Merge pull request #1400 from KhronosGroup/fix-1399

MSL: Remove the old VertexAttr API.
This commit is contained in:
Hans-Kristian Arntzen 2020-06-22 16:08:53 +02:00 committed by GitHub
commit 9eb615c63b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 42 deletions

View File

@ -1019,11 +1019,11 @@ spvc_result spvc_compiler_msl_add_vertex_attribute(spvc_compiler compiler, const
} }
auto &msl = *static_cast<CompilerMSL *>(compiler->compiler.get()); auto &msl = *static_cast<CompilerMSL *>(compiler->compiler.get());
MSLVertexAttr attr; MSLShaderInput attr;
attr.location = va->location; attr.location = va->location;
attr.format = static_cast<MSLVertexFormat>(va->format); attr.format = static_cast<MSLShaderInputFormat>(va->format);
attr.builtin = static_cast<spv::BuiltIn>(va->builtin); attr.builtin = static_cast<spv::BuiltIn>(va->builtin);
msl.add_msl_vertex_attribute(attr); msl.add_msl_shader_input(attr);
return SPVC_SUCCESS; return SPVC_SUCCESS;
#else #else
(void)va; (void)va;
@ -1163,7 +1163,7 @@ spvc_result spvc_compiler_msl_set_argument_buffer_device_address_space(spvc_comp
#endif #endif
} }
spvc_bool spvc_compiler_msl_is_vertex_attribute_used(spvc_compiler compiler, unsigned location) spvc_bool spvc_compiler_msl_is_shader_input_used(spvc_compiler compiler, unsigned location)
{ {
#if SPIRV_CROSS_C_API_MSL #if SPIRV_CROSS_C_API_MSL
if (compiler->backend != SPVC_BACKEND_MSL) if (compiler->backend != SPVC_BACKEND_MSL)
@ -1173,7 +1173,7 @@ spvc_bool spvc_compiler_msl_is_vertex_attribute_used(spvc_compiler compiler, uns
} }
auto &msl = *static_cast<CompilerMSL *>(compiler->compiler.get()); auto &msl = *static_cast<CompilerMSL *>(compiler->compiler.get());
return msl.is_msl_vertex_attribute_used(location) ? SPVC_TRUE : SPVC_FALSE; return msl.is_msl_shader_input_used(location) ? SPVC_TRUE : SPVC_FALSE;
#else #else
(void)location; (void)location;
compiler->context->report_error("MSL function used on a non-MSL backend."); compiler->context->report_error("MSL function used on a non-MSL backend.");
@ -1181,6 +1181,11 @@ spvc_bool spvc_compiler_msl_is_vertex_attribute_used(spvc_compiler compiler, uns
#endif #endif
} }
spvc_bool spvc_compiler_msl_is_vertex_attribute_used(spvc_compiler compiler, unsigned location)
{
return spvc_compiler_msl_is_shader_input_used(compiler, location);
}
spvc_bool spvc_compiler_msl_is_resource_used(spvc_compiler compiler, SpvExecutionModel model, unsigned set, spvc_bool spvc_compiler_msl_is_resource_used(spvc_compiler compiler, SpvExecutionModel model, unsigned set,
unsigned binding) unsigned binding)
{ {
@ -2282,7 +2287,7 @@ void spvc_msl_vertex_attribute_init(spvc_msl_vertex_attribute *attr)
{ {
#if SPIRV_CROSS_C_API_MSL #if SPIRV_CROSS_C_API_MSL
// Crude, but works. // Crude, but works.
MSLVertexAttr attr_default; MSLShaderInput attr_default;
attr->location = attr_default.location; attr->location = attr_default.location;
attr->format = static_cast<spvc_msl_vertex_format>(attr_default.format); attr->format = static_cast<spvc_msl_vertex_format>(attr_default.format);
attr->builtin = static_cast<SpvBuiltIn>(attr_default.builtin); attr->builtin = static_cast<SpvBuiltIn>(attr_default.builtin);

View File

@ -268,7 +268,9 @@ typedef enum spvc_msl_shader_input_format
/* Deprecated names. */ /* Deprecated names. */
SPVC_MSL_VERTEX_FORMAT_OTHER = SPVC_MSL_SHADER_INPUT_FORMAT_OTHER, SPVC_MSL_VERTEX_FORMAT_OTHER = SPVC_MSL_SHADER_INPUT_FORMAT_OTHER,
SPVC_MSL_VERTEX_FORMAT_UINT8 = SPVC_MSL_SHADER_INPUT_FORMAT_UINT8, SPVC_MSL_VERTEX_FORMAT_UINT8 = SPVC_MSL_SHADER_INPUT_FORMAT_UINT8,
SPVC_MSL_VERTEX_FORMAT_UINT16 = SPVC_MSL_SHADER_INPUT_FORMAT_UINT16 SPVC_MSL_VERTEX_FORMAT_UINT16 = SPVC_MSL_SHADER_INPUT_FORMAT_UINT16,
SPVC_MSL_SHADER_INPUT_FORMAT_INT_MAX = 0x7fffffff
} spvc_msl_shader_input_format, spvc_msl_vertex_format; } spvc_msl_shader_input_format, spvc_msl_vertex_format;
/* Maps to C++ API. Deprecated; use spvc_msl_shader_input. */ /* Maps to C++ API. Deprecated; use spvc_msl_shader_input. */
@ -721,7 +723,11 @@ SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_shader_input(spvc_compiler com
const spvc_msl_shader_input *input); const spvc_msl_shader_input *input);
SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_discrete_descriptor_set(spvc_compiler compiler, unsigned desc_set); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_add_discrete_descriptor_set(spvc_compiler compiler, unsigned desc_set);
SPVC_PUBLIC_API spvc_result spvc_compiler_msl_set_argument_buffer_device_address_space(spvc_compiler compiler, unsigned desc_set, spvc_bool device_address); SPVC_PUBLIC_API spvc_result spvc_compiler_msl_set_argument_buffer_device_address_space(spvc_compiler compiler, unsigned desc_set, spvc_bool device_address);
/* Obsolete, use is_shader_input_used. */
SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_vertex_attribute_used(spvc_compiler compiler, unsigned location); SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_vertex_attribute_used(spvc_compiler compiler, unsigned location);
SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_shader_input_used(spvc_compiler compiler, unsigned location);
SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_resource_used(spvc_compiler compiler, SPVC_PUBLIC_API spvc_bool spvc_compiler_msl_is_resource_used(spvc_compiler compiler,
SpvExecutionModel model, SpvExecutionModel model,
unsigned set, unsigned set,

View File

@ -56,15 +56,6 @@ void CompilerMSL::add_msl_shader_input(const MSLShaderInput &si)
inputs_by_builtin[si.builtin] = si; inputs_by_builtin[si.builtin] = si;
} }
void CompilerMSL::add_msl_vertex_attribute(const MSLVertexAttr &va)
{
MSLShaderInput si;
si.location = va.location;
si.format = va.format;
si.builtin = va.builtin;
add_msl_shader_input(si);
}
void CompilerMSL::add_msl_resource_binding(const MSLResourceBinding &binding) void CompilerMSL::add_msl_resource_binding(const MSLResourceBinding &binding)
{ {
StageSetBinding tuple = { binding.stage, binding.desc_set, binding.binding }; StageSetBinding tuple = { binding.stage, binding.desc_set, binding.binding };
@ -100,11 +91,6 @@ void CompilerMSL::set_argument_buffer_device_address_space(uint32_t desc_set, bo
} }
} }
bool CompilerMSL::is_msl_vertex_attribute_used(uint32_t location)
{
return is_msl_shader_input_used(location);
}
bool CompilerMSL::is_msl_shader_input_used(uint32_t location) bool CompilerMSL::is_msl_shader_input_used(uint32_t location)
{ {
return inputs_in_use.count(location) != 0; return inputs_in_use.count(location) != 0;

View File

@ -43,16 +43,6 @@ enum MSLShaderInputFormat
MSL_SHADER_INPUT_FORMAT_INT_MAX = 0x7fffffff MSL_SHADER_INPUT_FORMAT_INT_MAX = 0x7fffffff
}; };
SPIRV_CROSS_DEPRECATED("Use MSLShaderInputFormat.") typedef MSLShaderInputFormat MSLVertexFormat;
// Defines MSL characteristics of a vertex attribute at a particular location.
// After compilation, it is possible to query whether or not this location was used.
struct SPIRV_CROSS_DEPRECATED("Use MSLShaderInput.") MSLVertexAttr
{
uint32_t location = 0;
MSLShaderInputFormat format = MSL_SHADER_INPUT_FORMAT_OTHER;
spv::BuiltIn builtin = spv::BuiltInMax;
};
// Defines MSL characteristics of an input variable at a particular location. // Defines MSL characteristics of an input variable at a particular location.
// After compilation, it is possible to query whether or not this location was used. // After compilation, it is possible to query whether or not this location was used.
@ -438,13 +428,6 @@ public:
explicit CompilerMSL(const ParsedIR &ir); explicit CompilerMSL(const ParsedIR &ir);
explicit CompilerMSL(ParsedIR &&ir); explicit CompilerMSL(ParsedIR &&ir);
// attr is a vertex attribute binding used to match
// vertex content locations to MSL attributes. If vertex attributes are provided,
// is_msl_vertex_attribute_used() will return true after calling ::compile() if
// the location was used by the MSL code.
SPIRV_CROSS_DEPRECATED("Use add_msl_shader_input().")
void add_msl_vertex_attribute(const MSLVertexAttr &attr);
// input is a shader input description used to fix up shader input variables. // input is a shader input description used to fix up shader input variables.
// If shader inputs are provided, is_msl_shader_input_used() will return true after // If shader inputs are provided, is_msl_shader_input_used() will return true after
// calling ::compile() if the location was used by the MSL code. // calling ::compile() if the location was used by the MSL code.
@ -480,10 +463,6 @@ public:
// constant. Opt-in to this behavior here on a per set basis. // constant. Opt-in to this behavior here on a per set basis.
void set_argument_buffer_device_address_space(uint32_t desc_set, bool device_storage); void set_argument_buffer_device_address_space(uint32_t desc_set, bool device_storage);
// Query after compilation is done. This allows you to check if a location or set/binding combination was used by the shader.
SPIRV_CROSS_DEPRECATED("Use is_msl_shader_input_used().")
bool is_msl_vertex_attribute_used(uint32_t location);
// Query after compilation is done. This allows you to check if an input location was used by the shader. // Query after compilation is done. This allows you to check if an input location was used by the shader.
bool is_msl_shader_input_used(uint32_t location); bool is_msl_shader_input_used(uint32_t location);