Skip to content

Commit

Permalink
Merge pull request #2386 from CodeLinaro/SPV_QCOM_image_processing2
Browse files Browse the repository at this point in the history
support for SPV_QCOM_image_processing2
  • Loading branch information
HansKristian-Work authored Oct 14, 2024
2 parents 5f48411 + 71b8e4b commit 208adcd
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 35 deletions.
2 changes: 1 addition & 1 deletion checkout_glslang_spirv_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2016-2021 The Khronos Group Inc.
# SPDX-License-Identifier: Apache-2.0

GLSLANG_REV=10ee92feb00712f444783032f5c9ee798887670d
GLSLANG_REV=142052fa30f9eca191aa9dcf65359fcaed09eeec
SPIRV_TOOLS_REV=fd96922e9a1814d92df46df03277788c799a4fad
SPIRV_HEADERS_REV=ea77f2a826bc820cb8f57f9b2a7c7eccb681c73
PROTOCOL=https
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

layout(location = 1) in vec2 _8;
layout(location = 1, component = 2) in float _16;
layout(location = 2) flat in float _22;
layout(location = 3) flat in float _22;
layout(location = 2, component = 1) flat in uint _28;
layout(location = 2, component = 2) flat in uint _33;
layout(location = 0) out vec4 o0;
Expand Down
14 changes: 7 additions & 7 deletions reference/opt/shaders/vulkan/vert/small-storage.vk.vert
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ layout(binding = 0, std140) uniform block
i8vec2 c;
u8vec2 d;
f16vec2 e;
} _26;
} _28;

layout(binding = 1, std430) readonly buffer storage
{
Expand All @@ -39,7 +39,7 @@ layout(binding = 1, std430) readonly buffer storage
i8vec3 h;
u8vec3 i;
f16vec3 j;
} _53;
} _55;

struct pushconst
{
Expand All @@ -50,20 +50,20 @@ struct pushconst
f16vec4 o;
};

uniform pushconst _76;
uniform pushconst _78;

layout(location = 0) out i16vec4 p;
layout(location = 0, component = 0) in int16_t foo;
layout(location = 0, component = 0) in uint16_t foo;
layout(location = 1) out u16vec4 q;
layout(location = 0, component = 1) in uint16_t bar;
layout(location = 2) out f16vec4 r;
layout(location = 1) in float16_t baz;

void main()
{
p = i16vec4((((ivec4(int(foo)) + ivec4(ivec2(_26.a), ivec2(_26.c))) - ivec4(ivec3(_53.f) / ivec3(_53.h), 1)) + ivec4(_76.k)) + ivec4(_76.m));
q = u16vec4((((uvec4(uint(bar)) + uvec4(uvec2(_26.b), uvec2(_26.d))) - uvec4(uvec3(_53.g) / uvec3(_53.i), 1u)) + uvec4(_76.l)) + uvec4(_76.n));
r = f16vec4(((vec4(float(baz)) + vec4(vec2(_26.e), 0.0, 1.0)) - vec4(vec3(_53.j), 1.0)) + vec4(_76.o));
p = i16vec4((((ivec4(int(uint(foo))) + ivec4(ivec2(_28.a), ivec2(_28.c))) - ivec4(ivec3(_55.f) / ivec3(_55.h), 1)) + ivec4(_78.k)) + ivec4(_78.m));
q = u16vec4((((uvec4(uint(bar)) + uvec4(uvec2(_28.b), uvec2(_28.d))) - uvec4(uvec3(_55.g) / uvec3(_55.i), 1u)) + uvec4(_78.l)) + uvec4(_78.n));
r = f16vec4(((vec4(float(baz)) + vec4(vec2(_28.e), 0.0, 1.0)) - vec4(vec3(_55.j), 1.0)) + vec4(_78.o));
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
}

14 changes: 7 additions & 7 deletions reference/opt/shaders/vulkan/vert/small-storage.vk.vert.vk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ layout(set = 0, binding = 0, std140) uniform block
i8vec2 c;
u8vec2 d;
f16vec2 e;
} _26;
} _28;

