Skip to content

vcc assumes push constants are structs #50

@btipling

Description

@btipling
VVL ERROR: Validation vkCreateShadersEXT(): pCreateInfos[0].pCode (spirv-val produced an error):
PushConstant OpVariable <id> '28[%28]' has illegal type.
From Vulkan spec, Push Constant Interface section:
Such variables must be typed as OpTypeStruct
  %t = OpVariable %_ptr_PushConstant_float PushConstant
The Vulkan spec states: Any variable in the PushConstant Storage Class must be typed as OpTypeStruct (https://vulkan.lunarg.com/doc/view/1.4.313.2/windows/antora/spec/latest/appendices/spirvenv.html#VUID-StandaloneSpirv-PushConstant-06808)
#include <shady.h>
#include <stdint.h>

float floorf(float) __asm__("shady::prim_op::floor");
float fmodf(float, float) __asm__("shady::prim_op::mod");
float sinf(float) __asm__("shady::prim_op::sin");

location(0) output native_vec4 out_color;

push_constant float t;

// A naive triangle
vertex_shader void main()
{
    float pi = 3.1415926535897932385f;
    native_vec4 pos;
    int i = 0;
    switch (gl_VertexIndex) {
        case 0:
            {
                pos = (native_vec4){-0.5f, 0.5f, 0.f, 1.f};
                out_color = (native_vec4){1.f, 0.f, 0.f, 1.f};
                break;
            }
        case 1:
            {
                pos = (native_vec4){0.f, -0.5f, 0.f, 1.f};
                out_color = (native_vec4){0.f, 1.f, 0.f, 1.f};
                break;
            }
        case 2:
            {
                pos = (native_vec4){0.5f, 0.5f, 0.f, 1.f};
                out_color = (native_vec4){0.f, 0.f, 1.f, 1.f};
                break;
            }
        default:
            {
                // Garbage data detectable with Renderdoc
                pos = (native_vec4){7.77f, 7.77f, 7.77f, 7.77f};
                out_color = (native_vec4){1.f, 0.f, 1.f, 1.f};
                break;
            }
    }
    float x_move_interval_ms = 10000.0f;
    float ms = floorf(t * 1000.f);
    float x_pos_modifier = ((fmodf(ms, x_move_interval_ms)) / x_move_interval_ms) * 2.f * (float)pi;
    float s_x_pos_mod = sinf(x_pos_modifier);
    pos.x *= (s_x_pos_mod/2.f);

    gl_Position = pos;
}

if I use a struct I do not get a VVL

#include <shady.h>
#include <stdint.h>

float floorf(float) __asm__("shady::prim_op::floor");
float fmodf(float, float) __asm__("shady::prim_op::mod");
float sinf(float) __asm__("shady::prim_op::sin");

location(0) output native_vec4 out_color;

typedef struct {
    float t;
} pc_t;

push_constant pc_t pc;

// A naive triangle
vertex_shader void main()
{
    float pi = 3.1415926535897932385f;
    native_vec4 pos;
    int i = 0;
    switch (gl_VertexIndex) {
        case 0:
            {
                pos = (native_vec4){-0.5f, 0.5f, 0.f, 1.f};
                out_color = (native_vec4){1.f, 0.f, 0.f, 1.f};
                break;
            }
        case 1:
            {
                pos = (native_vec4){0.f, -0.5f, 0.f, 1.f};
                out_color = (native_vec4){0.f, 1.f, 0.f, 1.f};
                break;
            }
        case 2:
            {
                pos = (native_vec4){0.5f, 0.5f, 0.f, 1.f};
                out_color = (native_vec4){0.f, 0.f, 1.f, 1.f};
                break;
            }
        default:
            {
                // Garbage data detectable with Renderdoc
                pos = (native_vec4){7.77f, 7.77f, 7.77f, 7.77f};
                out_color = (native_vec4){1.f, 0.f, 1.f, 1.f};
                break;
            }
    }
    float x_move_interval_ms = 10000.0f;
    float ms = floorf(pc.t * 1000.f);
    float x_pos_modifier = ((fmodf(ms, x_move_interval_ms)) / x_move_interval_ms) * 2.f * (float)pi;
    float s_x_pos_mod = sinf(x_pos_modifier);
    pos.x *= (s_x_pos_mod/2.f);

    gl_Position = pos;
}

VVLs continue to cause Access Violations that end my program when trying to create the shader, both in the SO and graphics pipeline path.

The slang version of this shader has no problems with the float push constant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions