Skip to content

Commit 1209132

Browse files
committed
[D3D11] Always prefer UpdateSubresource1() over emulated offset update (#156).
1 parent bc21854 commit 1209132

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

sources/Renderer/Direct3D11/Buffer/D3D11Buffer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void D3D11Buffer::WriteSubresource(ID3D11DeviceContext* context, const void* dat
127127
{
128128
/* Update subresource region of buffer */
129129
const D3D11_BOX dstBox{ offset, 0, 0, offset + dataSize, 1, 1 };
130-
if (offset != 0 && needsCommandListEmulation && context->GetType() == D3D11_DEVICE_CONTEXT_DEFERRED)
130+
if (offset != 0 && context->GetType() == D3D11_DEVICE_CONTEXT_DEFERRED)
131131
{
132132
#if LLGL_D3D11_ENABLE_FEATURELEVEL >= 1
133133
ComPtr<ID3D11DeviceContext1> context1;
@@ -138,6 +138,7 @@ void D3D11Buffer::WriteSubresource(ID3D11DeviceContext* context, const void* dat
138138
}
139139
else
140140
#endif
141+
if (needsCommandListEmulation)
141142
{
142143
/*
143144
Update subresource region of buffer with adjusted source pointer to workaround limitation of emulated command lists.
@@ -146,6 +147,8 @@ void D3D11Buffer::WriteSubresource(ID3D11DeviceContext* context, const void* dat
146147
const char* dataWithOffset = static_cast<const char*>(data) - offset;
147148
context->UpdateSubresource(GetNative(), 0, &dstBox, dataWithOffset, 0, 0);
148149
}
150+
else
151+
context->UpdateSubresource(GetNative(), 0, &dstBox, data, 0, 0);
149152
}
150153
else
151154
context->UpdateSubresource(GetNative(), 0, &dstBox, data, 0, 0);

sources/Renderer/Direct3D11/RenderState/D3D11StateManager.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ namespace LLGL
1818
{
1919

2020

21-
#if LLGL_D3D11_ENABLE_FEATURELEVEL >= 1
22-
2321
/*
2422
Returns true if the D3D runtime supports command lists natively.
2523
Otherwise, they will be emulated by the D3D runtime and all *SetConstantBuffers1() functions need a workaround as described here:
@@ -32,8 +30,6 @@ static bool D3DSupportsDriverCommandLists(ID3D11Device* device)
3230
return (SUCCEEDED(hr) && threadingCaps.DriverCommandLists != FALSE);
3331
}
3432

35-
#endif
36-
3733
/*
3834
Note:
3935
Maximum size for D3D11 cbuffer is 'D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT * 4 * sizeof(float)'
@@ -43,9 +39,7 @@ static constexpr UINT g_cbufferChunkSize = 4096u;
4339

4440
D3D11StateManager::D3D11StateManager(ID3D11Device* device, const ComPtr<ID3D11DeviceContext>& context) :
4541
context_ { context },
46-
#if LLGL_D3D11_ENABLE_FEATURELEVEL >= 1
4742
needsCommandListEmulation_ { !D3DSupportsDriverCommandLists(device) },
48-
#endif
4943
stagingCbufferPool_
5044
{
5145
device,

sources/Renderer/Direct3D11/RenderState/D3D11StateManager.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,7 @@ class D3D11StateManager
114114
// This is true if the D3D device does not natively support command lists.
115115
inline bool NeedsCommandListEmulation() const
116116
{
117-
#if LLGL_D3D11_ENABLE_FEATURELEVEL >= 1
118117
return needsCommandListEmulation_;
119-
#else
120-
return true;
121-
#endif
122118
}
123119

124120
private:
@@ -155,9 +151,10 @@ class D3D11StateManager
155151

156152
#if LLGL_D3D11_ENABLE_FEATURELEVEL >= 1
157153
ComPtr<ID3D11DeviceContext1> context1_;
158-
const bool needsCommandListEmulation_ = false;
159154
#endif
160155

156+
const bool needsCommandListEmulation_ = false;
157+
161158
D3D11StagingBufferPool stagingCbufferPool_;
162159

163160
D3DInputAssemblyState inputAssemblyState_;

0 commit comments

Comments
 (0)