layout(set = 0, binding = 1, std430) readonly buffer storage
{
Expand All @@ -27,7 +27,7 @@ layout(set = 0, binding = 1, std430) readonly buffer storage
i8vec3 h;
u8vec3 i;
f16vec3 j;
} _53;
} _55;

layout(push_constant, std430) uniform pushconst
{
Expand All @@ -36,20 +36,20 @@ layout(push_constant, std430) uniform pushconst
i8vec4 m;
u8vec4 n;
f16vec4 o;
} _76;
} _78;

layout(location = 0) out i16vec4 p;
layout(location = 0, component = 0) in int16_t foo;
layout(location = 0, component = 0) in uint16_t foo;
layout(location = 1) out u16vec4 q;
layout(location = 0, component = 1) in uint16_t bar;
layout(location = 2) out f16vec4 r;
layout(location = 1) in float16_t baz;

void main()
{
p = i16vec4((((ivec4(int(foo)) + ivec4(ivec2(_26.a), ivec2(_26.c))) - ivec4(ivec3(_53.f) / ivec3(_53.h), 1)) + ivec4(_76.k)) + ivec4(_76.m));
q = u16vec4((((uvec4(uint(bar)) + uvec4(uvec2(_26.b), uvec2(_26.d))) - uvec4(uvec3(_53.g) / uvec3(_53.i), 1u)) + uvec4(_76.l)) + uvec4(_76.n));
r = f16vec4(((vec4(float(baz)) + vec4(vec2(_26.e), 0.0, 1.0)) - vec4(vec3(_53.j), 1.0)) + vec4(_76.o));
p = i16vec4((((ivec4(int(uint(foo))) + ivec4(ivec2(_28.a), ivec2(_28.c))) - ivec4(ivec3(_55.f) / ivec3(_55.h), 1)) + ivec4(_78.k)) + ivec4(_78.m));
q = u16vec4((((uvec4(uint(bar)) + uvec4(uvec2(_28.b), uvec2(_28.d))) - uvec4(uvec3(_55.g) / uvec3(_55.i), 1u)) + uvec4(_78.l)) + uvec4(_78.n));
r = f16vec4(((vec4(float(baz)) + vec4(vec2(_28.e), 0.0, 1.0)) - vec4(vec3(_55.j), 1.0)) + vec4(_78.o));
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
}

2 changes: 1 addition & 1 deletion reference/shaders/asm/frag/locations-components.asm.frag
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

layout(location = 1) in vec2 _8;
layout(location = 1, component = 2) in float _16;
layout(location = 2) flat in float _22;
layout(location = 3) flat in float _22;
layout(location = 2, component = 1) flat in uint _28;
layout(location = 2, component = 2) flat in uint _33;
layout(location = 0) out vec4 o0;
Expand Down
14 changes: 7 additions & 7 deletions reference/shaders/vulkan/vert/small-storage.vk.vert
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ layout(binding = 0, std140) uniform block
i8vec2 c;
u8vec2 d;
f16vec2 e;
} _26;
} _28;

layout(binding = 1, std430) readonly buffer storage
{
Expand All @@ -39,7 +39,7 @@ layout(binding = 1, std430) readonly buffer storage
i8vec3 h;
u8vec3 i;
f16vec3 j;
} _53;
} _55;

struct pushconst
{
Expand All @@ -50,20 +50,20 @@ struct pushconst
f16vec4 o;
};

uniform pushconst _76;
uniform pushconst _78;

layout(location = 0) out i16vec4 p;
layout(location = 0, component = 0) in int16_t foo;
layout(location = 0, component = 0) in uint16_t foo;
layout(location = 1) out u16vec4 q;
layout(location = 0, component = 1) in uint16_t bar;
layout(location = 2) out f16vec4 r;
layout(location = 1) in float16_t baz;

