mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
[d3d11] Fix ref counting for state objects bound to a context
Using raw pointers is safe here since the objects never get destroyed during the lifetime of the context.
This commit is contained in:
parent
1282c2b99e
commit
68c257fc0d
@ -1903,7 +1903,7 @@ namespace dxvk {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
||||
ppSamplers[i] = m_state.vs.samplers[StartSlot + i].ref();
|
||||
ppSamplers[i] = ref(m_state.vs.samplers[StartSlot + i]);
|
||||
}
|
||||
|
||||
|
||||
@ -2045,7 +2045,7 @@ namespace dxvk {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
||||
ppSamplers[i] = m_state.hs.samplers[StartSlot + i].ref();
|
||||
ppSamplers[i] = ref(m_state.hs.samplers[StartSlot + i]);
|
||||
}
|
||||
|
||||
|
||||
@ -2187,7 +2187,7 @@ namespace dxvk {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
||||
ppSamplers[i] = m_state.ds.samplers[StartSlot + i].ref();
|
||||
ppSamplers[i] = ref(m_state.ds.samplers[StartSlot + i]);
|
||||
}
|
||||
|
||||
|
||||
@ -2329,7 +2329,7 @@ namespace dxvk {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
||||
ppSamplers[i] = m_state.gs.samplers[StartSlot + i].ref();
|
||||
ppSamplers[i] = ref(m_state.gs.samplers[StartSlot + i]);
|
||||
}
|
||||
|
||||
|
||||
@ -2471,7 +2471,7 @@ namespace dxvk {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
||||
ppSamplers[i] = m_state.ps.samplers[StartSlot + i].ref();
|
||||
ppSamplers[i] = ref(m_state.ps.samplers[StartSlot + i]);
|
||||
}
|
||||
|
||||
|
||||
@ -2669,7 +2669,7 @@ namespace dxvk {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
||||
ppSamplers[i] = m_state.cs.samplers[StartSlot + i].ref();
|
||||
ppSamplers[i] = ref(m_state.cs.samplers[StartSlot + i]);
|
||||
}
|
||||
|
||||
|
||||
@ -2864,7 +2864,7 @@ namespace dxvk {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
if (ppBlendState != nullptr)
|
||||
*ppBlendState = m_state.om.cbState.ref();
|
||||
*ppBlendState = ref(m_state.om.cbState);
|
||||
|
||||
if (BlendFactor != nullptr)
|
||||
std::memcpy(BlendFactor, m_state.om.blendFactor, sizeof(FLOAT) * 4);
|
||||
@ -2880,7 +2880,7 @@ namespace dxvk {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
if (ppDepthStencilState != nullptr)
|
||||
*ppDepthStencilState = m_state.om.dsState.ref();
|
||||
*ppDepthStencilState = ref(m_state.om.dsState);
|
||||
|
||||
if (pStencilRef != nullptr)
|
||||
*pStencilRef = m_state.om.stencilRef;
|
||||
@ -2982,7 +2982,7 @@ namespace dxvk {
|
||||
D3D10DeviceLock lock = LockContext();
|
||||
|
||||
if (ppRasterizerState != nullptr)
|
||||
*ppRasterizerState = m_state.rs.state.ref();
|
||||
*ppRasterizerState = ref(m_state.rs.state);
|
||||
}
|
||||
|
||||
|
||||
@ -3213,7 +3213,7 @@ namespace dxvk {
|
||||
void D3D11DeviceContext::ApplyBlendState() {
|
||||
if (m_state.om.cbState != nullptr) {
|
||||
EmitCs([
|
||||
cBlendState = m_state.om.cbState.ptr(),
|
||||
cBlendState = m_state.om.cbState,
|
||||
cSampleMask = m_state.om.sampleMask
|
||||
] (DxvkContext* ctx) {
|
||||
cBlendState->BindToContext(ctx, cSampleMask);
|
||||
@ -3251,7 +3251,7 @@ namespace dxvk {
|
||||
void D3D11DeviceContext::ApplyDepthStencilState() {
|
||||
if (m_state.om.dsState != nullptr) {
|
||||
EmitCs([
|
||||
cDepthStencilState = m_state.om.dsState.ptr()
|
||||
cDepthStencilState = m_state.om.dsState
|
||||
] (DxvkContext* ctx) {
|
||||
cDepthStencilState->BindToContext(ctx);
|
||||
});
|
||||
@ -3278,7 +3278,7 @@ namespace dxvk {
|
||||
void D3D11DeviceContext::ApplyRasterizerState() {
|
||||
if (m_state.rs.state != nullptr) {
|
||||
EmitCs([
|
||||
cRasterizerState = m_state.rs.state.ptr()
|
||||
cRasterizerState = m_state.rs.state
|
||||
] (DxvkContext* ctx) {
|
||||
cRasterizerState->BindToContext(ctx);
|
||||
});
|
||||
@ -3959,7 +3959,7 @@ namespace dxvk {
|
||||
uint32_t slotId = computeSamplerBinding(Stage, 0);
|
||||
|
||||
for (uint32_t i = 0; i < Bindings.size(); i++)
|
||||
BindSampler(slotId + i, Bindings[i].ptr());
|
||||
BindSampler(slotId + i, Bindings[i]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
using D3D11SamplerBindings = std::array<
|
||||
Com<D3D11SamplerState>, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT>;
|
||||
D3D11SamplerState*, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT>;
|
||||
|
||||
|
||||
struct D3D11ShaderResourceBindings {
|
||||
@ -125,8 +125,8 @@ namespace dxvk {
|
||||
std::array<Com<D3D11RenderTargetView, false>, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT> renderTargetViews;
|
||||
Com<D3D11DepthStencilView, false> depthStencilView;
|
||||
|
||||
Com<D3D11BlendState> cbState = nullptr;
|
||||
Com<D3D11DepthStencilState> dsState = nullptr;
|
||||
D3D11BlendState* cbState = nullptr;
|
||||
D3D11DepthStencilState* dsState = nullptr;
|
||||
|
||||
FLOAT blendFactor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
UINT sampleMask = 0xFFFFFFFFu;
|
||||
@ -144,7 +144,7 @@ namespace dxvk {
|
||||
std::array<D3D11_VIEWPORT, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE> viewports;
|
||||
std::array<D3D11_RECT, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE> scissors;
|
||||
|
||||
Com<D3D11RasterizerState> state;
|
||||
D3D11RasterizerState* state;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user