KhronosGroup / KhronosGroup/glslang

HLSL: Class with method causes validation error

Open
#1,462 1 comment 0 reactions 0 assignees View on GitHub
HLSL Missing Functionality
Dominant language
C++
Stars
3.6k
Forks
990
Avg merge
1d 2h
Merged PRs (30d)
31

Description

Hi,

I have noticed a validation error with spirv-val when compiling HLSL shaders with classes that have a member function and are nested inside a ConstantBuffer<>:

Example using a simple "getter" with return value:

// test01.frag.hlsl

class Nested
{
float4 m_value;

float4 GetValue()
{
return m_value;
}
};

struct MyBuffer
{
Nested m_nested;
};

ConstantBuffer< MyBuffer > in_buffer;

float4 main() : SV_TARGET0
{
float4 out_value;

out_value = in_buffer.m_nested.GetValue();

return out_value;
}

The shader is compiled with glslangValidator (TOT with SPIRV-Tools) via:

glslangValidator -Os -V450 -e main -o test01.frag.spv test01.frag.hlsl

Then validated via:

spirv-val test01.frag.spv

The output of spirv-val is:

error: 148: The result pointer storage class and base pointer storage class in OpAccessChain do not match.

The same error happens when using an inout parameter instead of a return value.

Contributor guide

Open the contributing guide

Research direction

Start by compiling the provided test01.frag.hlsl with glslangValidator and running spirv-val on the generated test01.frag.spv. Inspect the generated OpAccessChain instructions around the reported validation error, including the inout variant; done means both cases produce SPIR-V accepted by spirv-val.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.