mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader: Deduplicate profile version comparison functions.
This commit is contained in:
parent
dd96fe50e2
commit
2ba8c5771c
Notes:
Alexandre Julliard
2023-11-02 22:49:42 +01:00
Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/432
@ -358,11 +358,6 @@ struct vkd3d_d3d_asm_compiler
|
||||
struct vkd3d_d3d_asm_colours colours;
|
||||
};
|
||||
|
||||
static int shader_ver_ge(const struct vkd3d_shader_version *v, int major, int minor)
|
||||
{
|
||||
return v->major > major || (v->major == major && v->minor >= minor);
|
||||
}
|
||||
|
||||
static int VKD3D_PRINTF_FUNC(2, 3) shader_addline(struct vkd3d_string_buffer *buffer, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
@ -684,7 +679,7 @@ static void shader_dump_decl_usage(struct vkd3d_d3d_asm_compiler *compiler,
|
||||
else
|
||||
{
|
||||
/* Pixel shaders 3.0 don't have usage semantics. */
|
||||
if (!shader_ver_ge(&compiler->shader_version, 3, 0)
|
||||
if (!vkd3d_shader_ver_ge(&compiler->shader_version, 3, 0)
|
||||
&& compiler->shader_version.type == VKD3D_SHADER_TYPE_PIXEL)
|
||||
return;
|
||||
else
|
||||
@ -908,7 +903,7 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
|
||||
case VKD3DSPR_TEXCRDOUT:
|
||||
/* Vertex shaders >= 3.0 use general purpose output registers
|
||||
* (VKD3DSPR_OUTPUT), which can include an address token. */
|
||||
if (shader_ver_ge(&compiler->shader_version, 3, 0))
|
||||
if (vkd3d_shader_ver_ge(&compiler->shader_version, 3, 0))
|
||||
shader_addline(buffer, "o");
|
||||
else
|
||||
shader_addline(buffer, "oT");
|
||||
@ -1174,7 +1169,7 @@ static void shader_dump_register(struct vkd3d_d3d_asm_compiler *compiler, const
|
||||
{
|
||||
if (offset != ~0u)
|
||||
{
|
||||
bool is_sm_5_1 = shader_ver_ge(&compiler->shader_version, 5, 1);
|
||||
bool is_sm_5_1 = vkd3d_shader_ver_ge(&compiler->shader_version, 5, 1);
|
||||
|
||||
if (reg->idx[0].rel_addr || reg->type == VKD3DSPR_IMMCONSTBUFFER
|
||||
|| reg->type == VKD3DSPR_INCONTROLPOINT || (reg->type == VKD3DSPR_INPUT
|
||||
@ -1570,7 +1565,7 @@ static void shader_dump_instruction_flags(struct vkd3d_d3d_asm_compiler *compile
|
||||
break;
|
||||
|
||||
case VKD3DSIH_TEX:
|
||||
if (shader_ver_ge(&compiler->shader_version, 2, 0) && (ins->flags & VKD3DSI_TEXLD_PROJECT))
|
||||
if (vkd3d_shader_ver_ge(&compiler->shader_version, 2, 0) && (ins->flags & VKD3DSI_TEXLD_PROJECT))
|
||||
shader_addline(buffer, "p");
|
||||
break;
|
||||
|
||||
@ -1582,7 +1577,7 @@ static void shader_dump_instruction_flags(struct vkd3d_d3d_asm_compiler *compile
|
||||
|
||||
static void shader_dump_register_space(struct vkd3d_d3d_asm_compiler *compiler, unsigned int register_space)
|
||||
{
|
||||
if (shader_ver_ge(&compiler->shader_version, 5, 1))
|
||||
if (vkd3d_shader_ver_ge(&compiler->shader_version, 5, 1))
|
||||
shader_print_uint_literal(compiler, ", space=", register_space, "");
|
||||
}
|
||||
|
||||
@ -1626,9 +1621,9 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
|
||||
case VKD3DSIH_DCL_CONSTANT_BUFFER:
|
||||
vkd3d_string_buffer_printf(buffer, " ");
|
||||
shader_dump_register(compiler, &ins->declaration.cb.src.reg, true);
|
||||
if (shader_ver_ge(&compiler->shader_version, 6, 0))
|
||||
if (vkd3d_shader_ver_ge(&compiler->shader_version, 6, 0))
|
||||
shader_print_subscript(compiler, ins->declaration.cb.size, NULL);
|
||||
else if (shader_ver_ge(&compiler->shader_version, 5, 1))
|
||||
else if (vkd3d_shader_ver_ge(&compiler->shader_version, 5, 1))
|
||||
shader_print_subscript(compiler, ins->declaration.cb.size / VKD3D_VEC4_SIZE / sizeof(float), NULL);
|
||||
shader_addline(buffer, ", %s",
|
||||
ins->flags & VKD3DSI_INDEXED_DYNAMIC ? "dynamicIndexed" : "immediateIndexed");
|
||||
|
@ -402,16 +402,6 @@ static uint32_t read_u32(const uint32_t **ptr)
|
||||
return *(*ptr)++;
|
||||
}
|
||||
|
||||
static bool shader_ver_ge(const struct vkd3d_shader_version *v, unsigned int major, unsigned int minor)
|
||||
{
|
||||
return v->major > major || (v->major == major && v->minor >= minor);
|
||||
}
|
||||
|
||||
static bool shader_ver_le(const struct vkd3d_shader_version *v, unsigned int major, unsigned int minor)
|
||||
{
|
||||
return v->major < major || (v->major == major && v->minor <= minor);
|
||||
}
|
||||
|
||||
static bool has_relative_address(uint32_t param)
|
||||
{
|
||||
enum vkd3d_sm1_address_mode_type address_mode;
|
||||
@ -434,8 +424,8 @@ static const struct vkd3d_sm1_opcode_info *shader_sm1_get_opcode_info(
|
||||
return NULL;
|
||||
|
||||
if (opcode == info->sm1_opcode
|
||||
&& shader_ver_ge(&sm1->p.shader_version, info->min_version.major, info->min_version.minor)
|
||||
&& (shader_ver_le(&sm1->p.shader_version, info->max_version.major, info->max_version.minor)
|
||||
&& vkd3d_shader_ver_ge(&sm1->p.shader_version, info->min_version.major, info->min_version.minor)
|
||||
&& (vkd3d_shader_ver_le(&sm1->p.shader_version, info->max_version.major, info->max_version.minor)
|
||||
|| !info->max_version.major))
|
||||
return info;
|
||||
}
|
||||
@ -1263,7 +1253,7 @@ static enum vkd3d_result shader_sm1_init(struct vkd3d_shader_sm1_parser *sm1,
|
||||
return VKD3D_ERROR_INVALID_SHADER;
|
||||
}
|
||||
|
||||
if (!shader_ver_le(&version, 3, 0))
|
||||
if (!vkd3d_shader_ver_le(&version, 3, 0))
|
||||
{
|
||||
vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_D3DBC_INVALID_VERSION_TOKEN,
|
||||
"Invalid shader version %u.%u (token 0x%08x).", version.major, version.minor, code[0]);
|
||||
|
@ -1082,6 +1082,16 @@ struct vkd3d_shader_instruction
|
||||
} declaration;
|
||||
};
|
||||
|
||||
static inline bool vkd3d_shader_ver_ge(const struct vkd3d_shader_version *v, unsigned int major, unsigned int minor)
|
||||
{
|
||||
return v->major > major || (v->major == major && v->minor >= minor);
|
||||
}
|
||||
|
||||
static inline bool vkd3d_shader_ver_le(const struct vkd3d_shader_version *v, unsigned int major, unsigned int minor)
|
||||
{
|
||||
return v->major < major || (v->major == major && v->minor <= minor);
|
||||
}
|
||||
|
||||
void vsir_instruction_init(struct vkd3d_shader_instruction *ins, const struct vkd3d_shader_location *location,
|
||||
enum vkd3d_shader_opcode handler_idx);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user