Add CompilerMSL::get_is_rasterization_disabled() to manage rasterization status.
This commit is contained in:
parent
5be1d911cc
commit
0d6202e770
@ -276,6 +276,8 @@ string CompilerMSL::compile()
|
|||||||
backend.boolean_mix_support = false;
|
backend.boolean_mix_support = false;
|
||||||
backend.allow_truncated_access_chain = true;
|
backend.allow_truncated_access_chain = true;
|
||||||
|
|
||||||
|
is_rasterization_disabled = msl_options.disable_rasterization;
|
||||||
|
|
||||||
replace_illegal_names();
|
replace_illegal_names();
|
||||||
|
|
||||||
struct_member_padding.clear();
|
struct_member_padding.clear();
|
||||||
@ -300,9 +302,8 @@ string CompilerMSL::compile()
|
|||||||
stage_uniforms_var_id = add_interface_block(StorageClassUniformConstant);
|
stage_uniforms_var_id = add_interface_block(StorageClassUniformConstant);
|
||||||
|
|
||||||
// Metal vertex functions that define no output must disable rasterization and return void.
|
// Metal vertex functions that define no output must disable rasterization and return void.
|
||||||
// Provide feedback to calling API to allow runtime to disable pipeline rasterization.
|
if (!stage_out_var_id)
|
||||||
if (!stage_out_var_id && (get_entry_point().model == ExecutionModelVertex))
|
is_rasterization_disabled = true;
|
||||||
msl_options.disable_rasterization = true;
|
|
||||||
|
|
||||||
// Convert the use of global variables to recursively-passed function parameters
|
// Convert the use of global variables to recursively-passed function parameters
|
||||||
localize_global_variables();
|
localize_global_variables();
|
||||||
@ -383,9 +384,8 @@ void CompilerMSL::preprocess_op_codes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Metal vertex functions that write to textures must disable rasterization and return void.
|
// Metal vertex functions that write to textures must disable rasterization and return void.
|
||||||
// Provide feedback to calling API to allow runtime to disable pipeline rasterization.
|
if (preproc.uses_image_write)
|
||||||
if (preproc.uses_image_write && get_entry_point().model == ExecutionModelVertex)
|
is_rasterization_disabled = true;
|
||||||
msl_options.disable_rasterization = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the Private and Workgroup global variables to the entry function.
|
// Move the Private and Workgroup global variables to the entry function.
|
||||||
@ -703,8 +703,7 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage)
|
|||||||
// If the entry point should return the output struct, set the entry function
|
// If the entry point should return the output struct, set the entry function
|
||||||
// to return the output interface struct, otherwise to return nothing.
|
// to return the output interface struct, otherwise to return nothing.
|
||||||
// Indicate the output var requires early initialization.
|
// Indicate the output var requires early initialization.
|
||||||
bool ep_should_return_output =
|
bool ep_should_return_output = !get_is_rasterization_disabled();
|
||||||
!((get_entry_point().model == ExecutionModelVertex) && msl_options.disable_rasterization);
|
|
||||||
uint32_t rtn_id = ep_should_return_output ? ib_var_id : 0;
|
uint32_t rtn_id = ep_should_return_output ? ib_var_id : 0;
|
||||||
auto &entry_func = get<SPIRFunction>(entry_point);
|
auto &entry_func = get<SPIRFunction>(entry_point);
|
||||||
entry_func.add_local_variable(ib_var_id);
|
entry_func.add_local_variable(ib_var_id);
|
||||||
@ -3098,8 +3097,7 @@ string CompilerMSL::func_type_decl(SPIRType &type)
|
|||||||
return return_type;
|
return return_type;
|
||||||
|
|
||||||
// If an outgoing interface block has been defined, and it should be returned, override the entry point return type
|
// If an outgoing interface block has been defined, and it should be returned, override the entry point return type
|
||||||
bool ep_should_return_output =
|
bool ep_should_return_output = !get_is_rasterization_disabled();
|
||||||
!((get_entry_point().model == ExecutionModelVertex) && msl_options.disable_rasterization);
|
|
||||||
if (stage_out_var_id && ep_should_return_output)
|
if (stage_out_var_id && ep_should_return_output)
|
||||||
{
|
{
|
||||||
auto &so_var = get<SPIRVariable>(stage_out_var_id);
|
auto &so_var = get<SPIRVariable>(stage_out_var_id);
|
||||||
|
@ -153,7 +153,7 @@ public:
|
|||||||
uint32_t msl_version = make_msl_version(1, 2);
|
uint32_t msl_version = make_msl_version(1, 2);
|
||||||
uint32_t texel_buffer_texture_width = 4096; // Width of 2D Metal textures used as 1D texel buffers
|
uint32_t texel_buffer_texture_width = 4096; // Width of 2D Metal textures used as 1D texel buffers
|
||||||
bool enable_point_size_builtin = true;
|
bool enable_point_size_builtin = true;
|
||||||
bool disable_rasterization = false; // Used as both input and output
|
bool disable_rasterization = false;
|
||||||
bool resolve_specialized_array_lengths = true;
|
bool resolve_specialized_array_lengths = true;
|
||||||
|
|
||||||
bool is_ios()
|
bool is_ios()
|
||||||
@ -204,6 +204,13 @@ public:
|
|||||||
msl_options = opts;
|
msl_options = opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Provide feedback to calling API to allow runtime to disable pipeline
|
||||||
|
// rasterization if vertex shader requires rasterization to be disabled.
|
||||||
|
bool get_is_rasterization_disabled() const
|
||||||
|
{
|
||||||
|
return is_rasterization_disabled && (get_entry_point().model == spv::ExecutionModelVertex);
|
||||||
|
}
|
||||||
|
|
||||||
// An enum of SPIR-V functions that are implemented in additional
|
// An enum of SPIR-V functions that are implemented in additional
|
||||||
// source code that is added to the shader if necessary.
|
// source code that is added to the shader if necessary.
|
||||||
enum SPVFuncImpl
|
enum SPVFuncImpl
|
||||||
@ -376,6 +383,7 @@ protected:
|
|||||||
uint32_t stage_uniforms_var_id = 0;
|
uint32_t stage_uniforms_var_id = 0;
|
||||||
bool needs_vertex_idx_arg = false;
|
bool needs_vertex_idx_arg = false;
|
||||||
bool needs_instance_idx_arg = false;
|
bool needs_instance_idx_arg = false;
|
||||||
|
bool is_rasterization_disabled = false;
|
||||||
std::string qual_pos_var_name;
|
std::string qual_pos_var_name;
|
||||||
std::string stage_in_var_name = "in";
|
std::string stage_in_var_name = "in";
|
||||||
std::string stage_out_var_name = "out";
|
std::string stage_out_var_name = "out";
|
||||||
|
Loading…
Reference in New Issue
Block a user