Skip to content

Commit 2c90411

Browse files
committed
feat(d3d11): hint backend a texture is ShaderReadonly
1 parent c94c3aa commit 2c90411

3 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/d3d11/d3d11_texture_device.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ HRESULT CreateDeviceTextureInternal(MTLD3D11Device *pDevice,
370370
flags.set(TextureAllocationFlag::GpuPrivate);
371371
if (finalDesc.Usage == D3D11_USAGE_IMMUTABLE)
372372
flags.set(TextureAllocationFlag::GpuReadonly);
373+
if (!(finalDesc.BindFlags & (D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_RENDER_TARGET | D3D11_BIND_DEPTH_STENCIL)))
374+
flags.set(TextureAllocationFlag::ShaderReadonly);
373375
flags.set(TextureAllocationFlag::Shared);
374376
auto allocation = texture->allocate(flags);
375377

@@ -421,6 +423,8 @@ HRESULT CreateDeviceTextureInternal(MTLD3D11Device *pDevice,
421423

422424
Flags<TextureAllocationFlag> flags;
423425
flags.set(finalDesc.CPUAccessFlags ? TextureAllocationFlag::GpuManaged : TextureAllocationFlag::GpuPrivate);
426+
if (!(finalDesc.BindFlags & (D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_RENDER_TARGET | D3D11_BIND_DEPTH_STENCIL)))
427+
flags.set(TextureAllocationFlag::ShaderReadonly);
424428
if (finalDesc.Usage == D3D11_USAGE_IMMUTABLE)
425429
flags.set(TextureAllocationFlag::GpuReadonly);
426430
if (single_subresource && (finalDesc.BindFlags & D3D11_BIND_DEPTH_STENCIL)) {

src/d3d11/d3d11_texture_dynamic.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ HRESULT CreateDynamicTextureInternal(MTLD3D11Device *pDevice,
138138
auto texture = Rc<Texture>(new Texture(info, pDevice->GetMTLDevice()));
139139
Flags<TextureAllocationFlag> flags;
140140
flags.set(TextureAllocationFlag::GpuManaged);
141+
flags.set(TextureAllocationFlag::ShaderReadonly);
141142
if (pInitialData) {
142143
auto default_allocation = texture->allocate(flags);
143144
InitializeTextureData(pDevice, default_allocation->texture(), finalDesc, pInitialData);

src/d3d11/d3d11_texture_linear.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ TDynamicLinearTexture(
4747
bytes_per_row_(bytes_per_row) {
4848
this->texture_ = new Texture(bytes_per_image, bytes_per_row, descriptor, device->GetMTLDevice());
4949
Flags<TextureAllocationFlag> flags;
50+
flags.set(TextureAllocationFlag::ShaderReadonly);
5051
if (!this->m_parent->IsTraced() && pDesc->Usage == D3D11_USAGE_DYNAMIC)
5152
flags.set(TextureAllocationFlag::CpuWriteCombined);
5253
// if (pDesc->Usage != D3D11_USAGE_DEFAULT)

0 commit comments

Comments
 (0)