Skip to content

Commit

Permalink
Bind constant buffers where you define them
Browse files Browse the repository at this point in the history
And remove possible slot collisions.
  • Loading branch information
ns6089 authored and cgutman committed Sep 5, 2023
1 parent bfde253 commit 8a19b24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/platform/windows/display_vram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ namespace platf::dxgi {
return;
}

device_ctx->VSSetConstantBuffers(0, 1, &info_scene);
device_ctx->PSSetConstantBuffers(0, 1, &color_matrix);
this->color_matrix = std::move(color_matrix);
}
Expand Down Expand Up @@ -471,6 +470,7 @@ namespace platf::dxgi {
BOOST_LOG(error) << "Failed to create info scene buffer"sv;
return -1;
}
device_ctx->VSSetConstantBuffers(0, 1, &info_scene);

D3D11_RENDER_TARGET_VIEW_DESC nv12_rt_desc {
format == DXGI_FORMAT_P010 ? DXGI_FORMAT_R16_UNORM : DXGI_FORMAT_R8_UNORM,
Expand Down Expand Up @@ -607,6 +607,7 @@ namespace platf::dxgi {
BOOST_LOG(error) << "Failed to create color matrix buffer"sv;
return -1;
}
device_ctx->PSSetConstantBuffers(0, 1, &color_matrix);

D3D11_INPUT_ELEMENT_DESC layout_desc {
"SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0
Expand Down Expand Up @@ -640,8 +641,6 @@ namespace platf::dxgi {
}

device_ctx->IASetInputLayout(input_layout.get());
device_ctx->PSSetConstantBuffers(0, 1, &color_matrix);
device_ctx->VSSetConstantBuffers(0, 1, &info_scene);

device_ctx->OMSetBlendState(blend_disable.get(), nullptr, 0xFFFFFFFFu);
device_ctx->PSSetSamplers(0, 1, &sampler_linear);
Expand Down Expand Up @@ -1367,7 +1366,7 @@ namespace platf::dxgi {
return -1;
}

device_ctx->PSSetConstantBuffers(0, 1, &sdr_multiplier);
device_ctx->PSSetConstantBuffers(1, 1, &sdr_multiplier);
}
else {
status = device->CreatePixelShader(scene_ps_hlsl->GetBufferPointer(), scene_ps_hlsl->GetBufferSize(), nullptr, &scene_ps);
Expand Down
2 changes: 1 addition & 1 deletion src_assets/windows/assets/shaders/directx/ScenePS_NW.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct PS_INPUT
float2 tex : TEXCOORD;
};

cbuffer SdrScaling : register(b0) {
cbuffer SdrScaling : register(b1) {
float scale_factor;
};

Expand Down

0 comments on commit 8a19b24

Please sign in to comment.