Compare commits
11 Commits
cb06c50eba
...
e4d6832d31
Author | SHA1 | Date | |
---|---|---|---|
e4d6832d31 | |||
|
66363ac7e8 | ||
|
b7dbf7a379 | ||
|
68d401117c | ||
|
1de3f8c1f2 | ||
|
d17a2d6940 | ||
|
1297499703 | ||
|
ae75fccf71 | ||
|
c1bf9099b9 | ||
|
abed74fb9b | ||
|
b37f1598ad |
@ -0,0 +1,25 @@
|
||||
static float4 gl_Position;
|
||||
static int gl_BaseInstanceARB;
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
uint gl_BaseInstanceARB : SV_StartInstanceLocation;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
float4 gl_Position : SV_Position;
|
||||
};
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
gl_Position = float(gl_BaseInstanceARB).xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_BaseInstanceARB = stage_input.gl_BaseInstanceARB;
|
||||
vert_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.gl_Position = gl_Position;
|
||||
return stage_output;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
static float4 gl_Position;
|
||||
static int gl_BaseVertexARB;
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
uint gl_BaseVertexARB : SV_StartVertexLocation;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
float4 gl_Position : SV_Position;
|
||||
};
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
gl_Position = float(gl_BaseVertexARB).xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_BaseVertexARB = stage_input.gl_BaseVertexARB;
|
||||
vert_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.gl_Position = gl_Position;
|
||||
return stage_output;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
static float4 gl_Position;
|
||||
static int gl_InstanceIndex;
|
||||
static int gl_BaseInstanceARB;
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
uint gl_InstanceIndex : SV_InstanceID;
|
||||
uint gl_BaseInstanceARB : SV_StartInstanceLocation;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
float4 gl_Position : SV_Position;
|
||||
};
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
gl_Position = float(gl_InstanceIndex).xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_InstanceIndex = int(stage_input.gl_InstanceIndex + stage_input.gl_BaseInstanceARB);
|
||||
gl_BaseInstanceARB = stage_input.gl_BaseInstanceARB;
|
||||
vert_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.gl_Position = gl_Position;
|
||||
return stage_output;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
static float4 gl_Position;
|
||||
static int gl_VertexIndex;
|
||||
static int gl_BaseVertexARB;
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
uint gl_VertexIndex : SV_VertexID;
|
||||
uint gl_BaseVertexARB : SV_StartVertexLocation;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
float4 gl_Position : SV_Position;
|
||||
};
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
gl_Position = float(gl_VertexIndex).xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
gl_VertexIndex = int(stage_input.gl_VertexIndex + stage_input.gl_BaseVertexARB);
|
||||
gl_BaseVertexARB = stage_input.gl_BaseVertexARB;
|
||||
vert_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.gl_Position = gl_Position;
|
||||
return stage_output;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
#version 450
|
||||
#extension GL_ARB_shader_draw_parameters : require
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(gl_BaseInstanceARB);
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
#version 450
|
||||
#extension GL_ARB_shader_draw_parameters : require
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(gl_BaseVertexARB);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
#version 450
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(gl_InstanceIndex);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
#version 450
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(gl_VertexIndex);
|
||||
}
|
@ -783,6 +783,8 @@ uint32_t ParsedIR::get_member_decoration(TypeID id, uint32_t index, Decoration d
|
||||
return dec.stream;
|
||||
case DecorationSpecId:
|
||||
return dec.spec_id;
|
||||
case DecorationMatrixStride:
|
||||
return dec.matrix_stride;
|
||||
case DecorationIndex:
|
||||
return dec.index;
|
||||
default:
|
||||
|
@ -783,6 +783,9 @@ void CompilerHLSL::emit_builtin_inputs_in_struct()
|
||||
break;
|
||||
|
||||
case BuiltInPrimitiveId:
|
||||
if (legacy)
|
||||
SPIRV_CROSS_THROW("Primitive ID not supported in SM 3.0 or lower.");
|
||||
|
||||
type = "uint";
|
||||
semantic = "SV_PrimitiveID";
|
||||
break;
|
||||
@ -830,8 +833,16 @@ void CompilerHLSL::emit_builtin_inputs_in_struct()
|
||||
break;
|
||||
|
||||
case BuiltInFrontFacing:
|
||||
type = "bool";
|
||||
semantic = "SV_IsFrontFace";
|
||||
if (legacy)
|
||||
{
|
||||
type = "float";
|
||||
semantic = "VFACE";
|
||||
}
|
||||
else
|
||||
{
|
||||
type = "bool";
|
||||
semantic = "SV_IsFrontFace";
|
||||
}
|
||||
break;
|
||||
|
||||
case BuiltInViewIndex:
|
||||
@ -849,11 +860,25 @@ void CompilerHLSL::emit_builtin_inputs_in_struct()
|
||||
case BuiltInSubgroupLeMask:
|
||||
case BuiltInSubgroupGtMask:
|
||||
case BuiltInSubgroupGeMask:
|
||||
case BuiltInBaseVertex:
|
||||
case BuiltInBaseInstance:
|
||||
// Handled specially.
|
||||
break;
|
||||
|
||||
case BuiltInBaseVertex:
|
||||
if (hlsl_options.shader_model >= 68)
|
||||
{
|
||||
type = "uint";
|
||||
semantic = "SV_StartVertexLocation";
|
||||
}
|
||||
break;
|
||||
|
||||
case BuiltInBaseInstance:
|
||||
if (hlsl_options.shader_model >= 68)
|
||||
{
|
||||
type = "uint";
|
||||
semantic = "SV_StartInstanceLocation";
|
||||
}
|
||||
break;
|
||||
|
||||
case BuiltInHelperInvocation:
|
||||
if (hlsl_options.shader_model < 50 || get_entry_point().model != ExecutionModelFragment)
|
||||
SPIRV_CROSS_THROW("Helper Invocation input is only supported in PS 5.0 or higher.");
|
||||
@ -1231,7 +1256,7 @@ void CompilerHLSL::emit_builtin_variables()
|
||||
case BuiltInVertexIndex:
|
||||
case BuiltInInstanceIndex:
|
||||
type = "int";
|
||||
if (hlsl_options.support_nonzero_base_vertex_base_instance)
|
||||
if (hlsl_options.support_nonzero_base_vertex_base_instance || hlsl_options.shader_model >= 68)
|
||||
base_vertex_info.used = true;
|
||||
break;
|
||||
|
||||
@ -1353,7 +1378,7 @@ void CompilerHLSL::emit_builtin_variables()
|
||||
}
|
||||
});
|
||||
|
||||
if (base_vertex_info.used)
|
||||
if (base_vertex_info.used && hlsl_options.shader_model < 68)
|
||||
{
|
||||
string binding_info;
|
||||
if (base_vertex_info.explicit_binding)
|
||||
@ -3132,27 +3157,57 @@ void CompilerHLSL::emit_hlsl_entry_point()
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case BuiltInFrontFacing:
|
||||
{
|
||||
if (legacy)
|
||||
statement(builtin, " = bool(stage_input.", builtin, " > 0.0 ? true : false);");
|
||||
else
|
||||
{
|
||||
statement(builtin, " = int(stage_input.", builtin, ");");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case BuiltInVertexId:
|
||||
case BuiltInVertexIndex:
|
||||
case BuiltInInstanceIndex:
|
||||
// D3D semantics are uint, but shader wants int.
|
||||
if (hlsl_options.support_nonzero_base_vertex_base_instance)
|
||||
if (hlsl_options.support_nonzero_base_vertex_base_instance || hlsl_options.shader_model >= 68)
|
||||
{
|
||||
if (static_cast<BuiltIn>(i) == BuiltInInstanceIndex)
|
||||
statement(builtin, " = int(stage_input.", builtin, ") + SPIRV_Cross_BaseInstance;");
|
||||
if (hlsl_options.shader_model >= 68)
|
||||
{
|
||||
if (static_cast<BuiltIn>(i) == BuiltInInstanceIndex)
|
||||
statement(builtin, " = int(stage_input.", builtin, " + stage_input.gl_BaseInstanceARB);");
|
||||
else
|
||||
statement(builtin, " = int(stage_input.", builtin, " + stage_input.gl_BaseVertexARB);");
|
||||
}
|
||||
else
|
||||
statement(builtin, " = int(stage_input.", builtin, ") + SPIRV_Cross_BaseVertex;");
|
||||
{
|
||||
if (static_cast<BuiltIn>(i) == BuiltInInstanceIndex)
|
||||
statement(builtin, " = int(stage_input.", builtin, ") + SPIRV_Cross_BaseInstance;");
|
||||
else
|
||||
statement(builtin, " = int(stage_input.", builtin, ") + SPIRV_Cross_BaseVertex;");
|
||||
}
|
||||
}
|
||||
else
|
||||
statement(builtin, " = int(stage_input.", builtin, ");");
|
||||
break;
|
||||
|
||||
case BuiltInBaseVertex:
|
||||
statement(builtin, " = SPIRV_Cross_BaseVertex;");
|
||||
if (hlsl_options.shader_model >= 68)
|
||||
statement(builtin, " = stage_input.gl_BaseVertexARB;");
|
||||
else
|
||||
statement(builtin, " = SPIRV_Cross_BaseVertex;");
|
||||
break;
|
||||
|
||||
case BuiltInBaseInstance:
|
||||
statement(builtin, " = SPIRV_Cross_BaseInstance;");
|
||||
if (hlsl_options.shader_model >= 68)
|
||||
statement(builtin, " = stage_input.gl_BaseInstanceARB;");
|
||||
else
|
||||
statement(builtin, " = SPIRV_Cross_BaseInstance;");
|
||||
break;
|
||||
|
||||
case BuiltInInstanceId:
|
||||
@ -6714,6 +6769,15 @@ string CompilerHLSL::compile()
|
||||
if (need_subpass_input)
|
||||
active_input_builtins.set(BuiltInFragCoord);
|
||||
|
||||
// Need to offset by BaseVertex/BaseInstance in SM 6.8+.
|
||||
if (hlsl_options.shader_model >= 68)
|
||||
{
|
||||
if (active_input_builtins.get(BuiltInVertexIndex))
|
||||
active_input_builtins.set(BuiltInBaseVertex);
|
||||
if (active_input_builtins.get(BuiltInInstanceIndex))
|
||||
active_input_builtins.set(BuiltInBaseInstance);
|
||||
}
|
||||
|
||||
uint32_t pass_count = 0;
|
||||
do
|
||||
{
|
||||
|
@ -9262,8 +9262,8 @@ void CompilerMSL::emit_instruction(const Instruction &instruction)
|
||||
auto sampler_expr = to_sampler_expression(image_id);
|
||||
auto *combined = maybe_get<SPIRCombinedImageSampler>(image_id);
|
||||
auto image_expr = combined ? to_expression(combined->image) : to_expression(image_id);
|
||||
const SPIRType& image_type = expression_type(image_id);
|
||||
const SPIRType& coord_type = expression_type(coord_id);
|
||||
const SPIRType &image_type = expression_type(image_id);
|
||||
const SPIRType &coord_type = expression_type(coord_id);
|
||||
|
||||
switch (image_type.image.dim)
|
||||
{
|
||||
@ -14085,7 +14085,7 @@ void CompilerMSL::fix_up_shader_inputs_outputs()
|
||||
statement("constant uint", is_array_type ? "* " : "& ", to_buffer_size_expression(var_id),
|
||||
is_array_type ? " = &" : " = ", to_name(argument_buffer_ids[desc_set]),
|
||||
".spvBufferSizeConstants", "[",
|
||||
convert_to_string(get_metal_resource_index(var, SPIRType::Image)), "];");
|
||||
convert_to_string(get_metal_resource_index(var, SPIRType::UInt)), "];");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -18189,6 +18189,13 @@ void CompilerMSL::emit_argument_buffer_aliased_descriptor(const SPIRVariable &al
|
||||
}
|
||||
else
|
||||
{
|
||||
// This alias may have already been used to emit an entry point declaration. If there is a mismatch, we need a recompile.
|
||||
// Moving this code to be run earlier will also conflict,
|
||||
// because we need the qualified alias for the base resource,
|
||||
// so forcing recompile until things sync up is the least invasive method for now.
|
||||
if (ir.meta[aliased_var.self].decoration.qualified_alias != name)
|
||||
force_recompile();
|
||||
|
||||
// This will get wrapped in a separate temporary when a spvDescriptorArray wrapper is emitted.
|
||||
set_qualified_name(aliased_var.self, name);
|
||||
}
|
||||
|
@ -494,6 +494,8 @@ def shader_to_sm(shader):
|
||||
return '62'
|
||||
elif '.sm60.' in shader:
|
||||
return '60'
|
||||
elif '.sm68.' in shader:
|
||||
return '68'
|
||||
elif '.sm51.' in shader:
|
||||
return '51'
|
||||
elif '.sm30.' in shader:
|
||||
|
Loading…
Reference in New Issue
Block a user