mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +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();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
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();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
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();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
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();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
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();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
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();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < NumSamplers; i++)
|
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();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
if (ppBlendState != nullptr)
|
if (ppBlendState != nullptr)
|
||||||
*ppBlendState = m_state.om.cbState.ref();
|
*ppBlendState = ref(m_state.om.cbState);
|
||||||
|
|
||||||
if (BlendFactor != nullptr)
|
if (BlendFactor != nullptr)
|
||||||
std::memcpy(BlendFactor, m_state.om.blendFactor, sizeof(FLOAT) * 4);
|
std::memcpy(BlendFactor, m_state.om.blendFactor, sizeof(FLOAT) * 4);
|
||||||
@ -2880,7 +2880,7 @@ namespace dxvk {
|
|||||||
D3D10DeviceLock lock = LockContext();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
if (ppDepthStencilState != nullptr)
|
if (ppDepthStencilState != nullptr)
|
||||||
*ppDepthStencilState = m_state.om.dsState.ref();
|
*ppDepthStencilState = ref(m_state.om.dsState);
|
||||||
|
|
||||||
if (pStencilRef != nullptr)
|
if (pStencilRef != nullptr)
|
||||||
*pStencilRef = m_state.om.stencilRef;
|
*pStencilRef = m_state.om.stencilRef;
|
||||||
@ -2982,7 +2982,7 @@ namespace dxvk {
|
|||||||
D3D10DeviceLock lock = LockContext();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
if (ppRasterizerState != nullptr)
|
if (ppRasterizerState != nullptr)
|
||||||
*ppRasterizerState = m_state.rs.state.ref();
|
*ppRasterizerState = ref(m_state.rs.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3213,7 +3213,7 @@ namespace dxvk {
|
|||||||
void D3D11DeviceContext::ApplyBlendState() {
|
void D3D11DeviceContext::ApplyBlendState() {
|
||||||
if (m_state.om.cbState != nullptr) {
|
if (m_state.om.cbState != nullptr) {
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cBlendState = m_state.om.cbState.ptr(),
|
cBlendState = m_state.om.cbState,
|
||||||
cSampleMask = m_state.om.sampleMask
|
cSampleMask = m_state.om.sampleMask
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
cBlendState->BindToContext(ctx, cSampleMask);
|
cBlendState->BindToContext(ctx, cSampleMask);
|
||||||
@ -3251,7 +3251,7 @@ namespace dxvk {
|
|||||||
void D3D11DeviceContext::ApplyDepthStencilState() {
|
void D3D11DeviceContext::ApplyDepthStencilState() {
|
||||||
if (m_state.om.dsState != nullptr) {
|
if (m_state.om.dsState != nullptr) {
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cDepthStencilState = m_state.om.dsState.ptr()
|
cDepthStencilState = m_state.om.dsState
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
cDepthStencilState->BindToContext(ctx);
|
cDepthStencilState->BindToContext(ctx);
|
||||||
});
|
});
|
||||||
@ -3278,7 +3278,7 @@ namespace dxvk {
|
|||||||
void D3D11DeviceContext::ApplyRasterizerState() {
|
void D3D11DeviceContext::ApplyRasterizerState() {
|
||||||
if (m_state.rs.state != nullptr) {
|
if (m_state.rs.state != nullptr) {
|
||||||
EmitCs([
|
EmitCs([
|
||||||
cRasterizerState = m_state.rs.state.ptr()
|
cRasterizerState = m_state.rs.state
|
||||||
] (DxvkContext* ctx) {
|
] (DxvkContext* ctx) {
|
||||||
cRasterizerState->BindToContext(ctx);
|
cRasterizerState->BindToContext(ctx);
|
||||||
});
|
});
|
||||||
@ -3959,7 +3959,7 @@ namespace dxvk {
|
|||||||
uint32_t slotId = computeSamplerBinding(Stage, 0);
|
uint32_t slotId = computeSamplerBinding(Stage, 0);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < Bindings.size(); i++)
|
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<
|
using D3D11SamplerBindings = std::array<
|
||||||
Com<D3D11SamplerState>, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT>;
|
D3D11SamplerState*, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT>;
|
||||||
|
|
||||||
|
|
||||||
struct D3D11ShaderResourceBindings {
|
struct D3D11ShaderResourceBindings {
|
||||||
@ -125,8 +125,8 @@ namespace dxvk {
|
|||||||
std::array<Com<D3D11RenderTargetView, false>, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT> renderTargetViews;
|
std::array<Com<D3D11RenderTargetView, false>, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT> renderTargetViews;
|
||||||
Com<D3D11DepthStencilView, false> depthStencilView;
|
Com<D3D11DepthStencilView, false> depthStencilView;
|
||||||
|
|
||||||
Com<D3D11BlendState> cbState = nullptr;
|
D3D11BlendState* cbState = nullptr;
|
||||||
Com<D3D11DepthStencilState> dsState = nullptr;
|
D3D11DepthStencilState* dsState = nullptr;
|
||||||
|
|
||||||
FLOAT blendFactor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
FLOAT blendFactor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
UINT sampleMask = 0xFFFFFFFFu;
|
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_VIEWPORT, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE> viewports;
|
||||||
std::array<D3D11_RECT, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE> scissors;
|
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