Skip to content

Commit fcc38a3

Browse files
committed
Fix an issue in Asgard's Wrath due to dirty D3D11 state that would lead to eye mismatches.
1 parent 54cfc95 commit fcc38a3

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/d3d11/d3d11_helper.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ namespace vrperfkit {
116116
context->RSGetViewports( &state.numViewports, state.viewports );
117117
context->VSGetConstantBuffers( 0, 1, state.vsConstantBuffer.GetAddressOf() );
118118
context->PSGetConstantBuffers( 0, 1, state.psConstantBuffer.GetAddressOf() );
119+
context->CSGetConstantBuffers(0, 1, state.csConstantBuffer.GetAddressOf());
120+
context->CSGetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state.csShaderResources);
121+
context->CSGetUnorderedAccessViews(0, D3D11_1_UAV_SLOT_COUNT, state.csUavs);
119122
}
120123

121124
void RestoreD3D11State(ID3D11DeviceContext *context, const D3D11State &state) {
@@ -141,6 +144,18 @@ namespace vrperfkit {
141144
context->RSSetViewports( state.numViewports, state.viewports );
142145
context->VSSetConstantBuffers( 0, 1, state.vsConstantBuffer.GetAddressOf() );
143146
context->PSSetConstantBuffers( 0, 1, state.psConstantBuffer.GetAddressOf() );
147+
context->CSSetConstantBuffers(0, 1, state.csConstantBuffer.GetAddressOf());
148+
context->CSSetShaderResources(0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state.csShaderResources);
149+
for (int i = 0; i < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i) {
150+
if (state.csShaderResources[i])
151+
state.csShaderResources[i]->Release();
152+
}
153+
UINT initial = 0;
154+
context->CSSetUnorderedAccessViews(0, D3D11_1_UAV_SLOT_COUNT, state.csUavs, &initial);
155+
for (int i = 0; i < D3D11_1_UAV_SLOT_COUNT; ++i) {
156+
if (state.csUavs[i])
157+
state.csUavs[i]->Release();
158+
}
144159
}
145160

146161
ComPtr<ID3D11ShaderResourceView> CreateShaderResourceView(ID3D11Device *device, ID3D11Texture2D *texture, int arrayIndex) {

src/d3d11/d3d11_helper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ namespace vrperfkit {
4040
UINT numViewports = 0;
4141
ComPtr<ID3D11Buffer> vsConstantBuffer;
4242
ComPtr<ID3D11Buffer> psConstantBuffer;
43+
ComPtr<ID3D11Buffer> csConstantBuffer;
44+
ID3D11ShaderResourceView *csShaderResources[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
45+
ID3D11UnorderedAccessView *csUavs[D3D11_1_UAV_SLOT_COUNT];
4346
};
4447

4548
void StoreD3D11State(ID3D11DeviceContext *context, D3D11State &state);

0 commit comments

Comments
 (0)