mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
libs/vkd3d-shader: Translate sincos instructions.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ae1f96cc1f
commit
b14bb73c5b
@ -1427,12 +1427,29 @@ static void vkd3d_spirv_build_op_memory_barrier(struct vkd3d_spirv_builder *buil
|
|||||||
SpvOpMemoryBarrier, memory_id, memory_semantics_id);
|
SpvOpMemoryBarrier, memory_id, memory_semantics_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t vkd3d_spirv_build_op_glsl_std450_tr1(struct vkd3d_spirv_builder *builder,
|
||||||
|
enum GLSLstd450 op, uint32_t result_type, uint32_t operand)
|
||||||
|
{
|
||||||
|
uint32_t id = vkd3d_spirv_get_glsl_std450_instr_set(builder);
|
||||||
|
return vkd3d_spirv_build_op_ext_inst(builder, result_type, id, op, &operand, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static uint32_t vkd3d_spirv_build_op_glsl_std450_fabs(struct vkd3d_spirv_builder *builder,
|
static uint32_t vkd3d_spirv_build_op_glsl_std450_fabs(struct vkd3d_spirv_builder *builder,
|
||||||
uint32_t result_type, uint32_t operand)
|
uint32_t result_type, uint32_t operand)
|
||||||
{
|
{
|
||||||
uint32_t glsl_std450_id = vkd3d_spirv_get_glsl_std450_instr_set(builder);
|
return vkd3d_spirv_build_op_glsl_std450_tr1(builder, GLSLstd450FAbs, result_type, operand);
|
||||||
return vkd3d_spirv_build_op_ext_inst(builder, result_type, glsl_std450_id,
|
}
|
||||||
GLSLstd450FAbs, &operand, 1);
|
|
||||||
|
static uint32_t vkd3d_spirv_build_op_glsl_std450_sin(struct vkd3d_spirv_builder *builder,
|
||||||
|
uint32_t result_type, uint32_t operand)
|
||||||
|
{
|
||||||
|
return vkd3d_spirv_build_op_glsl_std450_tr1(builder, GLSLstd450Sin, result_type, operand);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t vkd3d_spirv_build_op_glsl_std450_cos(struct vkd3d_spirv_builder *builder,
|
||||||
|
uint32_t result_type, uint32_t operand)
|
||||||
|
{
|
||||||
|
return vkd3d_spirv_build_op_glsl_std450_tr1(builder, GLSLstd450Cos, result_type, operand);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t vkd3d_spirv_build_op_glsl_std450_nclamp(struct vkd3d_spirv_builder *builder,
|
static uint32_t vkd3d_spirv_build_op_glsl_std450_nclamp(struct vkd3d_spirv_builder *builder,
|
||||||
@ -4284,6 +4301,48 @@ static void vkd3d_dxbc_compiler_emit_rcp(struct vkd3d_dxbc_compiler *compiler,
|
|||||||
vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, val_id);
|
vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, val_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vkd3d_dxbc_compiler_emit_sincos(struct vkd3d_dxbc_compiler *compiler,
|
||||||
|
const struct vkd3d_shader_instruction *instruction)
|
||||||
|
{
|
||||||
|
const struct vkd3d_shader_dst_param *dst_sin = &instruction->dst[0];
|
||||||
|
const struct vkd3d_shader_dst_param *dst_cos = &instruction->dst[1];
|
||||||
|
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
||||||
|
const struct vkd3d_shader_src_param *src = instruction->src;
|
||||||
|
uint32_t type_id, src_id, sin_id = 0, cos_id = 0;
|
||||||
|
unsigned int component_count;
|
||||||
|
|
||||||
|
if (dst_sin->reg.type != VKD3DSPR_NULL)
|
||||||
|
{
|
||||||
|
component_count = vkd3d_write_mask_component_count(dst_sin->write_mask);
|
||||||
|
type_id = vkd3d_spirv_get_type_id(builder,
|
||||||
|
vkd3d_component_type_from_data_type(dst_sin->reg.data_type), component_count);
|
||||||
|
|
||||||
|
src_id = vkd3d_dxbc_compiler_emit_load_src(compiler, src, dst_sin->write_mask);
|
||||||
|
|
||||||
|
sin_id = vkd3d_spirv_build_op_glsl_std450_sin(builder, type_id, src_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dst_cos->reg.type != VKD3DSPR_NULL)
|
||||||
|
{
|
||||||
|
if (dst_sin->reg.type == VKD3DSPR_NULL || dst_cos->write_mask != dst_sin->write_mask)
|
||||||
|
{
|
||||||
|
component_count = vkd3d_write_mask_component_count(dst_cos->write_mask);
|
||||||
|
type_id = vkd3d_spirv_get_type_id(builder,
|
||||||
|
vkd3d_component_type_from_data_type(dst_cos->reg.data_type), component_count);
|
||||||
|
|
||||||
|
src_id = vkd3d_dxbc_compiler_emit_load_src(compiler, src, dst_cos->write_mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
cos_id = vkd3d_spirv_build_op_glsl_std450_cos(builder, type_id, src_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sin_id)
|
||||||
|
vkd3d_dxbc_compiler_emit_store_dst(compiler, dst_sin, sin_id);
|
||||||
|
|
||||||
|
if (cos_id)
|
||||||
|
vkd3d_dxbc_compiler_emit_store_dst(compiler, dst_cos, cos_id);
|
||||||
|
}
|
||||||
|
|
||||||
static void vkd3d_dxbc_compiler_emit_imul(struct vkd3d_dxbc_compiler *compiler,
|
static void vkd3d_dxbc_compiler_emit_imul(struct vkd3d_dxbc_compiler *compiler,
|
||||||
const struct vkd3d_shader_instruction *instruction)
|
const struct vkd3d_shader_instruction *instruction)
|
||||||
{
|
{
|
||||||
@ -5951,6 +6010,9 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler
|
|||||||
case VKD3DSIH_RCP:
|
case VKD3DSIH_RCP:
|
||||||
vkd3d_dxbc_compiler_emit_rcp(compiler, instruction);
|
vkd3d_dxbc_compiler_emit_rcp(compiler, instruction);
|
||||||
break;
|
break;
|
||||||
|
case VKD3DSIH_SINCOS:
|
||||||
|
vkd3d_dxbc_compiler_emit_sincos(compiler, instruction);
|
||||||
|
break;
|
||||||
case VKD3DSIH_IMUL:
|
case VKD3DSIH_IMUL:
|
||||||
vkd3d_dxbc_compiler_emit_imul(compiler, instruction);
|
vkd3d_dxbc_compiler_emit_imul(compiler, instruction);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user