Skip to content

Question about strictness of resource states #123

@Yoshusa

Description

@Yoshusa

Dear Microsoft Team,

I attached two files, which contain a modified version of the HelloTexture sample.

The major change is, that I create an unordered access view to the texture in addition to the shader resource view in the LoadAssets method of the sample:

D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
uavDesc.Format = textureDesc.Format;
uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D;
uavDesc.Texture2D.MipSlice = 0;
uavDesc.Texture2D.PlaneSlice = 0;

handle.ptr += m_srvDescriptorSize;

m_device->CreateUnorderedAccessView(m_texture.Get(), nullptr, &uavDesc, handle);

Also I change the resource state of the texture from COPY_DEST to UNORDERED_ACCESS instead to PIXEL_SHADER_RESOURCE:

m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_texture.Get(), D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS));

I did not change anything in the rendering method, so the texture is still used there as a pixel shader resource. Now my question: Why is this working? Why can the texture be used as a pixel shader resource so its resource state is UNORDERED_ACCESS?

Is it because UNORDERED_ACCESS is a read/write state and the set read flag automatically includes read-only states? On the other hand, changing the state to or-combined UNORDERED_ACCESS | PIXEL_SHADER_RESOURCE is not allowed, cause read/write states cannot or-combined with read-only states. So to be honest, I am a bit confused.

I did not find an option in the Visual Studio Graphics Debugger (and neither in NSight) to check the current state of a resource. Did I have overseen something?

Kind regards,

Joerg Sahm

D3D12HelloTexture.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions