Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d3d12: Device loss due to invalid usage of CreateShaderResourceView #5097

Closed
nical opened this issue Jan 19, 2024 · 5 comments · Fixed by #5100
Closed

d3d12: Device loss due to invalid usage of CreateShaderResourceView #5097

nical opened this issue Jan 19, 2024 · 5 comments · Fixed by #5100
Labels
api: dx12 Issues with DX12 or DXGI type: bug Something isn't working

Comments

@nical
Copy link
Contributor

nical commented Jan 19, 2024

Description
A clear and concise description of what the bug is.

Repro steps

The following triggers a device loss in Firefox:

<script>
document.addEventListener("DOMContentLoaded", async () => {
    const adpt = await self.navigator.gpu.requestAdapter({})
    const dev = await adpt.requestDevice({})
    const tex = dev.createTexture({
        "size": {"width": 88},
        "format": "stencil8",
        "usage": GPUTextureUsage.TEXTURE_BINDING
    })
    tex.createView()
    dev.createSampler({})
})
</script>

Log:

D3D12 ERROR: ID3D12Device::CreateShaderResourceView: The Plane Slice 0 cannot be used when the resource format is R24G8_TYPELESS and the view format is X24_TYPELESS_G8_UINT.  See documentation for the set of valid view format names for this resource format, determining which how the resource (or part of it) will appear to shader. [ STATE_CREATION ERROR #29: CREATESHADERRESOURCEVIEW_INVALIDVIDEOPLANESLICE]
D3D12: Removing Device.
D3D12 ERROR: ID3D12Device::RemoveDevice: Device removal has been triggered for the following reason (DXGI_ERROR_INVALID_CALL: There is strong evidence that the application has performed an illegal or undefined operation, and such a condition could not be returned to the application cleanly through a return code). [ EXECUTION ERROR #232: DEVICE_REMOVAL_PROCESS_AT_FAULT]
Exception thrown at 0x00007FFA9C07CF19 in firefox.exe: Microsoft C++ exception: _com_error at memory location 0x0000001DE87F9A80.
Exception thrown at 0x00007FFA9C07CF19 in firefox.exe: Microsoft C++ exception: _com_error at memory location 0x0000001DE87F9DF8.
Exception thrown at 0x00007FFA9C07CF19 in firefox.exe: Microsoft C++ exception: _com_error at memory location 0x0000001DE87FAB80.

Platform

Windows with d3d12

@nical
Copy link
Contributor Author

nical commented Jan 19, 2024

@nical
Copy link
Contributor Author

nical commented Jan 19, 2024

wgpu trace (recorded on another computer):

[
Init(
    desc: (
        label: None,
        required_features: 0,
        required_limits: (
            maxTextureDimension1D: 8192,
            maxTextureDimension2D: 8192,
            maxTextureDimension3D: 2048,
            maxTextureArrayLayers: 256,
            maxBindGroups: 4,
            maxBindingsPerBindGroup: 1000,
            maxDynamicUniformBuffersPerPipelineLayout: 8,
            maxDynamicStorageBuffersPerPipelineLayout: 4,
            maxSampledTexturesPerShaderStage: 16,
            maxSamplersPerShaderStage: 16,
            maxStorageBuffersPerShaderStage: 8,
            maxStorageTexturesPerShaderStage: 4,
            maxUniformBuffersPerShaderStage: 12,
            maxUniformBufferBindingSize: 65536,
            maxStorageBufferBindingSize: 134217728,
            maxVertexBuffers: 8,
            maxBufferSize: 268435456,
            maxVertexAttributes: 16,
            maxVertexBufferArrayStride: 2048,
            minUniformBufferOffsetAlignment: 256,
            minStorageBufferOffsetAlignment: 256,
            maxInterStageShaderComponents: 60,
            maxComputeWorkgroupStorageSize: 16384,
            maxComputeInvocationsPerWorkgroup: 256,
            maxComputeWorkgroupSizeX: 256,
            maxComputeWorkgroupSizeY: 256,
            maxComputeWorkgroupSizeZ: 64,
            maxComputeWorkgroupsPerDimension: 65535,
            maxPushConstantSize: 256,
            maxNonSamplerBindings: 10000,
        ),
    ),
    backend: Vulkan,
),
CreateTexture(Id(0, 1, Vulkan), (
    label: None,
    size: (
        width: 88,
        height: 1,
        depthOrArrayLayers: 1,
    ),
    mip_level_count: 1,
    sample_count: 1,
    dimension: r#2d,
    format: "stencil8",
    usage: 4,
    view_formats: [],
)),
CreateTextureView(
    id: Id(0, 1, Vulkan),
    parent_id: Id(0, 1, Vulkan),
    desc: (
        label: None,
        format: None,
        dimension: None,
        range: (
            aspect: all,
            baseMipLevel: 0,
            mipLevelCount: None,
            baseArrayLayer: 0,
            arrayLayerCount: None,
        ),
    ),
),
CreateSampler(Id(0, 1, Vulkan), (
    label: None,
    address_modes: (r#clamp-to-edge, r#clamp-to-edge, r#clamp-to-edge),
    mag_filter: nearest,
    min_filter: nearest,
    mipmap_filter: nearest,
    lod_min_clamp: 0.0,
    lod_max_clamp: 1000.0,
    compare: None,
    anisotropy_clamp: 1,
    border_color: None,
)),
DestroySampler(Id(0, 1, Vulkan)),
DestroyTextureView(Id(0, 1, Vulkan)),
DestroyTexture(Id(0, 1, Vulkan)),
]

@dtzxporter

This comment was marked as outdated.

@teoxoy
Copy link
Member

teoxoy commented Jan 19, 2024

We create a view with the X24_TYPELESS_G8_UINT format (which supports "Shader ld") from the texture with the R24G8_TYPELESS format.

This should work but I guess we should use plane 1 not 0 since that's where the G8 data is.

@teoxoy teoxoy added type: bug Something isn't working api: dx12 Issues with DX12 or DXGI labels Jan 19, 2024
@dtzxporter
Copy link
Contributor

#5100 fixes the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: dx12 Issues with DX12 or DXGI type: bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants