KhronosGroup / KhronosGroup/glslang

HLSL validation error when a Texture2D is inside a cbuffer

Open
#2,754 5 comments 1 reaction 1 assignee View on GitHub

@greg-lunarg is already working on this.

Since Sep 15, 2021.

bug SPIR-V
Dominant language
C++
Stars
3.6k
Forks
990
Avg merge
1d 2h
Merged PRs (30d)
31

Description

Here's a minimal example that triggers the error.
Do you think it's legit ? This code is accepted by fxc.exe.

// input.frag.hlsl (updated)
cbuffer MyCBuffer
{
    Texture2D myTexture;
    SamplerState mySampler;
}

float4 main(float4 parFragIn : SV_POSITION) : SV_TARGET
{
    return myTexture.SampleLevel(mySampler, float2(0, 0), 0).rgba;
}
% glslangValidator -V100 --spirv-val -S frag -D --target-env vulkan1.0 input.frag.hlsl -e main
input.frag.hlsl
error: SPIRV-Tools Validation Errors
error: In Vulkan, OpTypeStruct must not contain an opaque type.
  %MyCBuffer = OpTypeStruct %13 %14

% glslangValidator --version
Glslang Version: 10:11.0.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 11.0.0
GLSL Version: 4.60 glslang Khronos. 11.0.0
SPIR-V Version 0x00010500, Revision 4
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 10
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.