KhronosGroup / glslang

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Other
2.91k stars 817 forks source link

Samplers passed as function arguments will not appear in spir-v reflection results. #3468

Closed snowfoxer closed 2 months ago

snowfoxer commented 6 months ago
#version 450
#extension GL_GOOGLE_include_directive : enable
#include "b.glsl"

layout(set = 0, binding = 0) uniform samplerCube u_ibl_view;
layout(set = 0, binding = 1) uniform sampler2D u_dfg_lut_view;
layout(location = 0) out vec4 o_color;

void main()
{
  o_color = vec4(IBL(u_ibl_view, u_dfg_lut_view), 1);
}
#ifndef B_GLSL_
#define B_GLSL_

vec3 IBL(samplerCube env_map, sampler2D dfg_lut)
{
  float r = 1;
  float lod = 1;
  vec4 env_map_sample = textureLod(env_map, vec3(r), lod);
  vec2 dfg = texture(dfg_lut, vec2(0, 0)).rg;
  return env_map_sample.xyz + vec3(dfg, 0.0);
}

#endif // B_GLSL_

Following next instructions:

  1. $spvc -Icode/shaders -V code/shaders/$1 -o out/shader_bin/$1.spv
  2. use spvReflectCreateShaderModule to get reflection result.

Result:

These samplers have the reflection structure "SpvReflectDescriptorBinding" member "access" but with a value of false.

arcady-lunarg commented 2 months ago

Sorry it took so long to triage but it appears that this is a spirv-reflect bug, where it's not counting the function call as an access.

spencer-lunarg commented 2 months ago

moved to spirv-reflect, this is a known issue

arcady-lunarg commented 2 months ago

Closing this issue since we can't seem to transfer it to the spirv-reflect repository.