Skip to content

Commit

Permalink
Updated spirv-cross.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Oct 19, 2024
1 parent 4157813 commit 132266c
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 57 deletions.
12 changes: 11 additions & 1 deletion 3rdparty/spirv-cross/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 3rdparty/spirv-cross/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
17 changes: 16 additions & 1 deletion 3rdparty/spirv-cross/spirv_cross_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ struct spvc_resources_s : ScratchMemoryAllocation
SmallVector<spvc_reflected_resource> separate_images;
SmallVector<spvc_reflected_resource> separate_samplers;
SmallVector<spvc_reflected_resource> acceleration_structures;
SmallVector<spvc_reflected_resource> gl_plain_uniforms;

SmallVector<spvc_reflected_builtin_resource> builtin_inputs;
SmallVector<spvc_reflected_builtin_resource> builtin_outputs;

Expand Down Expand Up @@ -520,6 +522,10 @@ spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options, spvc_c
case SPVC_COMPILER_OPTION_HLSL_USE_ENTRY_POINT_NAME:
options->hlsl.use_entry_point_name = value != 0;
break;

case SPVC_COMPILER_OPTION_HLSL_PRESERVE_STRUCTURED_BUFFERS:
options->hlsl.preserve_structured_buffers = value != 0;
break;
#endif

#if SPIRV_CROSS_C_API_MSL
Expand Down Expand Up @@ -1855,6 +1861,8 @@ bool spvc_resources_s::copy_resources(const ShaderResources &resources)
return false;
if (!copy_resources(acceleration_structures, resources.acceleration_structures))
return false;
if (!copy_resources(gl_plain_uniforms, resources.gl_plain_uniforms))
return false;
if (!copy_resources(builtin_inputs, resources.builtin_inputs))
return false;
if (!copy_resources(builtin_outputs, resources.builtin_outputs))
Expand Down Expand Up @@ -2006,6 +2014,9 @@ spvc_result spvc_resources_get_resource_list_for_type(spvc_resources resources,
list = &resources->shader_record_buffers;
break;

case SPVC_RESOURCE_TYPE_GL_PLAIN_UNIFORM:
list = &resources->gl_plain_uniforms;

default:
break;
}
Expand Down Expand Up @@ -2177,7 +2188,11 @@ spvc_result spvc_compiler_get_entry_points(spvc_compiler compiler, const spvc_en

spvc_result spvc_compiler_set_entry_point(spvc_compiler compiler, const char *name, SpvExecutionModel model)
{
compiler->compiler->set_entry_point(name, static_cast<spv::ExecutionModel>(model));
SPVC_BEGIN_SAFE_SCOPE
{
compiler->compiler->set_entry_point(name, static_cast<spv::ExecutionModel>(model));
}
SPVC_END_SAFE_SCOPE(compiler->context, SPVC_ERROR_INVALID_ARGUMENT)
return SPVC_SUCCESS;
}

Expand Down
4 changes: 3 additions & 1 deletion 3rdparty/spirv-cross/spirv_cross_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern "C" {
/* Bumped if ABI or API breaks backwards compatibility. */
#define SPVC_C_API_VERSION_MAJOR 0
/* Bumped if APIs or enumerations are added in a backwards compatible way. */
#define SPVC_C_API_VERSION_MINOR 62
#define SPVC_C_API_VERSION_MINOR 64
/* Bumped if internal implementation details change. */
#define SPVC_C_API_VERSION_PATCH 0

Expand Down Expand Up @@ -226,6 +226,7 @@ typedef enum spvc_resource_type
SPVC_RESOURCE_TYPE_ACCELERATION_STRUCTURE = 12,
SPVC_RESOURCE_TYPE_RAY_QUERY = 13,
SPVC_RESOURCE_TYPE_SHADER_RECORD_BUFFER = 14,
SPVC_RESOURCE_TYPE_GL_PLAIN_UNIFORM = 15,
SPVC_RESOURCE_TYPE_INT_MAX = 0x7fffffff
} spvc_resource_type;

Expand Down Expand Up @@ -745,6 +746,7 @@ typedef enum spvc_compiler_option
SPVC_COMPILER_OPTION_MSL_FORCE_FRAGMENT_WITH_SIDE_EFFECTS_EXECUTION = 89 | SPVC_COMPILER_OPTION_MSL_BIT,

SPVC_COMPILER_OPTION_HLSL_USE_ENTRY_POINT_NAME = 90 | SPVC_COMPILER_OPTION_HLSL_BIT,
SPVC_COMPILER_OPTION_HLSL_PRESERVE_STRUCTURED_BUFFERS = 91 | SPVC_COMPILER_OPTION_HLSL_BIT,

SPVC_COMPILER_OPTION_INT_MAX = 0x7fffffff
} spvc_compiler_option;
Expand Down
3 changes: 2 additions & 1 deletion 3rdparty/spirv-cross/spirv_cross_parsed_ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ Bitset ParsedIR::get_buffer_block_type_flags(const SPIRType &type) const
Bitset ParsedIR::get_buffer_block_flags(const SPIRVariable &var) const
{
auto &type = get<SPIRType>(var.basetype);
assert(type.basetype == SPIRType::Struct);
if (type.basetype != SPIRType::Struct)
SPIRV_CROSS_THROW("Cannot get buffer block flags for non-buffer variable.");

// Some flags like non-writable, non-readable are actually found
// as member decorations. If all members have a decoration set, propagate
Expand Down
60 changes: 53 additions & 7 deletions 3rdparty/spirv-cross/spirv_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2764,6 +2764,8 @@ void CompilerGLSL::emit_interface_block(const SPIRVariable &var)
block_qualifier = "patch ";
else if (has_decoration(var.self, DecorationPerPrimitiveEXT))
block_qualifier = "perprimitiveEXT ";
else if (has_decoration(var.self, DecorationPerVertexKHR))
block_qualifier = "pervertexEXT ";
else
block_qualifier = "";

Expand Down Expand Up @@ -3691,11 +3693,11 @@ void CompilerGLSL::emit_resources()
auto &type = this->get<SPIRType>(undef.basetype);
// OpUndef can be void for some reason ...
if (type.basetype == SPIRType::Void)
return;
continue;

// This will break. It is bogus and should not be legal.
if (type_is_top_level_block(type))
return;
continue;

string initializer;
if (options.force_zero_initialized_variables && type_can_zero_initialize(type))
Expand Down Expand Up @@ -14481,6 +14483,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 Expand Up @@ -17608,7 +17654,7 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)

if (!collapsed_switch)
{
if (block_like_switch || is_legacy_es())
if (block_like_switch || is_legacy())
{
// ESSL 1.0 is not guaranteed to support do/while.
if (is_legacy_es())
Expand Down Expand Up @@ -17638,15 +17684,15 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
// Default case.
if (!block_like_switch)
{
if (is_legacy_es())
if (is_legacy())
statement("else");
else
statement("default:");
}
}
else
{
if (is_legacy_es())
if (is_legacy())
{
statement((i ? "else " : ""), "if (", to_legacy_case_label(block.condition, literals, label_suffix),
")");
Expand Down Expand Up @@ -17698,7 +17744,7 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)

if (block.default_block == block.next_block)
{
if (is_legacy_es())
if (is_legacy())
statement("else");
else
statement("default:");
Expand All @@ -17712,7 +17758,7 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)

if (!collapsed_switch)
{
if (block_like_switch && !is_legacy_es())
if ((block_like_switch || is_legacy()) && !is_legacy_es())
end_scope_decl("while(false)");
else
end_scope();
Expand Down
Loading

0 comments on commit 132266c

Please sign in to comment.