Skip to content

Commit

Permalink
fixed tests and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fairywreath committed Dec 10, 2024
1 parent 350f46a commit fda2279
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
8 changes: 8 additions & 0 deletions source/slang/slang-ast-modifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,14 @@ class UncheckedGLSLBindingLayoutAttribute : public UncheckedGLSLLayoutAttribute
SLANG_UNREFLECTED
};

// GLSL `set` layout qualifier, does not include `binding`.
class UncheckedGLSLSetLayoutAttribute : public UncheckedGLSLLayoutAttribute
{
SLANG_AST_CLASS(UncheckedGLSLSetLayoutAttribute)

SLANG_UNREFLECTED
};

// GLSL `offset` layout qualifier.
class UncheckedGLSLOffsetLayoutAttribute : public UncheckedGLSLLayoutAttribute
{
Expand Down
4 changes: 2 additions & 2 deletions source/slang/slang-check-modifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1475,8 +1475,8 @@ AttributeBase* SemanticsVisitor::checkGLSLLayoutAttribute(
// attribute.
bool addNode = true;

const auto& name = uncheckedAttr->getKeywordName()->text;
if (as<UncheckedGLSLBindingLayoutAttribute>(uncheckedAttr) || name == "set")
if (as<UncheckedGLSLBindingLayoutAttribute>(uncheckedAttr) ||
as<UncheckedGLSLSetLayoutAttribute>(uncheckedAttr))
{
// Binding and set are coupled together as a descriptor table slot resource for codegen.
// Attempt to retrieve and annotate an existing binding attribute or create a new one.
Expand Down
4 changes: 4 additions & 0 deletions source/slang/slang-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,10 @@ static Modifier* parseUncheckedGLSLLayoutAttribute(Parser* parser, NameLoc& name
// through the list builder when implicitly injecting an offset qualifier.
attr = parser->astBuilder->create<UncheckedGLSLOffsetLayoutAttribute>();
}
else if (nameLoc.name->text == "set")
{
attr = parser->astBuilder->create<UncheckedGLSLSetLayoutAttribute>();
}
else
{
attr = parser->astBuilder->create<UncheckedGLSLLayoutAttribute>();
Expand Down
8 changes: 6 additions & 2 deletions tests/bugs/glsl-layout-define.hlsl.expected
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
result code = -1
standard error = {
tests/bugs/glsl-layout-define.hlsl(4): error 20001: unexpected identifier, expected integer literal
tests/bugs/glsl-layout-define.hlsl(4): error 30015: undefined identifier 'UNDEFINED_VK_BINDING'.
binding = UNDEFINED_VK_BINDING,
^~~~~~~~~~~~~~~~~~~~
tests/bugs/glsl-layout-define.hlsl(5): error 20001: unexpected identifier, expected integer literal
tests/bugs/glsl-layout-define.hlsl(5): error 30015: undefined identifier 'UNDEFINED_VK_SET'.
set = UNDEFINED_VK_SET)
^~~~~~~~~~~~~~~~
(0): error 30015: undefined identifier 'main'.
tests/bugs/glsl-layout-define.hlsl(3): error 38000: no function found matching entry point name 'main'
layout(
^~~~~~
}
standard output = {
}
2 changes: 1 addition & 1 deletion tests/hlsl-intrinsic/image-swizzle-write.slang
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target spirv -emit-spirv-directly
//TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target spirv

layout(rgba6f)
layout(rgba8)
RWTexture2D<float4> texture;

[numthreads(4, 1, 1)]
Expand Down

0 comments on commit fda2279

Please sign in to comment.