mirror of https://github.com/RPCS3/rpcs3.git
d3d12: Avoid copying 8k of constant data per draw call
This commit is contained in:
parent
d88d078f4a
commit
8f31211557
|
@ -473,8 +473,7 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer()
|
|||
for (const RSXTransformConstant& c : m_transform_constants)
|
||||
{
|
||||
size_t offset = c.id * 4 * sizeof(float);
|
||||
float vector[] = { c.x, c.y, c.z, c.w };
|
||||
memcpy((char*)vertexConstantShadowCopy + offset, vector, 4 * sizeof(float));
|
||||
m_vertexConstants[offset] = c;
|
||||
}
|
||||
|
||||
size_t bufferSize = 512 * 4 * sizeof(float);
|
||||
|
@ -486,7 +485,16 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer()
|
|||
|
||||
void *constantsBufferMap;
|
||||
check(m_constantsData.m_heap->Map(0, &range, &constantsBufferMap));
|
||||
streamBuffer((char*)constantsBufferMap + heapOffset, vertexConstantShadowCopy, bufferSize);
|
||||
for (auto vertexConstants : m_vertexConstants)
|
||||
{
|
||||
float data[4] = {
|
||||
vertexConstants.second.x,
|
||||
vertexConstants.second.y,
|
||||
vertexConstants.second.z,
|
||||
vertexConstants.second.w
|
||||
};
|
||||
memcpy((char*)constantsBufferMap + heapOffset + vertexConstants.first, data, 4 * sizeof(float));
|
||||
}
|
||||
m_constantsData.m_heap->Unmap(0, &range);
|
||||
|
||||
D3D12_CONSTANT_BUFFER_VIEW_DESC constantBufferViewDesc = {};
|
||||
|
|
|
@ -545,8 +545,6 @@ D3D12GSRender::D3D12GSRender()
|
|||
m_perFrameStorage[1].Init(m_device);
|
||||
m_perFrameStorage[1].Reset();
|
||||
|
||||
vertexConstantShadowCopy = new float[512 * 4];
|
||||
|
||||
// Convert shader
|
||||
auto p = compileF32toU8CS();
|
||||
check(
|
||||
|
@ -620,7 +618,6 @@ D3D12GSRender::~D3D12GSRender()
|
|||
m_swapChain->Release();
|
||||
m_outputScalingPass.Release();
|
||||
m_device->Release();
|
||||
delete[] vertexConstantShadowCopy;
|
||||
unloadD3D12FunctionPointers();
|
||||
}
|
||||
|
||||
|
@ -1058,6 +1055,7 @@ void D3D12GSRender::Flip()
|
|||
// Flush
|
||||
m_texturesRTTs.clear();
|
||||
m_vertexCache.clear();
|
||||
m_vertexConstants.clear();
|
||||
|
||||
std::vector<std::function<void()> > cleaningFunction =
|
||||
{
|
||||
|
|
|
@ -333,7 +333,8 @@ public:
|
|||
GSFrameBase2 *m_frame;
|
||||
u32 m_draw_frames;
|
||||
u32 m_skip_frames;
|
||||
float *vertexConstantShadowCopy;
|
||||
|
||||
std::unordered_map<size_t, RSXTransformConstant> m_vertexConstants;
|
||||
|
||||
D3D12GSRender();
|
||||
virtual ~D3D12GSRender();
|
||||
|
|
Loading…
Reference in New Issue