mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Unify type minor/major size functions.
Signed-off-by: Francisco Casas <fcasas@codeweavers.com> Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
This commit is contained in:
committed by
Alexandre Julliard
parent
039b69ace9
commit
2dcfc888fb
Notes:
Alexandre Julliard
2022-10-18 00:13:00 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/5
@@ -21,22 +21,6 @@
|
||||
#include "hlsl.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static unsigned int minor_size(const struct hlsl_type *type)
|
||||
{
|
||||
if (type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
|
||||
return type->dimx;
|
||||
else
|
||||
return type->dimy;
|
||||
}
|
||||
|
||||
static unsigned int major_size(const struct hlsl_type *type)
|
||||
{
|
||||
if (type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
|
||||
return type->dimy;
|
||||
else
|
||||
return type->dimx;
|
||||
}
|
||||
|
||||
/* Split uniforms into two variables representing the constant and temp
|
||||
* registers, and copy the former to the latter, so that writes to uniforms
|
||||
* work. */
|
||||
@@ -86,11 +70,11 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
|
||||
|
||||
if (type->type == HLSL_CLASS_MATRIX)
|
||||
{
|
||||
struct hlsl_type *vector_type = hlsl_get_vector_type(ctx, type->base_type, minor_size(type));
|
||||
struct hlsl_type *vector_type = hlsl_get_vector_type(ctx, type->base_type, hlsl_type_minor_size(type));
|
||||
struct hlsl_semantic vector_semantic = *semantic;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < major_size(type); ++i)
|
||||
for (i = 0; i < hlsl_type_major_size(type); ++i)
|
||||
{
|
||||
prepend_input_copy(ctx, instrs, var, vector_type, 4 * i, modifiers, &vector_semantic);
|
||||
++vector_semantic.index;
|
||||
@@ -176,11 +160,11 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
|
||||
|
||||
if (type->type == HLSL_CLASS_MATRIX)
|
||||
{
|
||||
struct hlsl_type *vector_type = hlsl_get_vector_type(ctx, type->base_type, minor_size(type));
|
||||
struct hlsl_type *vector_type = hlsl_get_vector_type(ctx, type->base_type, hlsl_type_minor_size(type));
|
||||
struct hlsl_semantic vector_semantic = *semantic;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < major_size(type); ++i)
|
||||
for (i = 0; i < hlsl_type_major_size(type); ++i)
|
||||
{
|
||||
append_output_copy(ctx, instrs, var, vector_type, 4 * i, modifiers, &vector_semantic);
|
||||
++vector_semantic.index;
|
||||
@@ -915,7 +899,7 @@ static bool split_matrix_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
|
||||
type = rhs->data_type;
|
||||
if (type->type != HLSL_CLASS_MATRIX)
|
||||
return false;
|
||||
element_type = hlsl_get_vector_type(ctx, type->base_type, minor_size(type));
|
||||
element_type = hlsl_get_vector_type(ctx, type->base_type, hlsl_type_minor_size(type));
|
||||
|
||||
if (rhs->type != HLSL_IR_LOAD)
|
||||
{
|
||||
@@ -923,7 +907,7 @@ static bool split_matrix_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < major_size(type); ++i)
|
||||
for (i = 0; i < hlsl_type_major_size(type); ++i)
|
||||
{
|
||||
if (!split_copy(ctx, store, hlsl_ir_load(rhs), 4 * i, element_type))
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user