mirror of
https://github.com/WinDurango/WinDurango.git
synced 2026-05-02 15:29:13 -05:00
Implement GSSetConstantBuffers
This commit is contained in:
@@ -127,60 +127,20 @@ void wd::device_context_x::IASetVertexBuffers(UINT StartSlot, UINT NumBuffers, I
|
||||
|
||||
void wd::device_context_x::GSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, ID3D11Buffer* const* ppConstantBuffers)
|
||||
{
|
||||
if (!wrapped_interface)
|
||||
{
|
||||
printf("GSSetConstantBuffers: wrapped_interface is null.\n");
|
||||
return;
|
||||
}
|
||||
if (ppConstantBuffers != nullptr && *ppConstantBuffers != nullptr)
|
||||
{
|
||||
ID3D11Buffer* modifiedBuffers[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT];
|
||||
for (UINT i = 0; i < NumBuffers; ++i)
|
||||
{
|
||||
modifiedBuffers[i] = reinterpret_cast<wd::buffer*>(ppConstantBuffers[i])->wrapped_interface;
|
||||
}
|
||||
|
||||
if (!ppConstantBuffers)
|
||||
{
|
||||
printf("GSSetConstantBuffers: ppConstantBuffers is null.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ID3D11Device* contextDevice = nullptr;
|
||||
wrapped_interface->GetDevice(&contextDevice);
|
||||
|
||||
if (!contextDevice)
|
||||
{
|
||||
printf("GSSetConstantBuffers: failed to retrieve context device.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (UINT i = 0; i < NumBuffers; ++i)
|
||||
{
|
||||
ID3D11Buffer* buffer = ppConstantBuffers[ i ];
|
||||
if (!buffer)
|
||||
{
|
||||
printf("GSSetConstantBuffers: buffer at index %u is null.\n", i);
|
||||
continue; // Optional: could return instead
|
||||
}
|
||||
|
||||
ID3D11Device* bufferDevice = nullptr;
|
||||
buffer->GetDevice(&bufferDevice);
|
||||
|
||||
if (!bufferDevice)
|
||||
{
|
||||
printf("GSSetConstantBuffers: buffer at index %u has no device.\n", i);
|
||||
contextDevice->Release( );
|
||||
return;
|
||||
}
|
||||
|
||||
if (bufferDevice != contextDevice)
|
||||
{
|
||||
printf("GSSetConstantBuffers: buffer at index %u was created from a different device.\n", i);
|
||||
bufferDevice->Release( );
|
||||
contextDevice->Release( );
|
||||
return;
|
||||
}
|
||||
|
||||
bufferDevice->Release( );
|
||||
}
|
||||
|
||||
contextDevice->Release( );
|
||||
|
||||
wrapped_interface->GSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers);
|
||||
wrapped_interface->GSSetConstantBuffers(StartSlot, NumBuffers, modifiedBuffers);
|
||||
}
|
||||
else
|
||||
{
|
||||
wrapped_interface->GSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user