mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader: Move SM1 code generation to a separate file.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ae3df158d8
commit
2dedc937a0
@ -172,6 +172,7 @@ libvkd3d_shader_la_SOURCES = \
|
||||
libs/vkd3d-shader/hlsl.c \
|
||||
libs/vkd3d-shader/hlsl.h \
|
||||
libs/vkd3d-shader/hlsl_codegen.c \
|
||||
libs/vkd3d-shader/hlsl_sm1.c \
|
||||
libs/vkd3d-shader/preproc.h \
|
||||
libs/vkd3d-shader/sm4.h \
|
||||
libs/vkd3d-shader/spirv.c \
|
||||
|
@ -1,4 +1,6 @@
|
||||
/*
|
||||
* HLSL utility functions
|
||||
*
|
||||
* Copyright 2012 Matteo Bruni for CodeWeavers
|
||||
* Copyright 2019-2020 Zebediah Figura for CodeWeavers
|
||||
*
|
||||
@ -1449,6 +1451,80 @@ void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function
|
||||
rb_put(&ctx->functions, func->name, &func->entry);
|
||||
}
|
||||
|
||||
unsigned int hlsl_map_swizzle(unsigned int swizzle, unsigned int writemask)
|
||||
{
|
||||
unsigned int i, ret = 0;
|
||||
|
||||
/* Leave replicate swizzles alone; some instructions need them. */
|
||||
if (swizzle == HLSL_SWIZZLE(X, X, X, X)
|
||||
|| swizzle == HLSL_SWIZZLE(Y, Y, Y, Y)
|
||||
|| swizzle == HLSL_SWIZZLE(Z, Z, Z, Z)
|
||||
|| swizzle == HLSL_SWIZZLE(W, W, W, W))
|
||||
return swizzle;
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
if (writemask & (1 << i))
|
||||
{
|
||||
ret |= (swizzle & 3) << (i * 2);
|
||||
swizzle >>= 2;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned int hlsl_swizzle_from_writemask(unsigned int writemask)
|
||||
{
|
||||
static const unsigned int swizzles[16] =
|
||||
{
|
||||
0,
|
||||
HLSL_SWIZZLE(X, X, X, X),
|
||||
HLSL_SWIZZLE(Y, Y, Y, Y),
|
||||
HLSL_SWIZZLE(X, Y, X, X),
|
||||
HLSL_SWIZZLE(Z, Z, Z, Z),
|
||||
HLSL_SWIZZLE(X, Z, X, X),
|
||||
HLSL_SWIZZLE(Y, Z, X, X),
|
||||
HLSL_SWIZZLE(X, Y, Z, X),
|
||||
HLSL_SWIZZLE(W, W, W, W),
|
||||
HLSL_SWIZZLE(X, W, X, X),
|
||||
HLSL_SWIZZLE(Y, W, X, X),
|
||||
HLSL_SWIZZLE(X, Y, W, X),
|
||||
HLSL_SWIZZLE(Z, W, X, X),
|
||||
HLSL_SWIZZLE(X, Z, W, X),
|
||||
HLSL_SWIZZLE(Y, Z, W, X),
|
||||
HLSL_SWIZZLE(X, Y, Z, W),
|
||||
};
|
||||
|
||||
return swizzles[writemask & 0xf];
|
||||
}
|
||||
|
||||
unsigned int hlsl_combine_writemasks(unsigned int first, unsigned int second)
|
||||
{
|
||||
unsigned int ret = 0, i, j = 0;
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
if (first & (1 << i))
|
||||
{
|
||||
if (second & (1 << j++))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned int hlsl_combine_swizzles(unsigned int first, unsigned int second, unsigned int dim)
|
||||
{
|
||||
unsigned int ret = 0, i;
|
||||
for (i = 0; i < dim; ++i)
|
||||
{
|
||||
unsigned int s = (second >> (i * 2)) & 3;
|
||||
ret |= ((first >> (s * 2)) & 3) << (i * 2);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct hlsl_profile_info *get_target_info(const char *target)
|
||||
{
|
||||
unsigned int i;
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "vkd3d_shader_private.h"
|
||||
#include "rbtree.h"
|
||||
#include "vkd3d_d3dx9shader.h"
|
||||
|
||||
/* The general IR structure is inspired by Mesa GLSL hir, even though the code
|
||||
* ends up being quite different in practice. Anyway, here comes the relevant
|
||||
@ -679,6 +680,18 @@ unsigned int hlsl_type_get_sm4_offset(const struct hlsl_type *type, unsigned int
|
||||
bool hlsl_type_is_void(const struct hlsl_type *type);
|
||||
bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2);
|
||||
|
||||
unsigned int hlsl_combine_swizzles(unsigned int first, unsigned int second, unsigned int dim);
|
||||
unsigned int hlsl_combine_writemasks(unsigned int first, unsigned int second);
|
||||
unsigned int hlsl_map_swizzle(unsigned int swizzle, unsigned int writemask);
|
||||
unsigned int hlsl_swizzle_from_writemask(unsigned int writemask);
|
||||
|
||||
struct hlsl_reg hlsl_reg_from_deref(const struct hlsl_deref *deref, const struct hlsl_type *type);
|
||||
|
||||
bool hlsl_sm1_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic,
|
||||
bool output, D3DSHADER_PARAM_REGISTER_TYPE *type, unsigned int *reg);
|
||||
bool hlsl_sm1_usage_from_semantic(const struct hlsl_semantic *semantic, D3DDECLUSAGE *usage, uint32_t *usage_idx);
|
||||
int hlsl_sm1_write(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func, struct vkd3d_shader_code *out);
|
||||
|
||||
int hlsl_lexer_compile(struct hlsl_ctx *ctx, const struct vkd3d_shader_code *hlsl);
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
828
libs/vkd3d-shader/hlsl_sm1.c
Normal file
828
libs/vkd3d-shader/hlsl_sm1.c
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user