Commit 891e2f73 authored by Alexandre Julliard's avatar Alexandre Julliard

vkd3d: Import upstream release 1.6.

parent 7eef69e1
......@@ -3,6 +3,7 @@ Andrew Eikum
Andrey Gusev
Atharva Nimbalkar
Biswapriyo Nath
Brendan Shanks
Chip Davis
Conor McCarthy
David Gow
......
#define PACKAGE_NAME "vkd3d"
#define PACKAGE_STRING "vkd3d 1.5"
#define PACKAGE_VERSION "1.5"
#define PACKAGE_STRING "vkd3d 1.6"
#define PACKAGE_VERSION "1.6"
#define PATH_MAX 1024
#define SONAME_LIBVULKAN "vulkan-1.dll"
......@@ -54,14 +54,32 @@ static inline size_t align(size_t addr, size_t alignment)
#ifdef __GNUC__
# define VKD3D_NORETURN __attribute__((noreturn))
# define VKD3D_PRINTF_FUNC(fmt, args) __attribute__((format(printf, fmt, args)))
# ifdef __MINGW_PRINTF_FORMAT
# define VKD3D_PRINTF_FUNC(fmt, args) __attribute__((format(__MINGW_PRINTF_FORMAT, fmt, args)))
# else
# define VKD3D_PRINTF_FUNC(fmt, args) __attribute__((format(printf, fmt, args)))
# endif
# define VKD3D_UNUSED __attribute__((unused))
# define VKD3D_UNREACHABLE __builtin_unreachable()
#else
# define VKD3D_NORETURN
# define VKD3D_PRINTF_FUNC(fmt, args)
# define VKD3D_UNUSED
# define VKD3D_UNREACHABLE (void)0
#endif /* __GNUC__ */
VKD3D_NORETURN static inline void vkd3d_unreachable_(const char *filename, unsigned int line)
{
fprintf(stderr, "%s:%u: Aborting, reached unreachable code.\n", filename, line);
abort();
}
#ifdef NDEBUG
#define vkd3d_unreachable() VKD3D_UNREACHABLE
#else
#define vkd3d_unreachable() vkd3d_unreachable_(__FILE__, __LINE__)
#endif
static inline unsigned int vkd3d_popcount(unsigned int v)
{
#ifdef _MSC_VER
......
......@@ -115,5 +115,6 @@ struct vkd3d_debug_option
bool vkd3d_debug_list_has_member(const char *string, const char *member);
uint64_t vkd3d_parse_debug_options(const char *string,
const struct vkd3d_debug_option *options, unsigned int option_count);
void vkd3d_set_thread_name(const char *name);
#endif /* __VKD3D_DEBUG_H */
#define VKD3D_VCS_ID " (git 56b2f56b8631)"
#define VKD3D_VCS_ID " (git 1eaf73147cd3)"
......@@ -62,6 +62,7 @@ enum vkd3d_api_version
VKD3D_API_VERSION_1_3,
VKD3D_API_VERSION_1_4,
VKD3D_API_VERSION_1_5,
VKD3D_API_VERSION_1_6,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_API_VERSION),
};
......
......@@ -47,6 +47,7 @@ enum vkd3d_shader_api_version
VKD3D_SHADER_API_VERSION_1_3,
VKD3D_SHADER_API_VERSION_1_4,
VKD3D_SHADER_API_VERSION_1_5,
VKD3D_SHADER_API_VERSION_1_6,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_API_VERSION),
};
......@@ -1263,6 +1264,9 @@ enum vkd3d_shader_descriptor_info_flag
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ = 0x00000002,
/** The descriptor is a comparison sampler. */
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE = 0x00000004,
/** The descriptor is a UAV resource, on which the shader performs
* atomic ops. \since 1.6 */
VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_ATOMICS = 0x00000008,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_DESCRIPTOR_INFO_FLAG),
};
......@@ -1552,6 +1556,12 @@ VKD3D_SHADER_API const enum vkd3d_shader_target_type *vkd3d_shader_get_supported
*
* This version of vkd3d-shader supports the following transformations:
* - VKD3D_SHADER_SOURCE_DXBC_TPF to VKD3D_SHADER_TARGET_SPIRV_BINARY
* - VKD3D_SHADER_SOURCE_DXBC_TPF to VKD3D_SHADER_TARGET_SPIRV_TEXT
* (if vkd3d was compiled with SPIRV-Tools)
* - VKD3D_SHADER_SOURCE_DXBC_TPF to VKD3D_SHADER_TARGET_D3D_ASM
* - VKD3D_SHADER_SOURCE_D3D_BYTECODE to VKD3D_SHADER_TARGET_D3D_ASM
* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_DXBC_TPF
* - VKD3D_SHADER_SOURCE_HLSL to VKD3D_SHADER_TARGET_D3D_BYTECODE
*
* Supported transformations can also be detected at runtime with the functions
* vkd3d_shader_get_supported_source_types() and
......@@ -1560,9 +1570,11 @@ VKD3D_SHADER_API const enum vkd3d_shader_target_type *vkd3d_shader_get_supported
* Depending on the source and target types, this function may support the
* following chained structures:
* - vkd3d_shader_interface_info
* - vkd3d_shader_scan_descriptor_info
* - vkd3d_shader_spirv_domain_shader_target_info
* - vkd3d_shader_spirv_target_info
* - vkd3d_shader_transform_feedback_info
* - vkd3d_shader_hlsl_source_info
*
* \param compile_info A chained structure containing compilation parameters.
*
......
......@@ -16,6 +16,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifdef _WIN32
# define _WIN32_WINNT 0x0600 /* For InitOnceExecuteOnce(). */
#endif
#include "vkd3d_debug.h"
#include <assert.h>
......@@ -27,6 +31,11 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#endif
#include "vkd3d_memory.h"
#define VKD3D_DEBUG_BUFFER_COUNT 64
#define VKD3D_DEBUG_BUFFER_SIZE 512
......@@ -96,7 +105,7 @@ void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const ch
assert(level < ARRAY_SIZE(debug_level_names));
vkd3d_dbg_output("%s:%s ", debug_level_names[level], function);
vkd3d_dbg_output("vkd3d:%s:%s ", debug_level_names[level], function);
va_start(args, fmt);
vkd3d_dbg_voutput(fmt, args);
va_end(args);
......@@ -369,3 +378,49 @@ uint64_t vkd3d_parse_debug_options(const char *string,
return flags;
}
#ifdef _WIN32
static HRESULT (WINAPI *pfn_SetThreadDescription)(HANDLE, const WCHAR *);
static BOOL WINAPI resolve_SetThreadDescription(INIT_ONCE *once, void *param, void **context)
{
HMODULE kernelbase;
if (!(kernelbase = LoadLibraryA("kernelbase.dll")))
return TRUE;
if (!(pfn_SetThreadDescription = (void *)GetProcAddress(kernelbase, "SetThreadDescription")))
FreeLibrary(kernelbase);
return TRUE;
}
#endif
void vkd3d_set_thread_name(const char *name)
{
#ifdef _WIN32
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
WCHAR *wname;
int ret;
InitOnceExecuteOnce(&init_once, resolve_SetThreadDescription, NULL, NULL);
if (!pfn_SetThreadDescription)
return;
if ((ret = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0)) <= 0)
return;
if (!(wname = vkd3d_malloc(ret * sizeof(*wname))))
return;
if ((ret = MultiByteToWideChar(CP_UTF8, 0, name, -1, wname, ret)) > 0)
pfn_SetThreadDescription(GetCurrentThread(), wname);
vkd3d_free(wname);
#elif defined(HAVE_PTHREAD_SETNAME_NP_2)
pthread_setname_np(pthread_self(), name);
#elif defined(HAVE_PTHREAD_SETNAME_NP_1)
pthread_setname_np(name);
#endif
}
......@@ -26,7 +26,7 @@ HRESULT hresult_from_vkd3d_result(int vkd3d_result)
case VKD3D_OK:
return S_OK;
case VKD3D_ERROR_INVALID_SHADER:
WARN("Invalid shader bytecode.\n");
WARN("Invalid shader.\n");
/* fall-through */
case VKD3D_ERROR:
return E_FAIL;
......
......@@ -21,6 +21,11 @@
#include "vkd3d_shader_private.h"
#include "sm4.h"
#define SM4_MAX_SRC_COUNT 6
#define SM4_MAX_DST_COUNT 2
STATIC_ASSERT(SM4_MAX_SRC_COUNT <= SPIRV_MAX_SRC_COUNT);
void dxbc_writer_init(struct dxbc_writer *dxbc)
{
memset(dxbc, 0, sizeof(*dxbc));
......@@ -91,8 +96,8 @@ struct vkd3d_shader_sm4_parser
unsigned int output_map[MAX_REG_OUTPUT];
struct vkd3d_shader_src_param src_param[6];
struct vkd3d_shader_dst_param dst_param[2];
struct vkd3d_shader_src_param src_param[SM4_MAX_SRC_COUNT];
struct vkd3d_shader_dst_param dst_param[SM4_MAX_DST_COUNT];
struct list src_free;
struct list src;
struct vkd3d_shader_immediate_constant_buffer icb;
......@@ -104,8 +109,8 @@ struct vkd3d_sm4_opcode_info
{
enum vkd3d_sm4_opcode opcode;
enum vkd3d_shader_opcode handler_idx;
const char *dst_info;
const char *src_info;
char dst_info[SM4_MAX_DST_COUNT];
char src_info[SM4_MAX_SRC_COUNT];
void (*read_opcode_func)(struct vkd3d_shader_instruction *ins, uint32_t opcode, uint32_t opcode_token,
const uint32_t *tokens, unsigned int token_count, struct vkd3d_shader_sm4_parser *priv);
};
......@@ -1514,9 +1519,9 @@ static void shader_sm4_read_instruction(struct vkd3d_shader_parser *parser, stru
ins->raw = false;
ins->structured = false;
ins->predicate = NULL;
ins->dst_count = strlen(opcode_info->dst_info);
ins->dst_count = strnlen(opcode_info->dst_info, SM4_MAX_DST_COUNT);
ins->dst = sm4->dst_param;
ins->src_count = strlen(opcode_info->src_info);
ins->src_count = strnlen(opcode_info->src_info, SM4_MAX_SRC_COUNT);
ins->src = sm4->src_param;
assert(ins->dst_count <= ARRAY_SIZE(sm4->dst_param));
assert(ins->src_count <= ARRAY_SIZE(sm4->src_param));
......
......@@ -85,6 +85,7 @@ enum hlsl_base_type
HLSL_TYPE_LAST_SCALAR = HLSL_TYPE_BOOL,
HLSL_TYPE_SAMPLER,
HLSL_TYPE_TEXTURE,
HLSL_TYPE_UAV,
HLSL_TYPE_PIXELSHADER,
HLSL_TYPE_VERTEXSHADER,
HLSL_TYPE_STRING,
......@@ -177,6 +178,7 @@ enum hlsl_ir_node_type
HLSL_IR_LOOP,
HLSL_IR_JUMP,
HLSL_IR_RESOURCE_LOAD,
HLSL_IR_RESOURCE_STORE,
HLSL_IR_STORE,
HLSL_IR_SWIZZLE,
};
......@@ -210,6 +212,15 @@ struct hlsl_src
struct list entry;
};
struct hlsl_attribute
{
const char *name;
struct list instrs;
struct vkd3d_shader_location loc;
unsigned int args_count;
struct hlsl_src args[];
};
#define HLSL_STORAGE_EXTERN 0x00000001
#define HLSL_STORAGE_NOINTERPOLATION 0x00000002
#define HLSL_MODIFIER_PRECISE 0x00000004
......@@ -277,6 +288,8 @@ struct hlsl_ir_function_decl
struct list *parameters;
struct hlsl_block body;
bool has_body;
unsigned int attr_count;
const struct hlsl_attribute *const *attrs;
};
struct hlsl_ir_if
......@@ -312,6 +325,7 @@ enum hlsl_ir_expr_op
HLSL_OP1_NEG,
HLSL_OP1_NRM,
HLSL_OP1_RCP,
HLSL_OP1_REINTERPRET,
HLSL_OP1_ROUND,
HLSL_OP1_RSQ,
HLSL_OP1_SAT,
......@@ -408,6 +422,13 @@ struct hlsl_ir_resource_load
struct hlsl_src coords, lod, texel_offset;
};
struct hlsl_ir_resource_store
{
struct hlsl_ir_node node;
struct hlsl_deref resource;
struct hlsl_src coords, value;
};
struct hlsl_ir_store
{
struct hlsl_ir_node node;
......@@ -516,7 +537,10 @@ struct hlsl_ctx
} constant_defs;
uint32_t temp_count;
uint32_t thread_count[3];
uint32_t in_state_block : 1;
uint32_t found_numthreads : 1;
};
enum hlsl_error_level
......@@ -526,6 +550,14 @@ enum hlsl_error_level
HLSL_LEVEL_NOTE,
};
struct hlsl_resource_load_params
{
struct hlsl_type *format;
enum hlsl_resource_load_type type;
struct hlsl_deref resource, sampler;
struct hlsl_ir_node *coords, *lod, *texel_offset;
};
static inline struct hlsl_ir_constant *hlsl_ir_constant(const struct hlsl_ir_node *node)
{
assert(node->type == HLSL_IR_CONSTANT);
......@@ -568,6 +600,12 @@ static inline struct hlsl_ir_resource_load *hlsl_ir_resource_load(const struct h
return CONTAINING_RECORD(node, struct hlsl_ir_resource_load, node);
}
static inline struct hlsl_ir_resource_store *hlsl_ir_resource_store(const struct hlsl_ir_node *node)
{
assert(node->type == HLSL_IR_RESOURCE_STORE);
return CONTAINING_RECORD(node, struct hlsl_ir_resource_store, node);
}
static inline struct hlsl_ir_store *hlsl_ir_store(const struct hlsl_ir_node *node)
{
assert(node->type == HLSL_IR_STORE);
......@@ -580,16 +618,6 @@ static inline struct hlsl_ir_swizzle *hlsl_ir_swizzle(const struct hlsl_ir_node
return CONTAINING_RECORD(node, struct hlsl_ir_swizzle, node);
}
static inline void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type type,
struct hlsl_type *data_type, struct vkd3d_shader_location loc)
{
memset(node, 0, sizeof(*node));
node->type = type;
node->data_type = data_type;
node->loc = loc;
list_init(&node->uses);
}
static inline void hlsl_src_from_node(struct hlsl_src *src, struct hlsl_ir_node *node)
{
src->node = node;
......@@ -701,8 +729,7 @@ static inline unsigned int hlsl_sampler_dim_count(enum hlsl_sampler_dim dim)
case HLSL_SAMPLER_DIM_CUBEARRAY:
return 4;
default:
assert(0);
return 0;
vkd3d_unreachable();
}
}
......@@ -723,11 +750,12 @@ void hlsl_dump_function(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl
int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func,
enum vkd3d_shader_target_type target_type, struct vkd3d_shader_code *out);
bool hlsl_copy_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct hlsl_deref *other);
bool hlsl_copy_deref(struct hlsl_ctx *ctx, struct hlsl_deref *deref, const struct hlsl_deref *other);
void hlsl_cleanup_deref(struct hlsl_deref *deref);
void hlsl_replace_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new);
void hlsl_free_attribute(struct hlsl_attribute *attr);
void hlsl_free_instr(struct hlsl_ir_node *node);
void hlsl_free_instr_list(struct list *list);
void hlsl_free_type(struct hlsl_type *type);
......@@ -744,6 +772,7 @@ struct hlsl_type *hlsl_get_element_type_from_path_index(struct hlsl_ctx *ctx, co
struct hlsl_type *hlsl_new_array_type(struct hlsl_ctx *ctx, struct hlsl_type *basic_type, unsigned int array_size);
struct hlsl_ir_node *hlsl_new_binary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1,
struct hlsl_ir_node *arg2);
struct hlsl_ir_constant *hlsl_new_bool_constant(struct hlsl_ctx *ctx, bool b, const struct vkd3d_shader_location *loc);
struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type type, const char *name,
const struct hlsl_reg_reservation *reservation, struct vkd3d_shader_location loc);
struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type,
......@@ -751,8 +780,13 @@ struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *no
struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type,
const struct vkd3d_shader_location *loc);
struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ctx *ctx, struct hlsl_ir_node *node);
struct hlsl_ir_node *hlsl_new_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op,
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS],
struct hlsl_type *data_type, const struct vkd3d_shader_location *loc);
struct hlsl_ir_constant *hlsl_new_float_constant(struct hlsl_ctx *ctx,
float f, const struct vkd3d_shader_location *loc);
struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type,
struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc);
struct list *parameters, const struct hlsl_semantic *semantic, const struct vkd3d_shader_location *loc);
struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct vkd3d_shader_location loc);
struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
const struct vkd3d_shader_location *loc);
......@@ -773,21 +807,19 @@ struct hlsl_ir_store *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hl
struct hlsl_ir_store *hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block,
const struct hlsl_deref *lhs, unsigned int comp, struct hlsl_ir_node *rhs);
struct hlsl_ir_resource_load *hlsl_new_resource_load(struct hlsl_ctx *ctx, struct hlsl_type *data_type,
enum hlsl_resource_load_type type, struct hlsl_deref *resource, struct hlsl_deref *sampler,
struct hlsl_ir_node *coords, struct hlsl_ir_node *texel_offset, const struct vkd3d_shader_location *loc);
struct hlsl_ir_resource_load *hlsl_new_sample_lod(struct hlsl_ctx *ctx, struct hlsl_type *data_type,
struct hlsl_deref *resource, struct hlsl_deref *sampler, struct hlsl_ir_node *coords,
struct hlsl_ir_node *texel_offset, struct hlsl_ir_node *lod, const struct vkd3d_shader_location *loc);
struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, struct vkd3d_shader_location loc);
struct hlsl_ir_resource_load *hlsl_new_resource_load(struct hlsl_ctx *ctx,
const struct hlsl_resource_load_params *params, const struct vkd3d_shader_location *loc);
struct hlsl_ir_resource_store *hlsl_new_resource_store(struct hlsl_ctx *ctx, const struct hlsl_deref *resource,
struct hlsl_ir_node *coords, struct hlsl_ir_node *value, const struct vkd3d_shader_location *loc);
struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name,
struct hlsl_struct_field *fields, size_t field_count);
struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
struct hlsl_ir_node *val, const struct vkd3d_shader_location *loc);
struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type,
const struct vkd3d_shader_location loc);
struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *template,
struct hlsl_type *type, const struct vkd3d_shader_location *loc);
struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format);
struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format);
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
const struct vkd3d_shader_location *loc);
struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
......@@ -828,6 +860,7 @@ 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_type *hlsl_deref_get_type(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
bool hlsl_component_index_range_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref,
unsigned int *start, unsigned int *count);
bool hlsl_offset_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref, unsigned int *offset);
......
......@@ -102,6 +102,9 @@ RasterizerState {return KW_RASTERIZERSTATE; }
RenderTargetView {return KW_RENDERTARGETVIEW; }
return {return KW_RETURN; }
register {return KW_REGISTER; }
RWTexture1D {return KW_RWTEXTURE1D; }
RWTexture2D {return KW_RWTEXTURE2D; }
RWTexture3D {return KW_RWTEXTURE3D; }
sampler {return KW_SAMPLER; }
sampler1D {return KW_SAMPLER1D; }
sampler2D {return KW_SAMPLER2D; }
......
......@@ -79,8 +79,7 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct
break;
default:
assert(0);
return false;
vkd3d_unreachable();
}
switch (dst->node.data_type->base_type)
......@@ -104,12 +103,8 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct
case HLSL_TYPE_BOOL:
/* Casts to bool should have already been lowered. */
assert(0);
break;
default:
assert(0);
return false;
vkd3d_unreachable();
}
}
return true;
......@@ -248,8 +243,7 @@ static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst,
break;
default:
assert(0);
return false;
vkd3d_unreachable();
}
dst->value[k].u *= ~0u;
......@@ -532,9 +526,8 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
if (expr->operands[1].node)
arg2 = hlsl_ir_constant(expr->operands[1].node);
if (!(res = hlsl_alloc(ctx, sizeof(*res))))
if (!(res = hlsl_new_constant(ctx, instr->data_type, &instr->loc)))
return false;
init_node(&res->node, HLSL_IR_CONSTANT, instr->data_type, instr->loc);
switch (expr->op)
{
......@@ -617,9 +610,8 @@ bool hlsl_fold_constant_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
return false;
value = hlsl_ir_constant(swizzle->val.node);
if (!(res = hlsl_alloc(ctx, sizeof(*res))))
if (!(res = hlsl_new_constant(ctx, instr->data_type, &instr->loc)))
return false;
init_node(&res->node, HLSL_IR_CONSTANT, instr->data_type, instr->loc);
swizzle_bits = swizzle->swizzle;
for (i = 0; i < swizzle->node.data_type->dimx; ++i)
......
......@@ -159,8 +159,7 @@ static D3DXPARAMETER_CLASS sm1_class(const struct hlsl_type *type)
return D3DXPC_VECTOR;
default:
ERR("Invalid class %#x.\n", type->type);
assert(0);
return 0;
vkd3d_unreachable();
}
}
......@@ -193,6 +192,7 @@ static D3DXPARAMETER_TYPE sm1_base_type(const struct hlsl_type *type)
return D3DXPT_SAMPLER;
default:
ERR("Invalid dimension %#x.\n", type->sampler_dim);
vkd3d_unreachable();
}
break;
case HLSL_TYPE_STRING:
......@@ -212,6 +212,7 @@ static D3DXPARAMETER_TYPE sm1_base_type(const struct hlsl_type *type)
return D3DXPT_TEXTURE;
default:
ERR("Invalid dimension %#x.\n", type->sampler_dim);
vkd3d_unreachable();
}
break;
case HLSL_TYPE_VERTEXSHADER:
......@@ -219,10 +220,8 @@ static D3DXPARAMETER_TYPE sm1_base_type(const struct hlsl_type *type)
case HLSL_TYPE_VOID:
return D3DXPT_VOID;
default:
assert(0);
vkd3d_unreachable();
}
assert(0);
return 0;
}
static const struct hlsl_type *get_array_type(const struct hlsl_type *type)
......@@ -273,7 +272,7 @@ static void write_sm1_type(struct vkd3d_bytecode_buffer *buffer, struct hlsl_typ
}
}
type->bytecode_offset = put_u32(buffer, vkd3d_make_u32(sm1_class(type), sm1_base_type(type)));
type->bytecode_offset = put_u32(buffer, vkd3d_make_u32(sm1_class(type), sm1_base_type(array_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);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -690,6 +690,25 @@ static void vkd3d_shader_scan_record_uav_counter(struct vkd3d_shader_scan_contex
d->flags |= VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER;
}
static bool vkd3d_shader_instruction_is_uav_atomic_op(const struct vkd3d_shader_instruction *instruction)
{
enum vkd3d_shader_opcode handler_idx = instruction->handler_idx;
return (VKD3DSIH_ATOMIC_AND <= handler_idx && handler_idx <= VKD3DSIH_ATOMIC_XOR)
|| (VKD3DSIH_IMM_ATOMIC_ALLOC <= handler_idx && handler_idx <= VKD3DSIH_IMM_ATOMIC_XOR);
}
static void vkd3d_shader_scan_record_uav_atomic_op(struct vkd3d_shader_scan_context *context,
const struct vkd3d_shader_register *reg)
{
struct vkd3d_shader_descriptor_info *d;
if (!context->scan_descriptor_info)
return;
d = vkd3d_shader_scan_get_uav_descriptor_info(context, reg->idx[0].offset);
d->flags |= VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_ATOMICS;
}
static bool vkd3d_shader_scan_add_descriptor(struct vkd3d_shader_scan_context *context,
enum vkd3d_shader_descriptor_type type, const struct vkd3d_shader_register_range *range,
enum vkd3d_shader_resource_type resource_type, enum vkd3d_shader_resource_data_type resource_data_type,
......@@ -1017,6 +1036,15 @@ static int vkd3d_shader_scan_instruction(struct vkd3d_shader_scan_context *conte
if (vkd3d_shader_instruction_is_uav_counter(instruction))
vkd3d_shader_scan_record_uav_counter(context, &instruction->src[0].reg);
if (vkd3d_shader_instruction_is_uav_atomic_op(instruction))
{
for (i = 0; i < instruction->dst_count; ++i)
{
if (instruction->dst[i].reg.type == VKD3DSPR_UAV)
vkd3d_shader_scan_record_uav_atomic_op(context, &instruction->dst[i].reg);
}
}
++context->location.line;
return VKD3D_OK;
}
......@@ -1156,7 +1184,7 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
struct vkd3d_shader_scan_descriptor_info scan_descriptor_info;
struct vkd3d_shader_instruction instruction;
struct vkd3d_shader_compile_info scan_info;
struct vkd3d_dxbc_compiler *spirv_compiler;
struct spirv_compiler *spirv_compiler;
struct vkd3d_shader_parser *parser;
int ret;
......@@ -1206,7 +1234,7 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
return ret;
}
if (!(spirv_compiler = vkd3d_dxbc_compiler_create(&parser->shader_version, &parser->shader_desc,
if (!(spirv_compiler = spirv_compiler_create(&parser->shader_version, &parser->shader_desc,
compile_info, &scan_descriptor_info, message_context, &parser->location)))
{
ERR("Failed to create DXBC compiler.\n");
......@@ -1226,7 +1254,7 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
break;
}
if ((ret = vkd3d_dxbc_compiler_handle_instruction(spirv_compiler, &instruction)) < 0)
if ((ret = spirv_compiler_handle_instruction(spirv_compiler, &instruction)) < 0)
break;
}
......@@ -1234,9 +1262,9 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info
ret = VKD3D_ERROR_INVALID_SHADER;
if (ret >= 0)
ret = vkd3d_dxbc_compiler_generate_spirv(spirv_compiler, compile_info, out);
ret = spirv_compiler_generate_spirv(spirv_compiler, compile_info, out);
vkd3d_dxbc_compiler_destroy(spirv_compiler);
spirv_compiler_destroy(spirv_compiler);
vkd3d_shader_parser_destroy(parser);
vkd3d_shader_free_scan_descriptor_info(&scan_descriptor_info);
return ret;
......@@ -1312,7 +1340,7 @@ int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
break;
default:
assert(0);
vkd3d_unreachable();
}
vkd3d_shader_message_context_trace_messages(&message_context);
......
......@@ -119,9 +119,12 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_HLSL_INCOMPATIBLE_PROFILE = 5020,
VKD3D_SHADER_ERROR_HLSL_DIVISION_BY_ZERO = 5021,
VKD3D_SHADER_ERROR_HLSL_NON_STATIC_OBJECT_REF = 5022,
VKD3D_SHADER_ERROR_HLSL_INVALID_THREAD_COUNT = 5023,
VKD3D_SHADER_ERROR_HLSL_MISSING_ATTRIBUTE = 5024,
VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION = 5300,
VKD3D_SHADER_WARNING_HLSL_DIVISION_BY_ZERO = 5301,
VKD3D_SHADER_WARNING_HLSL_UNKNOWN_ATTRIBUTE = 5302,
VKD3D_SHADER_ERROR_GLSL_INTERNAL = 6000,
......@@ -1085,17 +1088,19 @@ int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator,
struct vkd3d_shader_parser *parser, struct vkd3d_shader_code *out);
void vkd3d_glsl_generator_destroy(struct vkd3d_glsl_generator *generator);
struct vkd3d_dxbc_compiler;
#define SPIRV_MAX_SRC_COUNT 6
struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader_version *shader_version,
struct spirv_compiler;
struct spirv_compiler *spirv_compiler_create(const struct vkd3d_shader_version *shader_version,
const struct vkd3d_shader_desc *shader_desc, const struct vkd3d_shader_compile_info *compile_info,
const struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info,
struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_location *location);
int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler,
int spirv_compiler_handle_instruction(struct spirv_compiler *compiler,
const struct vkd3d_shader_instruction *instruction);
int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
int spirv_compiler_generate_spirv(struct spirv_compiler *compiler,
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv);
void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler);
void spirv_compiler_destroy(struct spirv_compiler *compiler);
void vkd3d_compute_dxbc_checksum(const void *dxbc, size_t size, uint32_t checksum[4]);
......@@ -1237,7 +1242,6 @@ static inline void *vkd3d_find_struct_(const struct vkd3d_struct *chain,
return NULL;
}
#define VKD3D_DXBC_MAX_SOURCE_COUNT 6
#define VKD3D_DXBC_HEADER_SIZE (8 * sizeof(uint32_t))
#define TAG_AON9 VKD3D_MAKE_TAG('A', 'o', 'n', '9')
......
......@@ -4410,7 +4410,6 @@ HRESULT vkd3d_create_thread(struct vkd3d_instance *instance,
PFN_vkd3d_thread thread_main, void *data, union vkd3d_thread_handle *thread)
{
HRESULT hr = S_OK;
int rc;
if (instance->create_thread)
{
......@@ -4437,6 +4436,8 @@ HRESULT vkd3d_create_thread(struct vkd3d_instance *instance,
hr = E_FAIL;
}
#else
int rc;
if ((rc = pthread_create(&thread->pthread, NULL, thread_main, data)))
{
ERR("Failed to create thread, error %d.\n", rc);
......
......@@ -1964,7 +1964,7 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
const struct vkd3d_shader_compile_option options[] =
{
{VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_5},
{VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_6},
{VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV, typed_uav_compile_option(device)},
};
......@@ -2016,7 +2016,7 @@ static int vkd3d_scan_dxbc(const struct d3d12_device *device, const D3D12_SHADER
const struct vkd3d_shader_compile_option options[] =
{
{VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_5},
{VKD3D_SHADER_COMPILE_OPTION_API_VERSION, VKD3D_SHADER_API_VERSION_1_6},
{VKD3D_SHADER_COMPILE_OPTION_TYPED_UAV, typed_uav_compile_option(device)},
};
......
......@@ -1685,15 +1685,6 @@ extern const char vkd3d_build[];
bool vkd3d_get_program_name(char program_name[PATH_MAX]);
static inline void vkd3d_set_thread_name(const char *name)
{
#if defined(HAVE_PTHREAD_SETNAME_NP_2)
pthread_setname_np(pthread_self(), name);
#elif defined(HAVE_PTHREAD_SETNAME_NP_1)
pthread_setname_np(name);
#endif
}
VkResult vkd3d_set_vk_object_name_utf8(struct d3d12_device *device, uint64_t vk_object,
VkDebugReportObjectTypeEXT vk_object_type, const char *name);
HRESULT vkd3d_set_vk_object_name(struct d3d12_device *device, uint64_t vk_object,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment