mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Introduce vkd3d_make_u{16, 32}() helpers.
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
2dedc937a0
commit
ed7cdb3940
@ -26,6 +26,7 @@
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h>
|
||||
@ -145,6 +146,16 @@ static inline bool vkd3d_bound_range(size_t start, size_t count, size_t limit)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint16_t vkd3d_make_u16(uint8_t low, uint8_t high)
|
||||
{
|
||||
return low | ((uint16_t)high << 8);
|
||||
}
|
||||
|
||||
static inline uint32_t vkd3d_make_u32(uint16_t low, uint16_t high)
|
||||
{
|
||||
return low | ((uint32_t)high << 16);
|
||||
}
|
||||
|
||||
static inline int ascii_isupper(int c)
|
||||
{
|
||||
return 'A' <= c && c <= 'Z';
|
||||
|
@ -156,8 +156,7 @@ static void byte_reverse(unsigned char *buf, unsigned longs)
|
||||
|
||||
do
|
||||
{
|
||||
t = ((unsigned)buf[3] << 8 | buf[2]) << 16 |
|
||||
((unsigned)buf[1] << 8 | buf[0]);
|
||||
t = vkd3d_make_u32(vkd3d_make_u16(buf[0], buf[1]), vkd3d_make_u16(buf[2], buf[3]));
|
||||
*(unsigned int *)buf = t;
|
||||
buf += 4;
|
||||
} while (--longs);
|
||||
|
@ -268,9 +268,9 @@ static void write_sm1_type(struct vkd3d_bytecode_buffer *buffer, struct hlsl_typ
|
||||
}
|
||||
}
|
||||
|
||||
type->bytecode_offset = put_u32(buffer, sm1_class(type) | (sm1_base_type(type) << 16));
|
||||
put_u32(buffer, type->dimy | (type->dimx << 16));
|
||||
put_u32(buffer, array_size | (field_count << 16));
|
||||
type->bytecode_offset = put_u32(buffer, vkd3d_make_u32(sm1_class(type), sm1_base_type(type)));
|
||||
put_u32(buffer, vkd3d_make_u32(type->dimy, type->dimx));
|
||||
put_u32(buffer, vkd3d_make_u32(array_size, field_count));
|
||||
put_u32(buffer, fields_offset);
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe
|
||||
if (!var->semantic.name && var->reg.allocated)
|
||||
{
|
||||
put_u32(buffer, 0); /* name */
|
||||
put_u32(buffer, D3DXRS_FLOAT4 | (var->reg.id << 16));
|
||||
put_u32(buffer, vkd3d_make_u32(D3DXRS_FLOAT4, var->reg.id));
|
||||
put_u32(buffer, var->data_type->reg_size / 4);
|
||||
put_u32(buffer, 0); /* type */
|
||||
put_u32(buffer, 0); /* FIXME: default value */
|
||||
@ -381,7 +381,7 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe
|
||||
set_u32(buffer, creator_offset, offset - ctab_start);
|
||||
|
||||
ctab_end = bytecode_get_size(buffer);
|
||||
set_u32(buffer, size_offset, D3DSIO_COMMENT | (((ctab_end - ctab_offset) / sizeof(uint32_t)) << 16));
|
||||
set_u32(buffer, size_offset, vkd3d_make_u32(D3DSIO_COMMENT, (ctab_end - ctab_offset) / sizeof(uint32_t)));
|
||||
}
|
||||
|
||||
static uint32_t sm1_encode_register_type(D3DSHADER_PARAM_REGISTER_TYPE type)
|
||||
|
@ -215,7 +215,7 @@ static enum vkd3d_shader_input_sysval_semantic vkd3d_siv_from_sysval(enum vkd3d_
|
||||
#define VKD3D_SPIRV_VERSION 0x00010000
|
||||
#define VKD3D_SPIRV_GENERATOR_ID 18
|
||||
#define VKD3D_SPIRV_GENERATOR_VERSION 2
|
||||
#define VKD3D_SPIRV_GENERATOR_MAGIC ((VKD3D_SPIRV_GENERATOR_ID << 16) | VKD3D_SPIRV_GENERATOR_VERSION)
|
||||
#define VKD3D_SPIRV_GENERATOR_MAGIC vkd3d_make_u32(VKD3D_SPIRV_GENERATOR_VERSION, VKD3D_SPIRV_GENERATOR_ID)
|
||||
|
||||
struct vkd3d_spirv_stream
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user