void main()
{
p = i16vec4((((ivec4(int(foo)) + ivec4(ivec2(_26.a), ivec2(_26.c))) - ivec4(ivec3(_53.f) / ivec3(_53.h), 1)) + ivec4(_76.k)) + ivec4(_76.m));
q = u16vec4((((uvec4(uint(bar)) + uvec4(uvec2(_26.b), uvec2(_26.d))) - uvec4(uvec3(_53.g) / uvec3(_53.i), 1u)) + uvec4(_76.l)) + uvec4(_76.n));
r = f16vec4(((vec4(float(baz)) + vec4(vec2(_26.e), 0.0, 1.0)) - vec4(vec3(_53.j), 1.0)) + vec4(_76.o));
p = i16vec4((((ivec4(int(uint(foo))) + ivec4(ivec2(_28.a), ivec2(_28.c))) - ivec4(ivec3(_55.f) / ivec3(_55.h), 1)) + ivec4(_78.k)) + ivec4(_78.m));
q = u16vec4((((uvec4(uint(bar)) + uvec4(uvec2(_28.b), uvec2(_28.d))) - uvec4(uvec3(_55.g) / uvec3(_55.i), 1u)) + uvec4(_78.l)) + uvec4(_78.n));
r = f16vec4(((vec4(float(baz)) + vec4(vec2(_28.e), 0.0, 1.0)) - vec4(vec3(_55.j), 1.0)) + vec4(_78.o));
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
}

14 changes: 7 additions & 7 deletions reference/shaders/vulkan/vert/small-storage.vk.vert.vk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ layout(set = 0, binding = 0, std140) uniform block
i8vec2 c;
u8vec2 d;
f16vec2 e;
} _26;
} _28;

layout(set = 0, binding = 1, std430) readonly buffer storage
{
Expand All @@ -27,7 +27,7 @@ layout(set = 0, binding = 1, std430) readonly buffer storage
i8vec3 h;
u8vec3 i;
f16vec3 j;
} _53;
} _55;

layout(push_constant, std430) uniform pushconst
{
Expand All @@ -36,20 +36,20 @@ layout(push_constant, std430) uniform pushconst
i8vec4 m;
u8vec4 n;
f16vec4 o;
} _76;
} _78;

layout(location = 0) out i16vec4 p;
layout(location = 0, component = 0) in int16_t foo;
layout(location = 0, component = 0) in uint16_t foo;
layout(location = 1) out u16vec4 q;
layout(location = 0, component = 1) in uint16_t bar;
layout(location = 2) out f16vec4 r;
layout(location = 1) in float16_t baz;

void main()
{
p = i16vec4((((ivec4(int(foo)) + ivec4(ivec2(_26.a), ivec2(_26.c))) - ivec4(ivec3(_53.f) / ivec3(_53.h), 1)) + ivec4(_76.k)) + ivec4(_76.m));
q = u16vec4((((uvec4(uint(bar)) + uvec4(uvec2(_26.b), uvec2(_26.d))) - uvec4(uvec3(_53.g) / uvec3(_53.i), 1u)) + uvec4(_76.l)) + uvec4(_76.n));
r = f16vec4(((vec4(float(baz)) + vec4(vec2(_26.e), 0.0, 1.0)) - vec4(vec3(_53.j), 1.0)) + vec4(_76.o));
p = i16vec4((((ivec4(int(uint(foo))) + ivec4(ivec2(_28.a), ivec2(_28.c))) - ivec4(ivec3(_55.f) / ivec3(_55.h), 1)) + ivec4(_78.k)) + ivec4(_78.m));
q = u16vec4((((uvec4(uint(bar)) + uvec4(uvec2(_28.b), uvec2(_28.d))) - uvec4(uvec3(_55.g) / uvec3(_55.i), 1u)) + uvec4(_78.l)) + uvec4(_78.n));
r = f16vec4(((vec4(float(baz)) + vec4(vec2(_28.e), 0.0, 1.0)) - vec4(vec3(_55.j), 1.0)) + vec4(_78.o));
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
}

2 changes: 1 addition & 1 deletion shaders/asm/frag/locations-components.asm.frag
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
OpDecorate %8 Location 1
OpDecorate %16 Location 1
OpDecorate %16 Component 2
OpDecorate %22 Location 2
OpDecorate %22 Location 3
OpDecorate %22 Flat
OpDecorate %28 Location 2
OpDecorate %28 Component 1
Expand Down
2 changes: 1 addition & 1 deletion shaders/vulkan/vert/small-storage.vk.vert
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#extension GL_AMD_gpu_shader_int16 : require
#extension GL_AMD_gpu_shader_half_float : require

layout(location = 0, component = 0) in int16_t foo;
layout(location = 0, component = 0) in uint16_t foo;
layout(location = 0, component = 1) in uint16_t bar;
layout(location = 1) in float16_t baz;

Expand Down
12 changes: 11 additions & 1 deletion spirv.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** Copyright (c) 2014-2020 The Khronos Group Inc.
** Copyright (c) 2014-2024 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and/or associated documentation files (the "Materials"),
Expand Down Expand Up @@ -511,6 +511,7 @@ typedef enum SpvDecoration_ {
SpvDecorationNoUnsignedWrap = 4470,
SpvDecorationWeightTextureQCOM = 4487,
SpvDecorationBlockMatchTextureQCOM = 4488,
SpvDecorationBlockMatchSamplerQCOM = 4499,
SpvDecorationExplicitInterpAMD = 4999,
SpvDecorationOverrideCoverageNV = 5248,
SpvDecorationPassthroughNV = 5250,
Expand Down Expand Up @@ -996,6 +997,7 @@ typedef enum SpvCapability_ {
SpvCapabilityTextureSampleWeightedQCOM = 4484,
SpvCapabilityTextureBoxFilterQCOM = 4485,
SpvCapabilityTextureBlockMatchQCOM = 4486,
SpvCapabilityTextureBlockMatch2QCOM = 4498,
SpvCapabilityFloat16ImageAMD = 5008,
SpvCapabilityImageGatherBiasLodAMD = 5009,
SpvCapabilityFragmentMaskAMD = 5010,
Expand Down Expand Up @@ -1605,6 +1607,10 @@ typedef enum SpvOp_ {
SpvOpImageBoxFilterQCOM = 4481,
SpvOpImageBlockMatchSSDQCOM = 4482,
SpvOpImageBlockMatchSADQCOM = 4483,
SpvOpImageBlockMatchWindowSSDQCOM = 4500,
SpvOpImageBlockMatchWindowSADQCOM = 4501,
SpvOpImageBlockMatchGatherSSDQCOM = 4502,
SpvOpImageBlockMatchGatherSADQCOM = 4503,
SpvOpGroupIAddNonUniformAMD = 5000,
SpvOpGroupFAddNonUniformAMD = 5001,
SpvOpGroupFMinNonUniformAMD = 5002,
Expand Down Expand Up @@ -2284,6 +2290,10 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy
case SpvOpImageBoxFilterQCOM: *hasResult = true; *hasResultType = true; break;
case SpvOpImageBlockMatchSSDQCOM: *hasResult = true; *hasResultType = true; break;
case SpvOpImageBlockMatchSADQCOM: *hasResult = true; *hasResultType = true; break;
case SpvOpImageBlockMatchWindowSSDQCOM: *hasResult = true; *hasResultType = true; break;
case SpvOpImageBlockMatchWindowSADQCOM: *hasResult = true; *hasResultType = true; break;
case SpvOpImageBlockMatchGatherSSDQCOM: *hasResult = true; *hasResultType = true; break;
case SpvOpImageBlockMatchGatherSADQCOM: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupIAddNonUniformAMD: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupFAddNonUniformAMD: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupFMinNonUniformAMD: *hasResult = true; *hasResultType = true; break;
Expand Down
12 changes: 11 additions & 1 deletion spirv.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2014-2020 The Khronos Group Inc.
// Copyright (c) 2014-2024 The Khronos Group Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and/or associated documentation files (the "Materials"),
Expand Down Expand Up @@ -507,6 +507,7 @@ enum Decoration {
DecorationNoUnsignedWrap = 4470,
DecorationWeightTextureQCOM = 4487,
DecorationBlockMatchTextureQCOM = 4488,
DecorationBlockMatchSamplerQCOM = 4499,
DecorationExplicitInterpAMD = 4999,
DecorationOverrideCoverageNV = 5248,
DecorationPassthroughNV = 5250,
Expand Down Expand Up @@ -992,6 +993,7 @@ enum Capability {
CapabilityTextureSampleWeightedQCOM = 4484,
CapabilityTextureBoxFilterQCOM = 4485,
CapabilityTextureBlockMatchQCOM = 4486,
CapabilityTextureBlockMatch2QCOM = 4498,
CapabilityFloat16ImageAMD = 5008,
CapabilityImageGatherBiasLodAMD = 5009,
CapabilityFragmentMaskAMD = 5010,
Expand Down Expand Up @@ -1601,6 +1603,10 @@ enum Op {
OpImageBoxFilterQCOM = 4481,
OpImageBlockMatchSSDQCOM = 4482,
OpImageBlockMatchSADQCOM = 4483,
OpImageBlockMatchWindowSSDQCOM = 4500,
OpImageBlockMatchWindowSADQCOM = 4501,
OpImageBlockMatchGatherSSDQCOM = 4502,
OpImageBlockMatchGatherSADQCOM = 4503,
OpGroupIAddNonUniformAMD = 5000,
OpGroupFAddNonUniformAMD = 5001,
OpGroupFMinNonUniformAMD = 5002,
Expand Down Expand Up @@ -2280,6 +2286,10 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
case OpImageBoxFilterQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchSSDQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchSADQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchWindowSSDQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchWindowSADQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchGatherSSDQCOM: *hasResult = true; *hasResultType = true; break;
case OpImageBlockMatchGatherSADQCOM: *hasResult = true; *hasResultType = true; break;
case OpGroupIAddNonUniformAMD: *hasResult = true; *hasResultType = true; break;
case OpGroupFAddNonUniformAMD: *hasResult = true; *hasResultType = true; break;
case OpGroupFMinNonUniformAMD: *hasResult = true; *hasResultType = true; break;
Expand Down
44 changes: 44 additions & 0 deletions spirv_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14481,6 +14481,50 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
break;
}

case OpImageBlockMatchWindowSSDQCOM:
case OpImageBlockMatchWindowSADQCOM:
case OpImageBlockMatchGatherSSDQCOM:
case OpImageBlockMatchGatherSADQCOM:
{
require_extension_internal("GL_QCOM_image_processing2");
uint32_t result_type_id = ops[0];
uint32_t id = ops[1];
string expr;
switch (opcode)
{
case OpImageBlockMatchWindowSSDQCOM:
expr = "textureBlockMatchWindowSSDQCOM";
break;
case OpImageBlockMatchWindowSADQCOM:
expr = "textureBlockMatchWindowSADQCOM";
break;
case OpImageBlockMatchGatherSSDQCOM:
expr = "textureBlockMatchGatherSSDQCOM";
break;
case OpImageBlockMatchGatherSADQCOM:
expr = "textureBlockMatchGatherSADQCOM";
break;
default:
SPIRV_CROSS_THROW("Invalid opcode for QCOM_image_processing2.");
}
expr += "(";

bool forward = false;
expr += to_expression(ops[2]);
expr += ", " + to_expression(ops[3]);

expr += ", " + to_non_uniform_aware_expression(ops[4]);
expr += ", " + to_expression(ops[5]);
expr += ", " + to_expression(ops[6]);

expr += ")";
emit_op(result_type_id, id, expr, forward);

inherit_expression_dependencies(id, ops[3]);
inherit_expression_dependencies(id, ops[5]);
break;
}

// Compute
case OpControlBarrier:
case OpMemoryBarrier:
Expand Down
2 changes: 2 additions & 0 deletions spirv_reflect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ void CompilerReflection::emit_resources(const char *tag, const SmallVector<Resou
json_stream->emit_json_key_value("WeightTextureQCOM", get_decoration(res.id, DecorationWeightTextureQCOM));
if (mask.get(DecorationBlockMatchTextureQCOM))
json_stream->emit_json_key_value("BlockMatchTextureQCOM", get_decoration(res.id, DecorationBlockMatchTextureQCOM));
if (mask.get(DecorationBlockMatchSamplerQCOM))
json_stream->emit_json_key_value("BlockMatchSamplerQCOM", get_decoration(res.id, DecorationBlockMatchSamplerQCOM));

// For images, the type itself adds a layout qualifer.
// Only emit the format for storage images.
Expand Down

0 comments on commit 208adcd

Please sign in to comment.