mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 08:21:29 +12:00
d3d12: Add some code documentation + rename some functions
This commit is contained in:
parent
f2d39d0e82
commit
aa66ddcd86
4 changed files with 36 additions and 19 deletions
|
@ -264,7 +264,7 @@ ID3D12Resource *createVertexBuffer(const VertexBufferFormat &vbf, const RSXVerte
|
||||||
return vertexBuffer;
|
return vertexBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::vector<D3D12_VERTEX_BUFFER_VIEW>, D3D12_INDEX_BUFFER_VIEW> D3D12GSRender::EnableVertexData(bool indexed_draw)
|
std::pair<std::vector<D3D12_VERTEX_BUFFER_VIEW>, D3D12_INDEX_BUFFER_VIEW> D3D12GSRender::UploadVertexBuffers(bool indexed_draw)
|
||||||
{
|
{
|
||||||
std::pair<std::vector<D3D12_VERTEX_BUFFER_VIEW>, D3D12_INDEX_BUFFER_VIEW> result;
|
std::pair<std::vector<D3D12_VERTEX_BUFFER_VIEW>, D3D12_INDEX_BUFFER_VIEW> result;
|
||||||
const std::vector<VertexBufferFormat> &vertexBufferFormat = FormatVertexData(m_vertex_data);
|
const std::vector<VertexBufferFormat> &vertexBufferFormat = FormatVertexData(m_vertex_data);
|
||||||
|
|
|
@ -630,7 +630,7 @@ void D3D12GSRender::ExecCMD(u32 cmd)
|
||||||
{
|
{
|
||||||
assert(cmd == NV4097_CLEAR_SURFACE);
|
assert(cmd == NV4097_CLEAR_SURFACE);
|
||||||
|
|
||||||
InitDrawBuffers();
|
PrepareRenderTargets();
|
||||||
|
|
||||||
ID3D12GraphicsCommandList *commandList;
|
ID3D12GraphicsCommandList *commandList;
|
||||||
check(m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, getCurrentResourceStorage().m_commandAllocator, nullptr, IID_PPV_ARGS(&commandList)));
|
check(m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, getCurrentResourceStorage().m_commandAllocator, nullptr, IID_PPV_ARGS(&commandList)));
|
||||||
|
@ -710,7 +710,7 @@ void D3D12GSRender::ExecCMD(u32 cmd)
|
||||||
|
|
||||||
void D3D12GSRender::ExecCMD()
|
void D3D12GSRender::ExecCMD()
|
||||||
{
|
{
|
||||||
InitDrawBuffers();
|
PrepareRenderTargets();
|
||||||
|
|
||||||
// Init vertex count
|
// Init vertex count
|
||||||
// TODO: Very hackish, clean this
|
// TODO: Very hackish, clean this
|
||||||
|
@ -743,7 +743,7 @@ void D3D12GSRender::ExecCMD()
|
||||||
|
|
||||||
if (m_indexed_array.m_count || m_draw_array_count)
|
if (m_indexed_array.m_count || m_draw_array_count)
|
||||||
{
|
{
|
||||||
const std::pair<std::vector<D3D12_VERTEX_BUFFER_VIEW>, D3D12_INDEX_BUFFER_VIEW> &vertexIndexBufferViews = EnableVertexData(m_indexed_array.m_count ? true : false);
|
const std::pair<std::vector<D3D12_VERTEX_BUFFER_VIEW>, D3D12_INDEX_BUFFER_VIEW> &vertexIndexBufferViews = UploadVertexBuffers(m_indexed_array.m_count ? true : false);
|
||||||
commandList->IASetVertexBuffers(0, (UINT)vertexIndexBufferViews.first.size(), vertexIndexBufferViews.first.data());
|
commandList->IASetVertexBuffers(0, (UINT)vertexIndexBufferViews.first.size(), vertexIndexBufferViews.first.data());
|
||||||
if (m_forcedIndexBuffer || m_indexed_array.m_count)
|
if (m_forcedIndexBuffer || m_indexed_array.m_count)
|
||||||
commandList->IASetIndexBuffer(&vertexIndexBufferViews.second);
|
commandList->IASetIndexBuffer(&vertexIndexBufferViews.second);
|
||||||
|
|
|
@ -81,6 +81,14 @@ struct InitHeap<ID3D12Resource>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper around a ID3D12Resource or a ID3D12Heap.
|
||||||
|
* Acts as a ring buffer : hold a get and put pointers,
|
||||||
|
* put pointer is used as storage space offset
|
||||||
|
* and get is used as beginning of in use data space.
|
||||||
|
* This wrapper checks that put pointer doesn't cross get one.
|
||||||
|
*/
|
||||||
template<typename T, size_t Alignment>
|
template<typename T, size_t Alignment>
|
||||||
struct DataHeap
|
struct DataHeap
|
||||||
{
|
{
|
||||||
|
@ -154,6 +162,12 @@ struct DataHeap
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for a worker thread that executes lambda functions
|
||||||
|
* in the order they were submitted during its lifetime.
|
||||||
|
* Used mostly to release data that are not needed anymore.
|
||||||
|
*/
|
||||||
struct GarbageCollectionThread
|
struct GarbageCollectionThread
|
||||||
{
|
{
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
|
@ -192,12 +206,25 @@ private:
|
||||||
void Init(ID3D12Device *device);
|
void Init(ID3D12Device *device);
|
||||||
void Release();
|
void Release();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores data related to the scaling pass that turns internal
|
||||||
|
* render targets into presented buffers.
|
||||||
|
*/
|
||||||
Shader m_outputScalingPass;
|
Shader m_outputScalingPass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data used when depth buffer is converted to uchar textures.
|
||||||
|
*/
|
||||||
ID3D12PipelineState *m_convertPSO;
|
ID3D12PipelineState *m_convertPSO;
|
||||||
ID3D12RootSignature *m_convertRootSignature;
|
ID3D12RootSignature *m_convertRootSignature;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores data that are "ping ponged" between frame.
|
||||||
|
* For instance command allocator : maintains 2 command allocators and
|
||||||
|
* swap between them when frame is flipped.
|
||||||
|
*/
|
||||||
struct ResourceStorage
|
struct ResourceStorage
|
||||||
{
|
{
|
||||||
ID3D12Fence* m_frameFinishedFence;
|
ID3D12Fence* m_frameFinishedFence;
|
||||||
|
@ -296,29 +323,19 @@ private:
|
||||||
virtual void Close() override;
|
virtual void Close() override;
|
||||||
|
|
||||||
bool LoadProgram();
|
bool LoadProgram();
|
||||||
std::pair<std::vector<D3D12_VERTEX_BUFFER_VIEW>, D3D12_INDEX_BUFFER_VIEW> EnableVertexData(bool indexed_draw = false);
|
std::pair<std::vector<D3D12_VERTEX_BUFFER_VIEW>, D3D12_INDEX_BUFFER_VIEW> UploadVertexBuffers(bool indexed_draw = false);
|
||||||
void setScaleOffset();
|
void setScaleOffset();
|
||||||
void FillVertexShaderConstantsBuffer();
|
void FillVertexShaderConstantsBuffer();
|
||||||
void FillPixelShaderConstantsBuffer();
|
void FillPixelShaderConstantsBuffer();
|
||||||
/**
|
/**
|
||||||
|
* Upload textures to Data heap if necessary and create necessary descriptor in the per frame storage struct.
|
||||||
* returns the number of texture uploaded
|
* returns the number of texture uploaded
|
||||||
*/
|
*/
|
||||||
size_t UploadTextures();
|
size_t UploadTextures();
|
||||||
size_t GetMaxAniso(size_t aniso);
|
size_t GetMaxAniso(size_t aniso);
|
||||||
D3D12_TEXTURE_ADDRESS_MODE GetWrap(size_t wrap);
|
D3D12_TEXTURE_ADDRESS_MODE GetWrap(size_t wrap);
|
||||||
|
|
||||||
/*void DisableVertexData();
|
void PrepareRenderTargets();
|
||||||
|
|
||||||
void WriteBuffers();
|
|
||||||
void WriteColorBuffers();
|
|
||||||
void WriteColorBufferA();
|
|
||||||
void WriteColorBufferB();
|
|
||||||
void WriteColorBufferC();
|
|
||||||
void WriteColorBufferD();
|
|
||||||
|
|
||||||
void DrawObjects();*/
|
|
||||||
void InitDrawBuffers();
|
|
||||||
void WriteDepthBuffer();
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnInit() override;
|
virtual void OnInit() override;
|
||||||
virtual void OnInitThread() override;
|
virtual void OnInitThread() override;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "D3D12.h"
|
#include "D3D12.h"
|
||||||
#include "D3D12GSRender.h"
|
#include "D3D12GSRender.h"
|
||||||
|
|
||||||
void D3D12GSRender::InitDrawBuffers()
|
void D3D12GSRender::PrepareRenderTargets()
|
||||||
{
|
{
|
||||||
// FBO location has changed, previous data might be copied
|
// FBO location has changed, previous data might be copied
|
||||||
u32 address_a = GetAddress(m_surface_offset_a, m_context_dma_color_a - 0xfeed0000);
|
u32 address_a = GetAddress(m_surface_offset_a, m_context_dma_color_a - 0xfeed0000);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue