Updated spirv-cross.
This commit is contained in:
parent
ce48e02d2e
commit
84557d87eb
1
3rdparty/spirv-cross/spirv_common.hpp
vendored
1
3rdparty/spirv-cross/spirv_common.hpp
vendored
@ -1634,6 +1634,7 @@ struct Meta
|
||||
uint32_t offset = 0;
|
||||
uint32_t xfb_buffer = 0;
|
||||
uint32_t xfb_stride = 0;
|
||||
uint32_t stream = 0;
|
||||
uint32_t array_stride = 0;
|
||||
uint32_t matrix_stride = 0;
|
||||
uint32_t input_attachment = 0;
|
||||
|
9
3rdparty/spirv-cross/spirv_cross.cpp
vendored
9
3rdparty/spirv-cross/spirv_cross.cpp
vendored
@ -1717,7 +1717,7 @@ uint32_t Compiler::evaluate_spec_constant_u32(const SPIRConstantOp &spec) const
|
||||
break;
|
||||
|
||||
case OpSNegate:
|
||||
value = -eval_u32(spec.arguments[0]);
|
||||
value = uint32_t(-int32_t(eval_u32(spec.arguments[0])));
|
||||
break;
|
||||
|
||||
case OpSelect:
|
||||
@ -2062,6 +2062,13 @@ bool Compiler::is_tessellation_shader(ExecutionModel model)
|
||||
return model == ExecutionModelTessellationControl || model == ExecutionModelTessellationEvaluation;
|
||||
}
|
||||
|
||||
bool Compiler::is_vertex_like_shader() const
|
||||
{
|
||||
auto model = get_execution_model();
|
||||
return model == ExecutionModelVertex || model == ExecutionModelGeometry ||
|
||||
model == ExecutionModelTessellationControl || model == ExecutionModelTessellationEvaluation;
|
||||
}
|
||||
|
||||
bool Compiler::is_tessellation_shader() const
|
||||
{
|
||||
return is_tessellation_shader(get_execution_model());
|
||||
|
2
3rdparty/spirv-cross/spirv_cross.hpp
vendored
2
3rdparty/spirv-cross/spirv_cross.hpp
vendored
@ -1063,6 +1063,8 @@ protected:
|
||||
uint32_t evaluate_spec_constant_u32(const SPIRConstantOp &spec) const;
|
||||
uint32_t evaluate_constant_u32(uint32_t id) const;
|
||||
|
||||
bool is_vertex_like_shader() const;
|
||||
|
||||
private:
|
||||
// Used only to implement the old deprecated get_entry_point() interface.
|
||||
const SPIREntryPoint &get_first_entry_point(const std::string &name) const;
|
||||
|
@ -63,8 +63,7 @@ public:
|
||||
private:
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
// MSVC 2013 workarounds, sigh ...
|
||||
union
|
||||
{
|
||||
union {
|
||||
char aligned_char[sizeof(T) * N];
|
||||
double dummy_aligner;
|
||||
} u;
|
||||
@ -212,6 +211,10 @@ public:
|
||||
this->buffer_size = count;
|
||||
}
|
||||
|
||||
SmallVector(std::initializer_list<T> init) SPIRV_CROSS_NOEXCEPT : SmallVector(init.begin(), init.end())
|
||||
{
|
||||
}
|
||||
|
||||
SmallVector(SmallVector &&other) SPIRV_CROSS_NOEXCEPT : SmallVector()
|
||||
{
|
||||
*this = std::move(other);
|
||||
|
20
3rdparty/spirv-cross/spirv_cross_parsed_ir.cpp
vendored
20
3rdparty/spirv-cross/spirv_cross_parsed_ir.cpp
vendored
@ -388,6 +388,10 @@ void ParsedIR::set_decoration(ID id, Decoration decoration, uint32_t argument)
|
||||
dec.xfb_stride = argument;
|
||||
break;
|
||||
|
||||
case DecorationStream:
|
||||
dec.stream = argument;
|
||||
break;
|
||||
|
||||
case DecorationArrayStride:
|
||||
dec.array_stride = argument;
|
||||
break;
|
||||
@ -467,6 +471,10 @@ void ParsedIR::set_member_decoration(TypeID id, uint32_t index, Decoration decor
|
||||
dec.xfb_stride = argument;
|
||||
break;
|
||||
|
||||
case DecorationStream:
|
||||
dec.stream = argument;
|
||||
break;
|
||||
|
||||
case DecorationSpecId:
|
||||
dec.spec_id = argument;
|
||||
break;
|
||||
@ -584,6 +592,8 @@ uint32_t ParsedIR::get_decoration(ID id, Decoration decoration) const
|
||||
return dec.xfb_buffer;
|
||||
case DecorationXfbStride:
|
||||
return dec.xfb_stride;
|
||||
case DecorationStream:
|
||||
return dec.stream;
|
||||
case DecorationBinding:
|
||||
return dec.binding;
|
||||
case DecorationDescriptorSet:
|
||||
@ -656,6 +666,10 @@ void ParsedIR::unset_decoration(ID id, Decoration decoration)
|
||||
dec.xfb_stride = 0;
|
||||
break;
|
||||
|
||||
case DecorationStream:
|
||||
dec.stream = 0;
|
||||
break;
|
||||
|
||||
case DecorationBinding:
|
||||
dec.binding = 0;
|
||||
break;
|
||||
@ -730,6 +744,8 @@ uint32_t ParsedIR::get_member_decoration(TypeID id, uint32_t index, Decoration d
|
||||
return dec.xfb_buffer;
|
||||
case DecorationXfbStride:
|
||||
return dec.xfb_stride;
|
||||
case DecorationStream:
|
||||
return dec.stream;
|
||||
case DecorationSpecId:
|
||||
return dec.spec_id;
|
||||
case DecorationIndex:
|
||||
@ -826,6 +842,10 @@ void ParsedIR::unset_member_decoration(TypeID id, uint32_t index, Decoration dec
|
||||
dec.xfb_stride = 0;
|
||||
break;
|
||||
|
||||
case DecorationStream:
|
||||
dec.stream = 0;
|
||||
break;
|
||||
|
||||
case DecorationSpecId:
|
||||
dec.spec_id = 0;
|
||||
break;
|
||||
|
991
3rdparty/spirv-cross/spirv_glsl.cpp
vendored
991
3rdparty/spirv-cross/spirv_glsl.cpp
vendored
File diff suppressed because it is too large
Load Diff
92
3rdparty/spirv-cross/spirv_glsl.hpp
vendored
92
3rdparty/spirv-cross/spirv_glsl.hpp
vendored
@ -135,12 +135,14 @@ public:
|
||||
|
||||
struct VertexOptions
|
||||
{
|
||||
// GLSL: In vertex shaders, rewrite [0, w] depth (Vulkan/D3D style) to [-w, w] depth (GL style).
|
||||
// MSL: In vertex shaders, rewrite [-w, w] depth (GL style) to [0, w] depth.
|
||||
// HLSL: In vertex shaders, rewrite [-w, w] depth (GL style) to [0, w] depth.
|
||||
// "Vertex-like shader" here is any shader stage that can write BuiltInPosition.
|
||||
|
||||
// GLSL: In vertex-like shaders, rewrite [0, w] depth (Vulkan/D3D style) to [-w, w] depth (GL style).
|
||||
// MSL: In vertex-like shaders, rewrite [-w, w] depth (GL style) to [0, w] depth.
|
||||
// HLSL: In vertex-like shaders, rewrite [-w, w] depth (GL style) to [0, w] depth.
|
||||
bool fixup_clipspace = false;
|
||||
|
||||
// Inverts gl_Position.y or equivalent.
|
||||
// In vertex-like shaders, inverts gl_Position.y or equivalent.
|
||||
bool flip_vert_y = false;
|
||||
|
||||
// GLSL only, for HLSL version of this option, see CompilerHLSL.
|
||||
@ -241,7 +243,84 @@ public:
|
||||
// - Images which are statically used at least once with Dref opcodes.
|
||||
bool variable_is_depth_or_compare(VariableID id) const;
|
||||
|
||||
|
||||
protected:
|
||||
struct ShaderSubgroupSupportHelper
|
||||
{
|
||||
// lower enum value = greater priority
|
||||
enum Candidate
|
||||
{
|
||||
KHR_shader_subgroup_ballot,
|
||||
KHR_shader_subgroup_basic,
|
||||
KHR_shader_subgroup_vote,
|
||||
NV_gpu_shader_5,
|
||||
NV_shader_thread_group,
|
||||
NV_shader_thread_shuffle,
|
||||
ARB_shader_ballot,
|
||||
ARB_shader_group_vote,
|
||||
AMD_gcn_shader,
|
||||
|
||||
CandidateCount
|
||||
};
|
||||
|
||||
static const char *get_extension_name(Candidate c);
|
||||
static SmallVector<std::string> get_extra_required_extension_names(Candidate c);
|
||||
static const char *get_extra_required_extension_predicate(Candidate c);
|
||||
|
||||
enum Feature
|
||||
{
|
||||
SubgroupMask,
|
||||
SubgroupSize,
|
||||
SubgroupInvocationID,
|
||||
SubgroupID,
|
||||
NumSubgroups,
|
||||
SubgroupBrodcast_First,
|
||||
SubgroupBallotFindLSB_MSB,
|
||||
SubgroupAll_Any_AllEqualBool,
|
||||
SubgroupAllEqualT,
|
||||
SubgroupElect,
|
||||
SubgroupBarrier,
|
||||
SubgroupMemBarrier,
|
||||
SubgroupBallot,
|
||||
SubgroupInverseBallot_InclBitCount_ExclBitCout,
|
||||
SubgroupBallotBitExtract,
|
||||
SubgroupBallotBitCount,
|
||||
|
||||
FeatureCount
|
||||
};
|
||||
|
||||
using FeatureMask = uint32_t;
|
||||
static_assert(sizeof(FeatureMask) * 8u >= FeatureCount, "Mask type needs more bits.");
|
||||
|
||||
using CandidateVector = SmallVector<Candidate, CandidateCount>;
|
||||
using FeatureVector = SmallVector<Feature>;
|
||||
|
||||
static FeatureVector get_feature_dependencies(Feature feature);
|
||||
static FeatureMask get_feature_dependency_mask(Feature feature);
|
||||
static bool can_feature_be_implemented_without_extensions(Feature feature);
|
||||
static Candidate get_KHR_extension_for_feature(Feature feature);
|
||||
|
||||
struct Result
|
||||
{
|
||||
Result();
|
||||
uint32_t weights[CandidateCount];
|
||||
};
|
||||
|
||||
void request_feature(Feature feature);
|
||||
bool is_feature_requested(Feature feature) const;
|
||||
Result resolve() const;
|
||||
|
||||
static CandidateVector get_candidates_for_feature(Feature ft, const Result &r);
|
||||
|
||||
private:
|
||||
static CandidateVector get_candidates_for_feature(Feature ft);
|
||||
static FeatureMask build_mask(const SmallVector<Feature> &features);
|
||||
FeatureMask feature_mask = 0;
|
||||
};
|
||||
|
||||
// TODO remove this function when all subgroup ops are supported (or make it always return true)
|
||||
static bool is_supported_subgroup_op_in_opengl(spv::Op op);
|
||||
|
||||
void reset();
|
||||
void emit_function(SPIRFunction &func, const Bitset &return_flags);
|
||||
|
||||
@ -272,6 +351,8 @@ protected:
|
||||
void build_workgroup_size(SmallVector<std::string> &arguments, const SpecializationConstant &x,
|
||||
const SpecializationConstant &y, const SpecializationConstant &z);
|
||||
|
||||
void request_subgroup_feature(ShaderSubgroupSupportHelper::Feature feature);
|
||||
|
||||
virtual void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id);
|
||||
virtual void emit_texture_op(const Instruction &i, bool sparse);
|
||||
virtual std::string to_texture_op(const Instruction &i, bool sparse, bool *forward,
|
||||
@ -483,6 +564,7 @@ protected:
|
||||
|
||||
void emit_struct(SPIRType &type);
|
||||
void emit_resources();
|
||||
void emit_extension_workarounds(spv::ExecutionModel model);
|
||||
void emit_buffer_block_native(const SPIRVariable &var);
|
||||
void emit_buffer_reference_block(SPIRType &type, bool forward_declaration);
|
||||
void emit_buffer_block_legacy(const SPIRVariable &var);
|
||||
@ -680,6 +762,8 @@ protected:
|
||||
std::unordered_set<uint32_t> flattened_buffer_blocks;
|
||||
std::unordered_map<uint32_t, bool> flattened_structs;
|
||||
|
||||
ShaderSubgroupSupportHelper shader_subgroup_supporter;
|
||||
|
||||
std::string load_flattened_struct(const std::string &basename, const SPIRType &type);
|
||||
std::string to_flattened_struct_member(const std::string &basename, const SPIRType &type, uint32_t index);
|
||||
void store_flattened_struct(uint32_t lhs_id, uint32_t value);
|
||||
|
2
3rdparty/spirv-cross/spirv_hlsl.cpp
vendored
2
3rdparty/spirv-cross/spirv_hlsl.cpp
vendored
@ -2649,7 +2649,7 @@ void CompilerHLSL::emit_hlsl_entry_point()
|
||||
|
||||
void CompilerHLSL::emit_fixup()
|
||||
{
|
||||
if (get_entry_point().model == ExecutionModelVertex)
|
||||
if (is_vertex_like_shader())
|
||||
{
|
||||
// Do various mangling on the gl_Position.
|
||||
if (hlsl_options.shader_model <= 30)
|
||||
|
4
3rdparty/spirv-cross/spirv_msl.cpp
vendored
4
3rdparty/spirv-cross/spirv_msl.cpp
vendored
@ -9028,9 +9028,7 @@ string CompilerMSL::convert_row_major_matrix(string exp_str, const SPIRType &exp
|
||||
// Called automatically at the end of the entry point function
|
||||
void CompilerMSL::emit_fixup()
|
||||
{
|
||||
if ((get_execution_model() == ExecutionModelVertex ||
|
||||
get_execution_model() == ExecutionModelTessellationEvaluation) &&
|
||||
stage_out_var_id && !qual_pos_var_name.empty() && !capture_output_to_buffer)
|
||||
if (is_vertex_like_shader() && stage_out_var_id && !qual_pos_var_name.empty() && !capture_output_to_buffer)
|
||||
{
|
||||
if (options.vertex.fixup_clipspace)
|
||||
statement(qual_pos_var_name, ".z = (", qual_pos_var_name, ".z + ", qual_pos_var_name,
|
||||
|
Loading…
x
Reference in New Issue
Block a user