mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
libs/vkd3d-shader: Avoid Windows data types in public API.
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
fddf86e6ea
commit
844c83a837
@ -19,7 +19,8 @@
|
|||||||
#ifndef __VKD3D_SHADER_H
|
#ifndef __VKD3D_SHADER_H
|
||||||
#define __VKD3D_SHADER_H
|
#define __VKD3D_SHADER_H
|
||||||
|
|
||||||
#include "vkd3d.h"
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -27,6 +28,17 @@ extern "C" {
|
|||||||
|
|
||||||
#define VKD3D_FORCE_32_BIT_ENUM(name) name##_FORCE_32BIT = 0x7fffffff
|
#define VKD3D_FORCE_32_BIT_ENUM(name) name##_FORCE_32BIT = 0x7fffffff
|
||||||
|
|
||||||
|
enum vkd3d_result
|
||||||
|
{
|
||||||
|
VKD3D_OK = 0,
|
||||||
|
VKD3D_ERROR = -1, /* unspecified failure */
|
||||||
|
VKD3D_ERROR_OUT_OF_MEMORY = -2,
|
||||||
|
VKD3D_ERROR_INVALID_ARGUMENT = -3,
|
||||||
|
VKD3D_ERROR_NOT_IMPLEMENTED = -4,
|
||||||
|
|
||||||
|
VKD3D_FORCE_32_BIT_ENUM(VKD3D_RESULT),
|
||||||
|
};
|
||||||
|
|
||||||
enum vkd3d_shader_compiler_option
|
enum vkd3d_shader_compiler_option
|
||||||
{
|
{
|
||||||
VKD3D_SHADER_STRIP_DEBUG = 0x00000001,
|
VKD3D_SHADER_STRIP_DEBUG = 0x00000001,
|
||||||
@ -113,7 +125,7 @@ struct vkd3d_shader_interface
|
|||||||
unsigned int uav_counter_count;
|
unsigned int uav_counter_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
|
int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
|
||||||
struct vkd3d_shader_code *spirv, uint32_t compiler_options,
|
struct vkd3d_shader_code *spirv, uint32_t compiler_options,
|
||||||
const struct vkd3d_shader_interface *shader_interface);
|
const struct vkd3d_shader_interface *shader_interface);
|
||||||
void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code);
|
void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code);
|
||||||
@ -295,7 +307,7 @@ struct vkd3d_root_signature_desc
|
|||||||
enum vkd3d_root_signature_flags flags;
|
enum vkd3d_root_signature_flags flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,
|
int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,
|
||||||
struct vkd3d_root_signature_desc *root_signature);
|
struct vkd3d_root_signature_desc *root_signature);
|
||||||
void vkd3d_shader_free_root_signature(struct vkd3d_root_signature_desc *root_signature);
|
void vkd3d_shader_free_root_signature(struct vkd3d_root_signature_desc *root_signature);
|
||||||
|
|
||||||
@ -306,7 +318,7 @@ enum vkd3d_root_signature_version
|
|||||||
VKD3D_FORCE_32_BIT_ENUM(VKD3D_ROOT_SIGNATURE_VERSION),
|
VKD3D_FORCE_32_BIT_ENUM(VKD3D_ROOT_SIGNATURE_VERSION),
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc *root_signature,
|
int vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc *root_signature,
|
||||||
enum vkd3d_root_signature_version version, struct vkd3d_shader_code *dxbc);
|
enum vkd3d_root_signature_version version, struct vkd3d_shader_code *dxbc);
|
||||||
|
|
||||||
#define VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS 8
|
#define VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS 8
|
||||||
@ -317,7 +329,7 @@ struct vkd3d_shader_scan_info
|
|||||||
unsigned int uav_counter_mask : VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS;
|
unsigned int uav_counter_mask : VKD3D_SHADER_MAX_UNORDERED_ACCESS_VIEWS;
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc,
|
int vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc,
|
||||||
struct vkd3d_shader_scan_info *scan_info);
|
struct vkd3d_shader_scan_info *scan_info);
|
||||||
|
|
||||||
enum vkd3d_component_type
|
enum vkd3d_component_type
|
||||||
@ -362,7 +374,7 @@ struct vkd3d_shader_signature_element
|
|||||||
enum vkd3d_sysval_semantic sysval_semantic;
|
enum vkd3d_sysval_semantic sysval_semantic;
|
||||||
enum vkd3d_component_type component_type;
|
enum vkd3d_component_type component_type;
|
||||||
unsigned int register_index;
|
unsigned int register_index;
|
||||||
DWORD mask;
|
unsigned int mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vkd3d_shader_signature
|
struct vkd3d_shader_signature
|
||||||
@ -371,7 +383,7 @@ struct vkd3d_shader_signature
|
|||||||
unsigned int element_count;
|
unsigned int element_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
|
int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
|
||||||
struct vkd3d_shader_signature *signature);
|
struct vkd3d_shader_signature *signature);
|
||||||
struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(
|
struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(
|
||||||
const struct vkd3d_shader_signature *signature, const char *semantic_name,
|
const struct vkd3d_shader_signature *signature, const char *semantic_name,
|
||||||
|
@ -1808,11 +1808,11 @@ static const char *shader_get_string(const char *data, size_t data_size, DWORD o
|
|||||||
return data + offset;
|
return data + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT parse_dxbc(const char *data, SIZE_T data_size,
|
static int parse_dxbc(const char *data, SIZE_T data_size,
|
||||||
HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx)
|
int (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx)
|
||||||
{
|
{
|
||||||
const char *ptr = data;
|
const char *ptr = data;
|
||||||
HRESULT hr = S_OK;
|
int ret = VKD3D_OK;
|
||||||
DWORD chunk_count;
|
DWORD chunk_count;
|
||||||
DWORD total_size;
|
DWORD total_size;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -1825,7 +1825,7 @@ static HRESULT parse_dxbc(const char *data, SIZE_T data_size,
|
|||||||
if (tag != TAG_DXBC)
|
if (tag != TAG_DXBC)
|
||||||
{
|
{
|
||||||
WARN("Wrong tag.\n");
|
WARN("Wrong tag.\n");
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
WARN("Ignoring DXBC checksum.\n");
|
WARN("Ignoring DXBC checksum.\n");
|
||||||
@ -1836,7 +1836,7 @@ static HRESULT parse_dxbc(const char *data, SIZE_T data_size,
|
|||||||
if (version != 0x00000001)
|
if (version != 0x00000001)
|
||||||
{
|
{
|
||||||
WARN("Got unexpected DXBC version %#x.\n", version);
|
WARN("Got unexpected DXBC version %#x.\n", version);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_dword(&ptr, &total_size);
|
read_dword(&ptr, &total_size);
|
||||||
@ -1857,7 +1857,7 @@ static HRESULT parse_dxbc(const char *data, SIZE_T data_size,
|
|||||||
if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size))
|
if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size))
|
||||||
{
|
{
|
||||||
WARN("Invalid chunk offset %#x (data size %#lx).\n", chunk_offset, data_size);
|
WARN("Invalid chunk offset %#x (data size %#lx).\n", chunk_offset, data_size);
|
||||||
return E_FAIL;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk_ptr = data + chunk_offset;
|
chunk_ptr = data + chunk_offset;
|
||||||
@ -1869,17 +1869,17 @@ static HRESULT parse_dxbc(const char *data, SIZE_T data_size,
|
|||||||
{
|
{
|
||||||
WARN("Invalid chunk size %#x (data size %#lx, chunk offset %#x).\n",
|
WARN("Invalid chunk size %#x (data size %#lx, chunk offset %#x).\n",
|
||||||
chunk_size, data_size, chunk_offset);
|
chunk_size, data_size, chunk_offset);
|
||||||
return E_FAIL;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx);
|
if ((ret = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx)) < 0)
|
||||||
if (FAILED(hr)) break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hr;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_size,
|
static int shader_parse_signature(DWORD tag, const char *data, DWORD data_size,
|
||||||
struct vkd3d_shader_signature *s)
|
struct vkd3d_shader_signature *s)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_signature_element *e;
|
struct vkd3d_shader_signature_element *e;
|
||||||
@ -1890,7 +1890,7 @@ static HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_si
|
|||||||
if (!require_space(0, 2, sizeof(DWORD), data_size))
|
if (!require_space(0, 2, sizeof(DWORD), data_size))
|
||||||
{
|
{
|
||||||
WARN("Invalid data size %#x.\n", data_size);
|
WARN("Invalid data size %#x.\n", data_size);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_dword(&ptr, &count);
|
read_dword(&ptr, &count);
|
||||||
@ -1901,13 +1901,13 @@ static HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_si
|
|||||||
if (!require_space(ptr - data, count, 6 * sizeof(DWORD), data_size))
|
if (!require_space(ptr - data, count, 6 * sizeof(DWORD), data_size))
|
||||||
{
|
{
|
||||||
WARN("Invalid count %#x (data size %#x).\n", count, data_size);
|
WARN("Invalid count %#x (data size %#x).\n", count, data_size);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(e = vkd3d_calloc(count, sizeof(*e))))
|
if (!(e = vkd3d_calloc(count, sizeof(*e))))
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate input signature memory.\n");
|
ERR("Failed to allocate input signature memory.\n");
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
@ -1923,7 +1923,7 @@ static HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_si
|
|||||||
{
|
{
|
||||||
WARN("Invalid name offset %#x (data size %#x).\n", name_offset, data_size);
|
WARN("Invalid name offset %#x (data size %#x).\n", name_offset, data_size);
|
||||||
vkd3d_free(e);
|
vkd3d_free(e);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
read_dword(&ptr, &e[i].semantic_index);
|
read_dword(&ptr, &e[i].semantic_index);
|
||||||
read_dword(&ptr, &e[i].sysval_semantic);
|
read_dword(&ptr, &e[i].sysval_semantic);
|
||||||
@ -1940,15 +1940,15 @@ static HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_si
|
|||||||
s->elements = e;
|
s->elements = e;
|
||||||
s->element_count = count;
|
s->element_count = count;
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT isgn_handler(const char *data, DWORD data_size, DWORD tag, void *ctx)
|
static int isgn_handler(const char *data, DWORD data_size, DWORD tag, void *ctx)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_signature *is = ctx;
|
struct vkd3d_shader_signature *is = ctx;
|
||||||
|
|
||||||
if (tag != TAG_ISGN)
|
if (tag != TAG_ISGN)
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
|
|
||||||
if (is->elements)
|
if (is->elements)
|
||||||
{
|
{
|
||||||
@ -1958,26 +1958,21 @@ static HRESULT isgn_handler(const char *data, DWORD data_size, DWORD tag, void *
|
|||||||
return shader_parse_signature(tag, data, data_size, is);
|
return shader_parse_signature(tag, data, data_size, is);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT shader_parse_input_signature(const void *dxbc, SIZE_T dxbc_length,
|
int shader_parse_input_signature(const void *dxbc, SIZE_T dxbc_length,
|
||||||
struct vkd3d_shader_signature *signature)
|
struct vkd3d_shader_signature *signature)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
memset(signature, 0, sizeof(*signature));
|
memset(signature, 0, sizeof(*signature));
|
||||||
|
if ((ret = parse_dxbc(dxbc, dxbc_length, isgn_handler, signature)) < 0)
|
||||||
if (FAILED(hr = parse_dxbc(dxbc, dxbc_length, isgn_handler, signature)))
|
|
||||||
{
|
|
||||||
ERR("Failed to parse input signature.\n");
|
ERR("Failed to parse input signature.\n");
|
||||||
return E_FAIL;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void *context)
|
static int shdr_handler(const char *data, DWORD data_size, DWORD tag, void *context)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_desc *desc = context;
|
struct vkd3d_shader_desc *desc = context;
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
switch (tag)
|
switch (tag)
|
||||||
{
|
{
|
||||||
@ -1987,8 +1982,8 @@ static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void *
|
|||||||
FIXME("Multiple input signatures.\n");
|
FIXME("Multiple input signatures.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (FAILED(hr = shader_parse_signature(tag, data, data_size, &desc->input_signature)))
|
if ((ret = shader_parse_signature(tag, data, data_size, &desc->input_signature)) < 0)
|
||||||
return hr;
|
return ret;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TAG_OSGN:
|
case TAG_OSGN:
|
||||||
@ -1998,8 +1993,8 @@ static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void *
|
|||||||
FIXME("Multiple output signatures.\n");
|
FIXME("Multiple output signatures.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (FAILED(hr = shader_parse_signature(tag, data, data_size, &desc->output_signature)))
|
if ((ret = shader_parse_signature(tag, data, data_size, &desc->output_signature)) < 0)
|
||||||
return hr;
|
return ret;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TAG_PCSG:
|
case TAG_PCSG:
|
||||||
@ -2008,8 +2003,8 @@ static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void *
|
|||||||
FIXME("Multiple patch constant signatures.\n");
|
FIXME("Multiple patch constant signatures.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (FAILED(hr = shader_parse_signature(tag, data, data_size, &desc->patch_constant_signature)))
|
if ((ret = shader_parse_signature(tag, data, data_size, &desc->patch_constant_signature)) < 0)
|
||||||
return hr;
|
return ret;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TAG_SHDR:
|
case TAG_SHDR:
|
||||||
@ -2029,7 +2024,7 @@ static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void *
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_shader_desc(struct vkd3d_shader_desc *desc)
|
void free_shader_desc(struct vkd3d_shader_desc *desc)
|
||||||
@ -2039,10 +2034,10 @@ void free_shader_desc(struct vkd3d_shader_desc *desc)
|
|||||||
vkd3d_shader_free_shader_signature(&desc->patch_constant_signature);
|
vkd3d_shader_free_shader_signature(&desc->patch_constant_signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length,
|
int shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length,
|
||||||
struct vkd3d_shader_desc *desc)
|
struct vkd3d_shader_desc *desc)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
desc->byte_code = NULL;
|
desc->byte_code = NULL;
|
||||||
desc->byte_code_size = 0;
|
desc->byte_code_size = 0;
|
||||||
@ -2050,20 +2045,20 @@ HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length,
|
|||||||
memset(&desc->output_signature, 0, sizeof(desc->output_signature));
|
memset(&desc->output_signature, 0, sizeof(desc->output_signature));
|
||||||
memset(&desc->patch_constant_signature, 0, sizeof(desc->patch_constant_signature));
|
memset(&desc->patch_constant_signature, 0, sizeof(desc->patch_constant_signature));
|
||||||
|
|
||||||
hr = parse_dxbc(dxbc, dxbc_length, shdr_handler, desc);
|
ret = parse_dxbc(dxbc, dxbc_length, shdr_handler, desc);
|
||||||
if (!desc->byte_code)
|
if (!desc->byte_code)
|
||||||
hr = E_INVALIDARG;
|
ret = VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
FIXME("Failed to parse shader, hr %#x.\n", hr);
|
FIXME("Failed to parse shader, vkd3d result %d.\n", ret);
|
||||||
free_shader_desc(desc);
|
free_shader_desc(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hr;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_parse_descriptor_ranges(const char *data, DWORD data_size,
|
static int shader_parse_descriptor_ranges(const char *data, DWORD data_size,
|
||||||
DWORD offset, DWORD count, struct vkd3d_descriptor_range *ranges)
|
DWORD offset, DWORD count, struct vkd3d_descriptor_range *ranges)
|
||||||
{
|
{
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
@ -2072,7 +2067,7 @@ static HRESULT shader_parse_descriptor_ranges(const char *data, DWORD data_size,
|
|||||||
if (!require_space(offset, 5 * count, sizeof(DWORD), data_size))
|
if (!require_space(offset, 5 * count, sizeof(DWORD), data_size))
|
||||||
{
|
{
|
||||||
WARN("Invalid data size %#x (offset %u, count %u).\n", data_size, offset, count);
|
WARN("Invalid data size %#x (offset %u, count %u).\n", data_size, offset, count);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
ptr = &data[offset];
|
ptr = &data[offset];
|
||||||
|
|
||||||
@ -2091,10 +2086,10 @@ static HRESULT shader_parse_descriptor_ranges(const char *data, DWORD data_size,
|
|||||||
ranges[i].descriptor_table_offset);
|
ranges[i].descriptor_table_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_parse_descriptor_table(const char *data, DWORD data_size,
|
static int shader_parse_descriptor_table(const char *data, DWORD data_size,
|
||||||
DWORD offset, struct vkd3d_root_descriptor_table *table)
|
DWORD offset, struct vkd3d_root_descriptor_table *table)
|
||||||
{
|
{
|
||||||
struct vkd3d_descriptor_range *ranges;
|
struct vkd3d_descriptor_range *ranges;
|
||||||
@ -2104,7 +2099,7 @@ static HRESULT shader_parse_descriptor_table(const char *data, DWORD data_size,
|
|||||||
if (!require_space(offset, 2, sizeof(DWORD), data_size))
|
if (!require_space(offset, 2, sizeof(DWORD), data_size))
|
||||||
{
|
{
|
||||||
WARN("Invalid data size %#x (offset %u).\n", data_size, offset);
|
WARN("Invalid data size %#x (offset %u).\n", data_size, offset);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
ptr = &data[offset];
|
ptr = &data[offset];
|
||||||
|
|
||||||
@ -2116,12 +2111,12 @@ static HRESULT shader_parse_descriptor_table(const char *data, DWORD data_size,
|
|||||||
table->descriptor_range_count = count;
|
table->descriptor_range_count = count;
|
||||||
|
|
||||||
if (!(ranges = vkd3d_calloc(count, sizeof(*ranges))))
|
if (!(ranges = vkd3d_calloc(count, sizeof(*ranges))))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
table->descriptor_ranges = ranges;
|
table->descriptor_ranges = ranges;
|
||||||
return shader_parse_descriptor_ranges(data, data_size, offset, count, ranges);
|
return shader_parse_descriptor_ranges(data, data_size, offset, count, ranges);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_parse_root_constants(const char *data, DWORD data_size,
|
static int shader_parse_root_constants(const char *data, DWORD data_size,
|
||||||
DWORD offset, struct vkd3d_root_constants *constants)
|
DWORD offset, struct vkd3d_root_constants *constants)
|
||||||
{
|
{
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
@ -2129,7 +2124,7 @@ static HRESULT shader_parse_root_constants(const char *data, DWORD data_size,
|
|||||||
if (!require_space(offset, 3, sizeof(DWORD), data_size))
|
if (!require_space(offset, 3, sizeof(DWORD), data_size))
|
||||||
{
|
{
|
||||||
WARN("Invalid data size %#x (offset %u).\n", data_size, offset);
|
WARN("Invalid data size %#x (offset %u).\n", data_size, offset);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
ptr = &data[offset];
|
ptr = &data[offset];
|
||||||
|
|
||||||
@ -2140,10 +2135,10 @@ static HRESULT shader_parse_root_constants(const char *data, DWORD data_size,
|
|||||||
TRACE("Shader register %u, register space %u, 32-bit value count %u.\n",
|
TRACE("Shader register %u, register space %u, 32-bit value count %u.\n",
|
||||||
constants->shader_register, constants->register_space, constants->value_count);
|
constants->shader_register, constants->register_space, constants->value_count);
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_parse_root_descriptor(const char *data, DWORD data_size,
|
static int shader_parse_root_descriptor(const char *data, DWORD data_size,
|
||||||
DWORD offset, struct vkd3d_root_descriptor *descriptor)
|
DWORD offset, struct vkd3d_root_descriptor *descriptor)
|
||||||
{
|
{
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
@ -2151,7 +2146,7 @@ static HRESULT shader_parse_root_descriptor(const char *data, DWORD data_size,
|
|||||||
if (!require_space(offset, 2, sizeof(DWORD), data_size))
|
if (!require_space(offset, 2, sizeof(DWORD), data_size))
|
||||||
{
|
{
|
||||||
WARN("Invalid data size %#x (offset %u).\n", data_size, offset);
|
WARN("Invalid data size %#x (offset %u).\n", data_size, offset);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
ptr = &data[offset];
|
ptr = &data[offset];
|
||||||
|
|
||||||
@ -2161,20 +2156,20 @@ static HRESULT shader_parse_root_descriptor(const char *data, DWORD data_size,
|
|||||||
TRACE("Shader register %u, register space %u.\n",
|
TRACE("Shader register %u, register space %u.\n",
|
||||||
descriptor->shader_register, descriptor->register_space);
|
descriptor->shader_register, descriptor->register_space);
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_parse_root_parameters(const char *data, DWORD data_size,
|
static int shader_parse_root_parameters(const char *data, DWORD data_size,
|
||||||
DWORD offset, DWORD count, struct vkd3d_root_parameter *parameters)
|
DWORD offset, DWORD count, struct vkd3d_root_parameter *parameters)
|
||||||
{
|
{
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
if (!require_space(offset, 3 * count, sizeof(DWORD), data_size))
|
if (!require_space(offset, 3 * count, sizeof(DWORD), data_size))
|
||||||
{
|
{
|
||||||
WARN("Invalid data size %#x (offset %u, count %u).\n", data_size, offset, count);
|
WARN("Invalid data size %#x (offset %u, count %u).\n", data_size, offset, count);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
ptr = &data[offset];
|
ptr = &data[offset];
|
||||||
|
|
||||||
@ -2190,29 +2185,29 @@ static HRESULT shader_parse_root_parameters(const char *data, DWORD data_size,
|
|||||||
switch (parameters[i].parameter_type)
|
switch (parameters[i].parameter_type)
|
||||||
{
|
{
|
||||||
case VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE:
|
case VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE:
|
||||||
hr = shader_parse_descriptor_table(data, data_size, offset, ¶meters[i].u.descriptor_table);
|
ret = shader_parse_descriptor_table(data, data_size, offset, ¶meters[i].u.descriptor_table);
|
||||||
break;
|
break;
|
||||||
case VKD3D_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS:
|
case VKD3D_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS:
|
||||||
hr = shader_parse_root_constants(data, data_size, offset, ¶meters[i].u.constants);
|
ret = shader_parse_root_constants(data, data_size, offset, ¶meters[i].u.constants);
|
||||||
break;
|
break;
|
||||||
case VKD3D_ROOT_PARAMETER_TYPE_CBV:
|
case VKD3D_ROOT_PARAMETER_TYPE_CBV:
|
||||||
case VKD3D_ROOT_PARAMETER_TYPE_SRV:
|
case VKD3D_ROOT_PARAMETER_TYPE_SRV:
|
||||||
case VKD3D_ROOT_PARAMETER_TYPE_UAV:
|
case VKD3D_ROOT_PARAMETER_TYPE_UAV:
|
||||||
hr = shader_parse_root_descriptor(data, data_size, offset, ¶meters[i].u.descriptor);
|
ret = shader_parse_root_descriptor(data, data_size, offset, ¶meters[i].u.descriptor);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FIXME("Unrecognized type %#x.\n", parameters[i].parameter_type);
|
FIXME("Unrecognized type %#x.\n", parameters[i].parameter_type);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (ret < 0)
|
||||||
return hr;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_parse_static_samplers(const char *data, DWORD data_size,
|
static int shader_parse_static_samplers(const char *data, DWORD data_size,
|
||||||
DWORD offset, DWORD count, struct vkd3d_static_sampler_desc *sampler_descs)
|
DWORD offset, DWORD count, struct vkd3d_static_sampler_desc *sampler_descs)
|
||||||
{
|
{
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
@ -2221,7 +2216,7 @@ static HRESULT shader_parse_static_samplers(const char *data, DWORD data_size,
|
|||||||
if (!require_space(offset, 13 * count, sizeof(DWORD), data_size))
|
if (!require_space(offset, 13 * count, sizeof(DWORD), data_size))
|
||||||
{
|
{
|
||||||
WARN("Invalid data size %#x (offset %u, count %u).\n", data_size, offset, count);
|
WARN("Invalid data size %#x (offset %u, count %u).\n", data_size, offset, count);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
ptr = &data[offset];
|
ptr = &data[offset];
|
||||||
|
|
||||||
@ -2242,20 +2237,20 @@ static HRESULT shader_parse_static_samplers(const char *data, DWORD data_size,
|
|||||||
read_dword(&ptr, &sampler_descs[i].shader_visibility);
|
read_dword(&ptr, &sampler_descs[i].shader_visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_parse_root_signature(const char *data, DWORD data_size,
|
static int shader_parse_root_signature(const char *data, DWORD data_size,
|
||||||
struct vkd3d_root_signature_desc *desc)
|
struct vkd3d_root_signature_desc *desc)
|
||||||
{
|
{
|
||||||
const char *ptr = data;
|
const char *ptr = data;
|
||||||
DWORD count, offset;
|
DWORD count, offset;
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
if (!require_space(0, 6, sizeof(DWORD), data_size))
|
if (!require_space(0, 6, sizeof(DWORD), data_size))
|
||||||
{
|
{
|
||||||
WARN("Invalid data size %#x.\n", data_size);
|
WARN("Invalid data size %#x.\n", data_size);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_dword_unknown(&ptr, 1); /* It seems to always be 0x00000001. */
|
skip_dword_unknown(&ptr, 1); /* It seems to always be 0x00000001. */
|
||||||
@ -2269,10 +2264,10 @@ static HRESULT shader_parse_root_signature(const char *data, DWORD data_size,
|
|||||||
{
|
{
|
||||||
struct vkd3d_root_parameter *parameters;
|
struct vkd3d_root_parameter *parameters;
|
||||||
if (!(parameters = vkd3d_calloc(desc->parameter_count, sizeof(*parameters))))
|
if (!(parameters = vkd3d_calloc(desc->parameter_count, sizeof(*parameters))))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
desc->parameters = parameters;
|
desc->parameters = parameters;
|
||||||
if (FAILED(hr = shader_parse_root_parameters(data, data_size, offset, count, parameters)))
|
if ((ret = shader_parse_root_parameters(data, data_size, offset, count, parameters)) < 0)
|
||||||
return hr;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_dword(&ptr, &count);
|
read_dword(&ptr, &count);
|
||||||
@ -2284,43 +2279,43 @@ static HRESULT shader_parse_root_signature(const char *data, DWORD data_size,
|
|||||||
{
|
{
|
||||||
struct vkd3d_static_sampler_desc *samplers;
|
struct vkd3d_static_sampler_desc *samplers;
|
||||||
if (!(samplers = vkd3d_calloc(desc->static_sampler_count, sizeof(*samplers))))
|
if (!(samplers = vkd3d_calloc(desc->static_sampler_count, sizeof(*samplers))))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
desc->static_samplers = samplers;
|
desc->static_samplers = samplers;
|
||||||
if (FAILED(hr = shader_parse_static_samplers(data, data_size, offset, count, samplers)))
|
if ((ret = shader_parse_static_samplers(data, data_size, offset, count, samplers)) < 0)
|
||||||
return hr;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_dword(&ptr, &desc->flags);
|
read_dword(&ptr, &desc->flags);
|
||||||
TRACE("Flags %#x.\n", desc->flags);
|
TRACE("Flags %#x.\n", desc->flags);
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT rts0_handler(const char *data, DWORD data_size, DWORD tag, void *context)
|
static int rts0_handler(const char *data, DWORD data_size, DWORD tag, void *context)
|
||||||
{
|
{
|
||||||
struct vkd3d_root_signature_desc *desc = context;
|
struct vkd3d_root_signature_desc *desc = context;
|
||||||
|
|
||||||
if (tag != TAG_RTS0)
|
if (tag != TAG_RTS0)
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
|
|
||||||
return shader_parse_root_signature(data, data_size, desc);
|
return shader_parse_root_signature(data, data_size, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,
|
int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,
|
||||||
struct vkd3d_root_signature_desc *root_signature)
|
struct vkd3d_root_signature_desc *root_signature)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
TRACE("dxbc {%p, %zu}, root_signature %p.\n", dxbc->code, dxbc->size, root_signature);
|
TRACE("dxbc {%p, %zu}, root_signature %p.\n", dxbc->code, dxbc->size, root_signature);
|
||||||
|
|
||||||
memset(root_signature, 0, sizeof(*root_signature));
|
memset(root_signature, 0, sizeof(*root_signature));
|
||||||
if (FAILED(hr = parse_dxbc(dxbc->code, dxbc->size, rts0_handler, root_signature)))
|
if ((ret = parse_dxbc(dxbc->code, dxbc->size, rts0_handler, root_signature)) < 0)
|
||||||
{
|
{
|
||||||
vkd3d_shader_free_root_signature(root_signature);
|
vkd3d_shader_free_root_signature(root_signature);
|
||||||
return hr;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct root_signature_writer_context
|
struct root_signature_writer_context
|
||||||
@ -2367,39 +2362,39 @@ static size_t get_chunk_offset(struct root_signature_writer_context *context)
|
|||||||
return (context->position - context->chunk_position) * sizeof(DWORD);
|
return (context->position - context->chunk_position) * sizeof(DWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_write_root_signature_header(struct root_signature_writer_context *context)
|
static int shader_write_root_signature_header(struct root_signature_writer_context *context)
|
||||||
{
|
{
|
||||||
if (!write_dword(context, TAG_DXBC))
|
if (!write_dword(context, TAG_DXBC))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
WARN("DXBC checksum is not implemented.\n");
|
WARN("DXBC checksum is not implemented.\n");
|
||||||
if (!write_dwords(context, 4, 0x00000000))
|
if (!write_dwords(context, 4, 0x00000000))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (!write_dword(context, 0x00000001))
|
if (!write_dword(context, 0x00000001))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
context->total_size_position = context->position;
|
context->total_size_position = context->position;
|
||||||
if (!write_dword(context, 0xffffffff)) /* total size */
|
if (!write_dword(context, 0xffffffff)) /* total size */
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (!write_dword(context, 1)) /* chunk count */
|
if (!write_dword(context, 1)) /* chunk count */
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
/* chunk offset */
|
/* chunk offset */
|
||||||
if (!write_dword(context, (context->position + 1) * sizeof(DWORD)))
|
if (!write_dword(context, (context->position + 1) * sizeof(DWORD)))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (!write_dword(context, TAG_RTS0))
|
if (!write_dword(context, TAG_RTS0))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, 0xffffffff)) /* chunk size */
|
if (!write_dword(context, 0xffffffff)) /* chunk size */
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
context->chunk_position = context->position;
|
context->chunk_position = context->position;
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_write_descriptor_ranges(struct root_signature_writer_context *context,
|
static int shader_write_descriptor_ranges(struct root_signature_writer_context *context,
|
||||||
const struct vkd3d_root_descriptor_table *table)
|
const struct vkd3d_root_descriptor_table *table)
|
||||||
{
|
{
|
||||||
const struct vkd3d_descriptor_range *ranges = table->descriptor_ranges;
|
const struct vkd3d_descriptor_range *ranges = table->descriptor_ranges;
|
||||||
@ -2408,72 +2403,72 @@ static HRESULT shader_write_descriptor_ranges(struct root_signature_writer_conte
|
|||||||
for (i = 0; i < table->descriptor_range_count; ++i)
|
for (i = 0; i < table->descriptor_range_count; ++i)
|
||||||
{
|
{
|
||||||
if (!write_dword(context, ranges[i].range_type))
|
if (!write_dword(context, ranges[i].range_type))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, ranges[i].descriptor_count))
|
if (!write_dword(context, ranges[i].descriptor_count))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, ranges[i].base_shader_register))
|
if (!write_dword(context, ranges[i].base_shader_register))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, ranges[i].register_space))
|
if (!write_dword(context, ranges[i].register_space))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, ranges[i].descriptor_table_offset))
|
if (!write_dword(context, ranges[i].descriptor_table_offset))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_write_descriptor_table(struct root_signature_writer_context *context,
|
static int shader_write_descriptor_table(struct root_signature_writer_context *context,
|
||||||
const struct vkd3d_root_descriptor_table *table)
|
const struct vkd3d_root_descriptor_table *table)
|
||||||
{
|
{
|
||||||
if (!write_dword(context, table->descriptor_range_count))
|
if (!write_dword(context, table->descriptor_range_count))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, get_chunk_offset(context) + sizeof(DWORD))) /* offset */
|
if (!write_dword(context, get_chunk_offset(context) + sizeof(DWORD))) /* offset */
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
return shader_write_descriptor_ranges(context, table);
|
return shader_write_descriptor_ranges(context, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_write_root_constants(struct root_signature_writer_context *context,
|
static int shader_write_root_constants(struct root_signature_writer_context *context,
|
||||||
const struct vkd3d_root_constants *constants)
|
const struct vkd3d_root_constants *constants)
|
||||||
{
|
{
|
||||||
if (!write_dword(context, constants->shader_register))
|
if (!write_dword(context, constants->shader_register))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, constants->register_space))
|
if (!write_dword(context, constants->register_space))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, constants->value_count))
|
if (!write_dword(context, constants->value_count))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_write_root_descriptor(struct root_signature_writer_context *context,
|
static int shader_write_root_descriptor(struct root_signature_writer_context *context,
|
||||||
const struct vkd3d_root_descriptor *descriptor)
|
const struct vkd3d_root_descriptor *descriptor)
|
||||||
{
|
{
|
||||||
if (!write_dword(context, descriptor->shader_register))
|
if (!write_dword(context, descriptor->shader_register))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, descriptor->register_space))
|
if (!write_dword(context, descriptor->register_space))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_write_root_parameters(struct root_signature_writer_context *context,
|
static int shader_write_root_parameters(struct root_signature_writer_context *context,
|
||||||
const struct vkd3d_root_signature_desc *desc)
|
const struct vkd3d_root_signature_desc *desc)
|
||||||
{
|
{
|
||||||
const struct vkd3d_root_parameter *parameters = desc->parameters;
|
const struct vkd3d_root_parameter *parameters = desc->parameters;
|
||||||
size_t parameters_position;
|
size_t parameters_position;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
parameters_position = context->position;
|
parameters_position = context->position;
|
||||||
for (i = 0; i < desc->parameter_count; ++i)
|
for (i = 0; i < desc->parameter_count; ++i)
|
||||||
{
|
{
|
||||||
if (!write_dword(context, parameters[i].parameter_type))
|
if (!write_dword(context, parameters[i].parameter_type))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, parameters[i].shader_visibility))
|
if (!write_dword(context, parameters[i].shader_visibility))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, 0xffffffff)) /* offset */
|
if (!write_dword(context, 0xffffffff)) /* offset */
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < desc->parameter_count; ++i)
|
for (i = 0; i < desc->parameter_count; ++i)
|
||||||
@ -2483,29 +2478,29 @@ static HRESULT shader_write_root_parameters(struct root_signature_writer_context
|
|||||||
switch (parameters[i].parameter_type)
|
switch (parameters[i].parameter_type)
|
||||||
{
|
{
|
||||||
case VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE:
|
case VKD3D_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE:
|
||||||
hr = shader_write_descriptor_table(context, ¶meters[i].u.descriptor_table);
|
ret = shader_write_descriptor_table(context, ¶meters[i].u.descriptor_table);
|
||||||
break;
|
break;
|
||||||
case VKD3D_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS:
|
case VKD3D_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS:
|
||||||
hr = shader_write_root_constants(context, ¶meters[i].u.constants);
|
ret = shader_write_root_constants(context, ¶meters[i].u.constants);
|
||||||
break;
|
break;
|
||||||
case VKD3D_ROOT_PARAMETER_TYPE_CBV:
|
case VKD3D_ROOT_PARAMETER_TYPE_CBV:
|
||||||
case VKD3D_ROOT_PARAMETER_TYPE_SRV:
|
case VKD3D_ROOT_PARAMETER_TYPE_SRV:
|
||||||
case VKD3D_ROOT_PARAMETER_TYPE_UAV:
|
case VKD3D_ROOT_PARAMETER_TYPE_UAV:
|
||||||
hr = shader_write_root_descriptor(context, ¶meters[i].u.descriptor);
|
ret = shader_write_root_descriptor(context, ¶meters[i].u.descriptor);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FIXME("Unrecognized type %#x.\n", parameters[i].parameter_type);
|
FIXME("Unrecognized type %#x.\n", parameters[i].parameter_type);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (ret < 0)
|
||||||
return hr;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_write_static_samplers(struct root_signature_writer_context *context,
|
static int shader_write_static_samplers(struct root_signature_writer_context *context,
|
||||||
const struct vkd3d_root_signature_desc *desc)
|
const struct vkd3d_root_signature_desc *desc)
|
||||||
{
|
{
|
||||||
const struct vkd3d_static_sampler_desc *samplers = desc->static_samplers;
|
const struct vkd3d_static_sampler_desc *samplers = desc->static_samplers;
|
||||||
@ -2514,93 +2509,93 @@ static HRESULT shader_write_static_samplers(struct root_signature_writer_context
|
|||||||
for (i = 0; i < desc->static_sampler_count; ++i)
|
for (i = 0; i < desc->static_sampler_count; ++i)
|
||||||
{
|
{
|
||||||
if (!write_dword(context, samplers[i].filter))
|
if (!write_dword(context, samplers[i].filter))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, samplers[i].address_u))
|
if (!write_dword(context, samplers[i].address_u))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, samplers[i].address_v))
|
if (!write_dword(context, samplers[i].address_v))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, samplers[i].address_w))
|
if (!write_dword(context, samplers[i].address_w))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_float(context, samplers[i].mip_lod_bias))
|
if (!write_float(context, samplers[i].mip_lod_bias))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, samplers[i].max_anisotropy))
|
if (!write_dword(context, samplers[i].max_anisotropy))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, samplers[i].comparison_func))
|
if (!write_dword(context, samplers[i].comparison_func))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, samplers[i].border_color))
|
if (!write_dword(context, samplers[i].border_color))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_float(context, samplers[i].min_lod))
|
if (!write_float(context, samplers[i].min_lod))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_float(context, samplers[i].max_lod))
|
if (!write_float(context, samplers[i].max_lod))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, samplers[i].shader_register))
|
if (!write_dword(context, samplers[i].shader_register))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, samplers[i].register_space))
|
if (!write_dword(context, samplers[i].register_space))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, samplers[i].shader_visibility))
|
if (!write_dword(context, samplers[i].shader_visibility))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT shader_write_root_signature(struct root_signature_writer_context *context,
|
static int shader_write_root_signature(struct root_signature_writer_context *context,
|
||||||
const struct vkd3d_root_signature_desc *desc)
|
const struct vkd3d_root_signature_desc *desc)
|
||||||
{
|
{
|
||||||
size_t samplers_offset_position;
|
size_t samplers_offset_position;
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
if (!write_dword(context, 0x00000001))
|
if (!write_dword(context, 0x00000001))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (!write_dword(context, desc->parameter_count))
|
if (!write_dword(context, desc->parameter_count))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
if (!write_dword(context, get_chunk_offset(context) + 4 * sizeof(DWORD))) /* offset */
|
if (!write_dword(context, get_chunk_offset(context) + 4 * sizeof(DWORD))) /* offset */
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (!write_dword(context, desc->static_sampler_count))
|
if (!write_dword(context, desc->static_sampler_count))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
samplers_offset_position = context->position;
|
samplers_offset_position = context->position;
|
||||||
if (!write_dword(context, 0xffffffff)) /* offset */
|
if (!write_dword(context, 0xffffffff)) /* offset */
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (!write_dword(context, desc->flags))
|
if (!write_dword(context, desc->flags))
|
||||||
return E_OUTOFMEMORY;
|
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if (FAILED(hr = shader_write_root_parameters(context, desc)))
|
if ((ret = shader_write_root_parameters(context, desc)) < 0)
|
||||||
return hr;
|
return ret;
|
||||||
|
|
||||||
context->data[samplers_offset_position] = get_chunk_offset(context);
|
context->data[samplers_offset_position] = get_chunk_offset(context);
|
||||||
return shader_write_static_samplers(context, desc);
|
return shader_write_static_samplers(context, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc *root_signature,
|
int vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_desc *root_signature,
|
||||||
enum vkd3d_root_signature_version version, struct vkd3d_shader_code *dxbc)
|
enum vkd3d_root_signature_version version, struct vkd3d_shader_code *dxbc)
|
||||||
{
|
{
|
||||||
struct root_signature_writer_context context;
|
struct root_signature_writer_context context;
|
||||||
size_t total_size, chunk_size;
|
size_t total_size, chunk_size;
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
TRACE("root_signature %p, version %#x, dxbc %p.\n", root_signature, version, dxbc);
|
TRACE("root_signature %p, version %#x, dxbc %p.\n", root_signature, version, dxbc);
|
||||||
|
|
||||||
if (version != VKD3D_ROOT_SIGNATURE_VERSION_1_0)
|
if (version != VKD3D_ROOT_SIGNATURE_VERSION_1_0)
|
||||||
{
|
{
|
||||||
FIXME("Root signature version %#x not supported.\n", version);
|
FIXME("Root signature version %#x not supported.\n", version);
|
||||||
return E_NOTIMPL;
|
return VKD3D_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(dxbc, 0, sizeof(*dxbc));
|
memset(dxbc, 0, sizeof(*dxbc));
|
||||||
memset(&context, 0, sizeof(context));
|
memset(&context, 0, sizeof(context));
|
||||||
if (FAILED(hr = shader_write_root_signature_header(&context)))
|
if ((ret = shader_write_root_signature_header(&context)) < 0)
|
||||||
{
|
{
|
||||||
vkd3d_free(context.data);
|
vkd3d_free(context.data);
|
||||||
return hr;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr = shader_write_root_signature(&context, root_signature)))
|
if ((ret = shader_write_root_signature(&context, root_signature)) < 0)
|
||||||
{
|
{
|
||||||
vkd3d_free(context.data);
|
vkd3d_free(context.data);
|
||||||
return hr;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
total_size = context.position * sizeof(DWORD);
|
total_size = context.position * sizeof(DWORD);
|
||||||
@ -2611,5 +2606,5 @@ HRESULT vkd3d_shader_serialize_root_signature(const struct vkd3d_root_signature_
|
|||||||
dxbc->code = context.data;
|
dxbc->code = context.data;
|
||||||
dxbc->size = total_size;
|
dxbc->size = total_size;
|
||||||
|
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
@ -5951,7 +5951,7 @@ static void vkd3d_dxbc_compiler_emit_output_setup_function(struct vkd3d_dxbc_com
|
|||||||
vkd3d_spirv_build_op_function_end(builder);
|
vkd3d_spirv_build_op_function_end(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
|
int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
|
||||||
struct vkd3d_shader_code *spirv)
|
struct vkd3d_shader_code *spirv)
|
||||||
{
|
{
|
||||||
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
||||||
@ -5965,7 +5965,7 @@ bool vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
|
|||||||
vkd3d_dxbc_compiler_emit_output_setup_function(compiler);
|
vkd3d_dxbc_compiler_emit_output_setup_function(compiler);
|
||||||
|
|
||||||
if (!vkd3d_spirv_compile_module(builder, spirv))
|
if (!vkd3d_spirv_compile_module(builder, spirv))
|
||||||
return false;
|
return VKD3D_ERROR;
|
||||||
|
|
||||||
if (TRACE_ON())
|
if (TRACE_ON())
|
||||||
{
|
{
|
||||||
@ -5973,7 +5973,7 @@ bool vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
|
|||||||
vkd3d_spirv_validate(spirv);
|
vkd3d_spirv_validate(spirv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler)
|
void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler)
|
||||||
|
@ -26,16 +26,16 @@ struct vkd3d_shader_parser
|
|||||||
const DWORD *ptr;
|
const DWORD *ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
static HRESULT vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser,
|
static int vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser,
|
||||||
const struct vkd3d_shader_code *dxbc)
|
const struct vkd3d_shader_code *dxbc)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_desc *shader_desc = &parser->shader_desc;
|
struct vkd3d_shader_desc *shader_desc = &parser->shader_desc;
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
if (FAILED(hr = shader_extract_from_dxbc(dxbc->code, dxbc->size, shader_desc)))
|
if ((ret = shader_extract_from_dxbc(dxbc->code, dxbc->size, shader_desc)) < 0)
|
||||||
{
|
{
|
||||||
WARN("Failed to extract shader, hr %#x.\n", hr);
|
WARN("Failed to extract shader, vkd3d result %d.\n", ret);
|
||||||
return hr;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(parser->data = shader_sm4_init(shader_desc->byte_code,
|
if (!(parser->data = shader_sm4_init(shader_desc->byte_code,
|
||||||
@ -43,11 +43,11 @@ static HRESULT vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser,
|
|||||||
{
|
{
|
||||||
WARN("Failed to initialize shader parser.\n");
|
WARN("Failed to initialize shader parser.\n");
|
||||||
free_shader_desc(shader_desc);
|
free_shader_desc(shader_desc);
|
||||||
return E_INVALIDARG;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
shader_sm4_read_header(parser->data, &parser->ptr, &parser->shader_version);
|
shader_sm4_read_header(parser->data, &parser->ptr, &parser->shader_version);
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser)
|
static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser)
|
||||||
@ -56,7 +56,7 @@ static void vkd3d_shader_parser_destroy(struct vkd3d_shader_parser *parser)
|
|||||||
free_shader_desc(&parser->shader_desc);
|
free_shader_desc(&parser->shader_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
|
int vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
|
||||||
struct vkd3d_shader_code *spirv, uint32_t compiler_options,
|
struct vkd3d_shader_code *spirv, uint32_t compiler_options,
|
||||||
const struct vkd3d_shader_interface *shader_interface)
|
const struct vkd3d_shader_interface *shader_interface)
|
||||||
{
|
{
|
||||||
@ -64,24 +64,23 @@ HRESULT vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
|
|||||||
struct vkd3d_dxbc_compiler *spirv_compiler;
|
struct vkd3d_dxbc_compiler *spirv_compiler;
|
||||||
struct vkd3d_shader_scan_info scan_info;
|
struct vkd3d_shader_scan_info scan_info;
|
||||||
struct vkd3d_shader_parser parser;
|
struct vkd3d_shader_parser parser;
|
||||||
HRESULT hr;
|
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
TRACE("dxbc {%p, %zu}, spirv %p, compiler_options %#x, shader_interface %p.\n",
|
TRACE("dxbc {%p, %zu}, spirv %p, compiler_options %#x, shader_interface %p.\n",
|
||||||
dxbc->code, dxbc->size, spirv, compiler_options, shader_interface);
|
dxbc->code, dxbc->size, spirv, compiler_options, shader_interface);
|
||||||
|
|
||||||
if (FAILED(hr = vkd3d_shader_scan_dxbc(dxbc, &scan_info)))
|
if ((ret = vkd3d_shader_scan_dxbc(dxbc, &scan_info)) < 0)
|
||||||
return hr;
|
return ret;
|
||||||
|
|
||||||
if (FAILED(hr = vkd3d_shader_parser_init(&parser, dxbc)))
|
if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0)
|
||||||
return hr;
|
return ret;
|
||||||
|
|
||||||
if (!(spirv_compiler = vkd3d_dxbc_compiler_create(&parser.shader_version,
|
if (!(spirv_compiler = vkd3d_dxbc_compiler_create(&parser.shader_version,
|
||||||
&parser.shader_desc, compiler_options, shader_interface, &scan_info)))
|
&parser.shader_desc, compiler_options, shader_interface, &scan_info)))
|
||||||
{
|
{
|
||||||
ERR("Failed to create DXBC compiler.\n");
|
ERR("Failed to create DXBC compiler.\n");
|
||||||
vkd3d_shader_parser_destroy(&parser);
|
vkd3d_shader_parser_destroy(&parser);
|
||||||
return hr;
|
return VKD3D_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!shader_sm4_is_end(parser.data, &parser.ptr))
|
while (!shader_sm4_is_end(parser.data, &parser.ptr))
|
||||||
@ -93,7 +92,7 @@ HRESULT vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
|
|||||||
WARN("Encountered unrecognized or invalid instruction.\n");
|
WARN("Encountered unrecognized or invalid instruction.\n");
|
||||||
vkd3d_dxbc_compiler_destroy(spirv_compiler);
|
vkd3d_dxbc_compiler_destroy(spirv_compiler);
|
||||||
vkd3d_shader_parser_destroy(&parser);
|
vkd3d_shader_parser_destroy(&parser);
|
||||||
return E_FAIL;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
vkd3d_dxbc_compiler_handle_instruction(spirv_compiler, &instruction);
|
vkd3d_dxbc_compiler_handle_instruction(spirv_compiler, &instruction);
|
||||||
@ -102,8 +101,7 @@ HRESULT vkd3d_shader_compile_dxbc(const struct vkd3d_shader_code *dxbc,
|
|||||||
ret = vkd3d_dxbc_compiler_generate_spirv(spirv_compiler, spirv);
|
ret = vkd3d_dxbc_compiler_generate_spirv(spirv_compiler, spirv);
|
||||||
vkd3d_dxbc_compiler_destroy(spirv_compiler);
|
vkd3d_dxbc_compiler_destroy(spirv_compiler);
|
||||||
vkd3d_shader_parser_destroy(&parser);
|
vkd3d_shader_parser_destroy(&parser);
|
||||||
|
return ret;
|
||||||
return ret ? S_OK : E_FAIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool vkd3d_shader_instruction_is_uav_read(const struct vkd3d_shader_instruction *instruction)
|
static bool vkd3d_shader_instruction_is_uav_read(const struct vkd3d_shader_instruction *instruction)
|
||||||
@ -160,17 +158,17 @@ static void vkd3d_shader_scan_handle_instruction(struct vkd3d_shader_scan_info *
|
|||||||
vkd3d_shader_scan_record_uav_counter(scan_info, &instruction->src[0].reg);
|
vkd3d_shader_scan_record_uav_counter(scan_info, &instruction->src[0].reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc,
|
int vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc,
|
||||||
struct vkd3d_shader_scan_info *scan_info)
|
struct vkd3d_shader_scan_info *scan_info)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_instruction instruction;
|
struct vkd3d_shader_instruction instruction;
|
||||||
struct vkd3d_shader_parser parser;
|
struct vkd3d_shader_parser parser;
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
TRACE("dxbc {%p, %zu}, scan_info %p.\n", dxbc->code, dxbc->size, scan_info);
|
TRACE("dxbc {%p, %zu}, scan_info %p.\n", dxbc->code, dxbc->size, scan_info);
|
||||||
|
|
||||||
if (FAILED(hr = vkd3d_shader_parser_init(&parser, dxbc)))
|
if ((ret = vkd3d_shader_parser_init(&parser, dxbc)) < 0)
|
||||||
return hr;
|
return ret;
|
||||||
|
|
||||||
memset(scan_info, 0, sizeof(*scan_info));
|
memset(scan_info, 0, sizeof(*scan_info));
|
||||||
|
|
||||||
@ -182,14 +180,14 @@ HRESULT vkd3d_shader_scan_dxbc(const struct vkd3d_shader_code *dxbc,
|
|||||||
{
|
{
|
||||||
WARN("Encountered unrecognized or invalid instruction.\n");
|
WARN("Encountered unrecognized or invalid instruction.\n");
|
||||||
vkd3d_shader_parser_destroy(&parser);
|
vkd3d_shader_parser_destroy(&parser);
|
||||||
return E_FAIL;
|
return VKD3D_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
vkd3d_shader_scan_handle_instruction(scan_info, &instruction);
|
vkd3d_shader_scan_handle_instruction(scan_info, &instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
vkd3d_shader_parser_destroy(&parser);
|
vkd3d_shader_parser_destroy(&parser);
|
||||||
return S_OK;
|
return VKD3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *shader_code)
|
void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *shader_code)
|
||||||
@ -217,7 +215,7 @@ void vkd3d_shader_free_root_signature(struct vkd3d_root_signature_desc *root_sig
|
|||||||
memset(root_signature, 0, sizeof(*root_signature));
|
memset(root_signature, 0, sizeof(*root_signature));
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
|
int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
|
||||||
struct vkd3d_shader_signature *signature)
|
struct vkd3d_shader_signature *signature)
|
||||||
{
|
{
|
||||||
TRACE("dxbc {%p, %zu}, signature %p.\n", dxbc->code, dxbc->size, signature);
|
TRACE("dxbc {%p, %zu}, signature %p.\n", dxbc->code, dxbc->size, signature);
|
||||||
|
@ -768,11 +768,11 @@ void shader_sm4_read_instruction(void *data, const DWORD **ptr,
|
|||||||
struct vkd3d_shader_instruction *ins) DECLSPEC_HIDDEN;
|
struct vkd3d_shader_instruction *ins) DECLSPEC_HIDDEN;
|
||||||
BOOL shader_sm4_is_end(void *data, const DWORD **ptr) DECLSPEC_HIDDEN;
|
BOOL shader_sm4_is_end(void *data, const DWORD **ptr) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length,
|
int shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length,
|
||||||
struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
|
struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
|
||||||
void free_shader_desc(struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
|
void free_shader_desc(struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
HRESULT shader_parse_input_signature(const void *dxbc, SIZE_T dxbc_length,
|
int shader_parse_input_signature(const void *dxbc, SIZE_T dxbc_length,
|
||||||
struct vkd3d_shader_signature *signature) DECLSPEC_HIDDEN;
|
struct vkd3d_shader_signature *signature) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
struct vkd3d_dxbc_compiler;
|
struct vkd3d_dxbc_compiler;
|
||||||
@ -783,7 +783,7 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader
|
|||||||
const struct vkd3d_shader_scan_info *scan_info) DECLSPEC_HIDDEN;
|
const struct vkd3d_shader_scan_info *scan_info) DECLSPEC_HIDDEN;
|
||||||
void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler,
|
void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler,
|
||||||
const struct vkd3d_shader_instruction *instruction) DECLSPEC_HIDDEN;
|
const struct vkd3d_shader_instruction *instruction) DECLSPEC_HIDDEN;
|
||||||
bool vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
|
int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
|
||||||
struct vkd3d_shader_code *spirv) DECLSPEC_HIDDEN;
|
struct vkd3d_shader_code *spirv) DECLSPEC_HIDDEN;
|
||||||
void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler) DECLSPEC_HIDDEN;
|
void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
@ -1013,11 +1013,12 @@ HRESULT d3d12_root_signature_create(struct d3d12_device *device,
|
|||||||
} root_signature_desc;
|
} root_signature_desc;
|
||||||
struct d3d12_root_signature *object;
|
struct d3d12_root_signature *object;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (FAILED(hr = vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc.vkd3d)))
|
if ((ret = vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc.vkd3d)) < 0)
|
||||||
{
|
{
|
||||||
WARN("Failed to parse root signature, hr %#x.\n", hr);
|
WARN("Failed to parse root signature, vkd3d result %d.\n", ret);
|
||||||
return hr;
|
return hresult_from_vkd3d_result(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(object = vkd3d_malloc(sizeof(*object))))
|
if (!(object = vkd3d_malloc(sizeof(*object))))
|
||||||
@ -1269,7 +1270,7 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
|
|||||||
struct VkShaderModuleCreateInfo shader_desc;
|
struct VkShaderModuleCreateInfo shader_desc;
|
||||||
struct vkd3d_shader_code spirv = {};
|
struct vkd3d_shader_code spirv = {};
|
||||||
VkResult vr;
|
VkResult vr;
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
stage_desc->sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
stage_desc->sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||||
stage_desc->pNext = NULL;
|
stage_desc->pNext = NULL;
|
||||||
@ -1283,10 +1284,10 @@ static HRESULT create_shader_stage(struct d3d12_device *device,
|
|||||||
shader_desc.flags = 0;
|
shader_desc.flags = 0;
|
||||||
|
|
||||||
dump_shader_stage(stage, code->pShaderBytecode, code->BytecodeLength);
|
dump_shader_stage(stage, code->pShaderBytecode, code->BytecodeLength);
|
||||||
if (FAILED(hr = vkd3d_shader_compile_dxbc(&dxbc, &spirv, 0, shader_interface)))
|
if ((ret = vkd3d_shader_compile_dxbc(&dxbc, &spirv, 0, shader_interface)) < 0)
|
||||||
{
|
{
|
||||||
WARN("Failed to compile shader, hr %#x.\n", hr);
|
WARN("Failed to compile shader, vkd3d result %d.\n", ret);
|
||||||
return hr;
|
return hresult_from_vkd3d_result(ret);
|
||||||
}
|
}
|
||||||
shader_desc.codeSize = spirv.size;
|
shader_desc.codeSize = spirv.size;
|
||||||
shader_desc.pCode = spirv.code;
|
shader_desc.pCode = spirv.code;
|
||||||
@ -1389,6 +1390,7 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st
|
|||||||
struct vkd3d_shader_code dxbc;
|
struct vkd3d_shader_code dxbc;
|
||||||
VkResult vr;
|
VkResult vr;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
int ret;
|
||||||
|
|
||||||
state->ID3D12PipelineState_iface.lpVtbl = &d3d12_pipeline_state_vtbl;
|
state->ID3D12PipelineState_iface.lpVtbl = &d3d12_pipeline_state_vtbl;
|
||||||
state->refcount = 1;
|
state->refcount = 1;
|
||||||
@ -1406,10 +1408,10 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st
|
|||||||
|
|
||||||
dxbc.code = desc->CS.pShaderBytecode;
|
dxbc.code = desc->CS.pShaderBytecode;
|
||||||
dxbc.size = desc->CS.BytecodeLength;
|
dxbc.size = desc->CS.BytecodeLength;
|
||||||
if (FAILED(hr = vkd3d_shader_scan_dxbc(&dxbc, &shader_info)))
|
if ((ret = vkd3d_shader_scan_dxbc(&dxbc, &shader_info)) < 0)
|
||||||
{
|
{
|
||||||
WARN("Failed to scan shader bytecode, hr %#x.\n", hr);
|
WARN("Failed to scan shader bytecode, vkd3d result %d.\n", ret);
|
||||||
return hr;
|
return hresult_from_vkd3d_result(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr = d3d12_pipeline_state_init_compute_uav_counters(state,
|
if (FAILED(hr = d3d12_pipeline_state_init_compute_uav_counters(state,
|
||||||
@ -1802,6 +1804,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
|
|||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
VkResult vr;
|
VkResult vr;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
int ret;
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
@ -1849,10 +1852,11 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
|
|||||||
if (!b->pShaderBytecode)
|
if (!b->pShaderBytecode)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (FAILED(hr = vkd3d_shader_scan_dxbc(&dxbc, &shader_info)))
|
if ((ret = vkd3d_shader_scan_dxbc(&dxbc, &shader_info)) < 0)
|
||||||
{
|
{
|
||||||
WARN("Failed to scan shader bytecode, stage %#x, hr %#x.\n", shader_stages[i].stage, hr);
|
WARN("Failed to scan shader bytecode, stage %#x, vkd3d result %d.\n",
|
||||||
hr = E_FAIL;
|
shader_stages[i].stage, ret);
|
||||||
|
hr = hresult_from_vkd3d_result(ret);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (shader_info.uav_counter_mask)
|
if (shader_info.uav_counter_mask)
|
||||||
@ -1863,8 +1867,11 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (shader_stages[i].stage == VK_SHADER_STAGE_VERTEX_BIT
|
if (shader_stages[i].stage == VK_SHADER_STAGE_VERTEX_BIT
|
||||||
&& FAILED(hr = vkd3d_shader_parse_input_signature(&dxbc, &input_signature)))
|
&& (ret = vkd3d_shader_parse_input_signature(&dxbc, &input_signature)) < 0)
|
||||||
|
{
|
||||||
|
hr = hresult_from_vkd3d_result(ret);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
++graphics->stage_count;
|
++graphics->stage_count;
|
||||||
}
|
}
|
||||||
|
@ -351,6 +351,26 @@ HRESULT hresult_from_vk_result(VkResult vr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT hresult_from_vkd3d_result(int vkd3d_result)
|
||||||
|
{
|
||||||
|
switch (vkd3d_result)
|
||||||
|
{
|
||||||
|
case VKD3D_OK:
|
||||||
|
return S_OK;
|
||||||
|
case VKD3D_ERROR:
|
||||||
|
return E_FAIL;
|
||||||
|
case VKD3D_ERROR_OUT_OF_MEMORY:
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
case VKD3D_ERROR_INVALID_ARGUMENT:
|
||||||
|
return E_INVALIDARG;
|
||||||
|
case VKD3D_ERROR_NOT_IMPLEMENTED:
|
||||||
|
return E_NOTIMPL;
|
||||||
|
default:
|
||||||
|
FIXME("Unhandled vkd3d result %d.\n", vkd3d_result);
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define LOAD_GLOBAL_PFN(name) \
|
#define LOAD_GLOBAL_PFN(name) \
|
||||||
if (!(procs->name = (void *)vkGetInstanceProcAddr(NULL, #name))) \
|
if (!(procs->name = (void *)vkGetInstanceProcAddr(NULL, #name))) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -162,15 +162,15 @@ static const struct ID3D12RootSignatureDeserializerVtbl d3d12_root_signature_des
|
|||||||
static HRESULT d3d12_root_signature_deserializer_init(struct d3d12_root_signature_deserializer *deserializer,
|
static HRESULT d3d12_root_signature_deserializer_init(struct d3d12_root_signature_deserializer *deserializer,
|
||||||
const struct vkd3d_shader_code *dxbc)
|
const struct vkd3d_shader_code *dxbc)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
int ret;
|
||||||
|
|
||||||
deserializer->ID3D12RootSignatureDeserializer_iface.lpVtbl = &d3d12_root_signature_deserializer_vtbl;
|
deserializer->ID3D12RootSignatureDeserializer_iface.lpVtbl = &d3d12_root_signature_deserializer_vtbl;
|
||||||
deserializer->refcount = 1;
|
deserializer->refcount = 1;
|
||||||
|
|
||||||
if (FAILED(hr = vkd3d_shader_parse_root_signature(dxbc, &deserializer->desc.vkd3d)))
|
if ((ret = vkd3d_shader_parse_root_signature(dxbc, &deserializer->desc.vkd3d)) < 0)
|
||||||
{
|
{
|
||||||
WARN("Failed to parse root signature, hr %#x.\n", hr);
|
WARN("Failed to parse root signature, vkd3d result %d.\n", ret);
|
||||||
return hr;
|
return hresult_from_vkd3d_result(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
@ -319,6 +319,7 @@ HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *root_sig
|
|||||||
struct vkd3d_shader_code dxbc;
|
struct vkd3d_shader_code dxbc;
|
||||||
struct d3d_blob *blob_object;
|
struct d3d_blob *blob_object;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
int ret;
|
||||||
|
|
||||||
TRACE("root_signature_desc %p, version %#x, blob %p, error_blob %p.\n",
|
TRACE("root_signature_desc %p, version %#x, blob %p, error_blob %p.\n",
|
||||||
root_signature_desc, version, blob, error_blob);
|
root_signature_desc, version, blob, error_blob);
|
||||||
@ -335,12 +336,12 @@ HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *root_sig
|
|||||||
*error_blob = NULL;
|
*error_blob = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr = vkd3d_shader_serialize_root_signature(
|
if ((ret = vkd3d_shader_serialize_root_signature(
|
||||||
(const struct vkd3d_root_signature_desc *)root_signature_desc,
|
(const struct vkd3d_root_signature_desc *)root_signature_desc,
|
||||||
(enum vkd3d_root_signature_version)version, &dxbc)))
|
(enum vkd3d_root_signature_version)version, &dxbc)) < 0)
|
||||||
{
|
{
|
||||||
WARN("Failed to serialize root signature, hr %#x.\n", hr);
|
WARN("Failed to serialize root signature, vkd3d result %d.\n", ret);
|
||||||
return hr;
|
return hresult_from_vkd3d_result(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr = d3d_blob_create((void *)dxbc.code, dxbc.size, &blob_object)))
|
if (FAILED(hr = d3d_blob_create((void *)dxbc.code, dxbc.size, &blob_object)))
|
||||||
|
@ -767,6 +767,7 @@ const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags) DECLSPEC
|
|||||||
const char *debug_vk_queue_flags(VkQueueFlags flags) DECLSPEC_HIDDEN;
|
const char *debug_vk_queue_flags(VkQueueFlags flags) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
HRESULT hresult_from_vk_result(VkResult vr) DECLSPEC_HIDDEN;
|
HRESULT hresult_from_vk_result(VkResult vr) DECLSPEC_HIDDEN;
|
||||||
|
HRESULT hresult_from_vkd3d_result(int vkd3d_result) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
HRESULT vkd3d_load_vk_global_procs(struct vkd3d_vk_global_procs *procs,
|
HRESULT vkd3d_load_vk_global_procs(struct vkd3d_vk_global_procs *procs,
|
||||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr) DECLSPEC_HIDDEN;
|
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr) DECLSPEC_HIDDEN;
|
||||||
|
Loading…
Reference in New Issue
Block a user