Commit fa410970 authored by Jan Sikorski's avatar Jan Sikorski Committed by Alexandre Julliard

wined3d: Implement UAV clears on the Vulkan backend.

Based on the vkd3d implementation. Signed-off-by: 's avatarJan Sikorski <jsikorski@codeweavers.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent bacd0301
......@@ -719,6 +719,8 @@ static HRESULT adapter_vk_init_3d(struct wined3d_device *device)
wined3d_device_create_default_samplers(device, &context_vk->c);
wined3d_device_vk_create_null_resources(device_vk, context_vk);
wined3d_device_vk_create_null_views(device_vk, context_vk);
if (device->adapter->d3d_info.feature_level >= WINED3D_FEATURE_LEVEL_11)
wined3d_device_vk_uav_clear_state_init(device_vk);
return WINED3D_OK;
}
......@@ -740,6 +742,8 @@ static void adapter_vk_uninit_3d_cs(void *object)
device->shader_backend->shader_destroy(shader);
}
if (device->adapter->d3d_info.feature_level >= WINED3D_FEATURE_LEVEL_11)
wined3d_device_vk_uav_clear_state_cleanup(device_vk);
device->blitter->ops->blitter_destroy(device->blitter, NULL);
device->shader_backend->shader_free_private(device, &context_vk->c);
wined3d_device_vk_destroy_null_views(device_vk, context_vk);
......@@ -1037,7 +1041,7 @@ static void adapter_vk_unmap_bo_address(struct wined3d_context *context,
wined3d_bo_vk_unmap(bo, context_vk);
}
static void adapter_vk_copy_bo_address(struct wined3d_context *context,
void adapter_vk_copy_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size)
{
struct wined3d_context_vk *context_vk = wined3d_context_vk(context);
......
......@@ -5637,6 +5637,13 @@ static BOOL shader_arb_has_ffp_proj_control(void *shader_priv)
static void shader_arb_precompile(void *shader_priv, struct wined3d_shader *shader) {}
static uint64_t shader_arb_shader_compile(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc,
enum wined3d_shader_type shader_type)
{
ERR("Not implemented.\n");
return 0;
}
const struct wined3d_shader_backend_ops arb_program_shader_backend =
{
shader_arb_handle_instruction,
......@@ -5656,6 +5663,7 @@ const struct wined3d_shader_backend_ops arb_program_shader_backend =
shader_arb_get_caps,
shader_arb_color_fixup_supported,
shader_arb_has_ffp_proj_control,
shader_arb_shader_compile,
};
/* ARB_fragment_program fixed function pipeline replacement definitions */
......
......@@ -2558,7 +2558,7 @@ static VkResult wined3d_context_vk_create_vk_descriptor_pool(struct wined3d_devi
return vr;
}
static VkResult wined3d_context_vk_create_vk_descriptor_set(struct wined3d_context_vk *context_vk,
VkResult wined3d_context_vk_create_vk_descriptor_set(struct wined3d_context_vk *context_vk,
VkDescriptorSetLayout vk_set_layout, VkDescriptorSet *vk_descriptor_set)
{
struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
......
......@@ -11490,6 +11490,13 @@ static BOOL shader_glsl_has_ffp_proj_control(void *shader_priv)
return priv->ffp_proj_control;
}
static uint64_t shader_glsl_shader_compile(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc,
enum wined3d_shader_type shader_type)
{
ERR("Not implemented.\n");
return 0;
}
const struct wined3d_shader_backend_ops glsl_shader_backend =
{
shader_glsl_handle_instruction,
......@@ -11509,6 +11516,7 @@ const struct wined3d_shader_backend_ops glsl_shader_backend =
shader_glsl_get_caps,
shader_glsl_color_fixup_supported,
shader_glsl_has_ffp_proj_control,
shader_glsl_shader_compile,
};
static void glsl_vertex_pipe_vp_enable(const struct wined3d_context *context, BOOL enable) {}
......
......@@ -3279,6 +3279,12 @@ static BOOL shader_none_has_ffp_proj_control(void *shader_priv)
return priv->ffp_proj_control;
}
static uint64_t shader_none_shader_compile(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc,
enum wined3d_shader_type shader_type)
{
return 0;
}
const struct wined3d_shader_backend_ops none_shader_backend =
{
shader_none_handle_instruction,
......@@ -3298,6 +3304,7 @@ const struct wined3d_shader_backend_ops none_shader_backend =
shader_none_get_caps,
shader_none_color_fixup_supported,
shader_none_has_ffp_proj_control,
shader_none_shader_compile,
};
static unsigned int shader_max_version_from_feature_level(enum wined3d_feature_level level)
......
......@@ -303,7 +303,7 @@ static void shader_spirv_init_shader_interface_vk(struct wined3d_shader_spirv_sh
iface->vkd3d_interface.uav_counter_count = b->uav_counter_count;
}
static VkShaderModule shader_spirv_compile(struct wined3d_context_vk *context_vk,
static VkShaderModule shader_spirv_compile_shader(struct wined3d_context_vk *context_vk,
const struct wined3d_shader_desc *shader_desc, enum wined3d_shader_type shader_type,
const struct shader_spirv_compile_arguments *args, const struct shader_spirv_resource_bindings *bindings,
const struct wined3d_stream_output_desc *so_desc)
......@@ -416,7 +416,7 @@ static struct shader_spirv_graphics_program_variant_vk *shader_spirv_find_graphi
shader_desc.byte_code = shader->byte_code;
shader_desc.byte_code_size = shader->byte_code_size;
if (!(variant_vk->vk_module = shader_spirv_compile(context_vk, &shader_desc, shader_type, &args,
if (!(variant_vk->vk_module = shader_spirv_compile_shader(context_vk, &shader_desc, shader_type, &args,
bindings, so_desc)))
return NULL;
++program_vk->variant_count;
......@@ -445,7 +445,7 @@ static struct shader_spirv_compute_program_vk *shader_spirv_find_compute_program
shader_desc.byte_code = shader->byte_code;
shader_desc.byte_code_size = shader->byte_code_size;
if (!(program->vk_module = shader_spirv_compile(context_vk, &shader_desc, WINED3D_SHADER_TYPE_COMPUTE,
if (!(program->vk_module = shader_spirv_compile_shader(context_vk, &shader_desc, WINED3D_SHADER_TYPE_COMPUTE,
NULL, bindings, NULL)))
return NULL;
......@@ -1126,6 +1126,13 @@ static BOOL shader_spirv_has_ffp_proj_control(void *shader_priv)
return priv->ffp_proj_control;
}
static uint64_t shader_spirv_compile(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc,
enum wined3d_shader_type shader_type)
{
struct shader_spirv_resource_bindings bindings = {0};
return (uint64_t)shader_spirv_compile_shader(wined3d_context_vk(context), shader_desc, shader_type, NULL, &bindings, NULL);
}
static const struct wined3d_shader_backend_ops spirv_shader_backend_vk =
{
.shader_handle_instruction = shader_spirv_handle_instruction,
......@@ -1145,6 +1152,7 @@ static const struct wined3d_shader_backend_ops spirv_shader_backend_vk =
.shader_get_caps = shader_spirv_get_caps,
.shader_color_fixup_supported = shader_spirv_color_fixup_supported,
.shader_has_ffp_proj_control = shader_spirv_has_ffp_proj_control,
.shader_compile = shader_spirv_compile,
};
const struct wined3d_shader_backend_ops *wined3d_spirv_shader_backend_init_vk(void)
......
......@@ -174,19 +174,6 @@ static const struct wined3d_format_channels formats[] =
{WINED3DFMT_B8G8R8X8_TYPELESS, 8, 8, 8, 0, 16, 8, 0, 0, 4, 0, 0},
};
enum wined3d_channel_type
{
WINED3D_CHANNEL_TYPE_NONE,
WINED3D_CHANNEL_TYPE_UNORM,
WINED3D_CHANNEL_TYPE_SNORM,
WINED3D_CHANNEL_TYPE_UINT,
WINED3D_CHANNEL_TYPE_SINT,
WINED3D_CHANNEL_TYPE_FLOAT,
WINED3D_CHANNEL_TYPE_DEPTH,
WINED3D_CHANNEL_TYPE_STENCIL,
WINED3D_CHANNEL_TYPE_UNUSED,
};
struct wined3d_typed_format_info
{
enum wined3d_format_id id;
......@@ -4396,6 +4383,22 @@ const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *ad
return format;
}
enum wined3d_format_id wined3d_get_typed_format_id(const struct wined3d_adapter *adapter,
const struct wined3d_format *format, enum wined3d_channel_type channel_type)
{
const struct wined3d_typed_format_info *info;
uint32_t i;
for (i = 0; i < ARRAY_SIZE(typed_formats); ++i)
{
info = &typed_formats[i];
if (info->typeless_id == format->typeless_id && map_channel_type(info->channels[0]) == channel_type)
return info->id;
}
return WINED3DFMT_UNKNOWN;
}
BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
enum wined3d_format_id view_format_id)
{
......
......@@ -1524,6 +1524,8 @@ struct wined3d_shader_backend_ops
void (*shader_get_caps)(const struct wined3d_adapter *adapter, struct shader_caps *caps);
BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
BOOL (*shader_has_ffp_proj_control)(void *shader_priv);
uint64_t (*shader_compile)(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc,
enum wined3d_shader_type shader_type);
};
extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN;
......@@ -2675,6 +2677,8 @@ void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context
unsigned int wait_semaphore_count, const VkSemaphore *wait_semaphores, const VkPipelineStageFlags *wait_stages,
unsigned int signal_semaphore_count, const VkSemaphore *signal_semaphores) DECLSPEC_HIDDEN;
void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk *context_vk, uint64_t id) DECLSPEC_HIDDEN;
VkResult wined3d_context_vk_create_vk_descriptor_set(struct wined3d_context_vk *context_vk,
VkDescriptorSetLayout vk_set_layout, VkDescriptorSet *vk_descriptor_set) DECLSPEC_HIDDEN;
typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id);
......@@ -3483,6 +3487,8 @@ struct wined3d_adapter *wined3d_adapter_vk_create(unsigned int ordinal,
unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
unsigned int wined3d_adapter_vk_get_memory_type_index(const struct wined3d_adapter_vk *adapter_vk,
uint32_t memory_type_mask, VkMemoryPropertyFlags flags) DECLSPEC_HIDDEN;
void adapter_vk_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst,
const struct wined3d_bo_address *src, size_t size) DECLSPEC_HIDDEN;
struct wined3d_caps_gl_ctx
{
......@@ -4026,6 +4032,32 @@ void wined3d_allocator_cleanup(struct wined3d_allocator *allocator) DECLSPEC_HID
bool wined3d_allocator_init(struct wined3d_allocator *allocator,
size_t pool_count, const struct wined3d_allocator_ops *allocator_ops) DECLSPEC_HIDDEN;
struct wined3d_uav_clear_pipelines_vk
{
VkPipeline buffer;
VkPipeline image_1d;
VkPipeline image_1d_array;
VkPipeline image_2d;
VkPipeline image_2d_array;
VkPipeline image_3d;
};
struct wined3d_uav_clear_state_vk
{
struct wined3d_uav_clear_pipelines_vk float_pipelines;
struct wined3d_uav_clear_pipelines_vk uint_pipelines;
struct wined3d_shader_thread_group_size buffer_group_size;
struct wined3d_shader_thread_group_size image_1d_group_size;
struct wined3d_shader_thread_group_size image_1d_array_group_size;
struct wined3d_shader_thread_group_size image_2d_group_size;
struct wined3d_shader_thread_group_size image_2d_array_group_size;
struct wined3d_shader_thread_group_size image_3d_group_size;
struct wined3d_pipeline_layout_vk *image_layout;
struct wined3d_pipeline_layout_vk *buffer_layout;
};
struct wined3d_device_vk
{
struct wined3d_device d;
......@@ -4043,6 +4075,8 @@ struct wined3d_device_vk
struct wined3d_null_views_vk null_views_vk;
struct wined3d_allocator allocator;
struct wined3d_uav_clear_state_vk uav_clear_state;
};
static inline struct wined3d_device_vk *wined3d_device_vk(struct wined3d_device *device)
......@@ -4059,6 +4093,9 @@ void wined3d_device_vk_destroy_null_resources(struct wined3d_device_vk *device_v
void wined3d_device_vk_destroy_null_views(struct wined3d_device_vk *device_vk,
struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
void wined3d_device_vk_uav_clear_state_init(struct wined3d_device_vk *device_vk) DECLSPEC_HIDDEN;
void wined3d_device_vk_uav_clear_state_cleanup(struct wined3d_device_vk *device_vk) DECLSPEC_HIDDEN;
static inline float wined3d_alpha_ref(const struct wined3d_state *state)
{
return (state->render_states[WINED3D_RS_ALPHAREF] & 0xff) / 255.0f;
......@@ -5820,6 +5857,19 @@ struct wined3d_color_key_conversion
unsigned int width, unsigned int height, const struct wined3d_color_key *colour_key);
};
enum wined3d_channel_type
{
WINED3D_CHANNEL_TYPE_NONE,
WINED3D_CHANNEL_TYPE_UNORM,
WINED3D_CHANNEL_TYPE_SNORM,
WINED3D_CHANNEL_TYPE_UINT,
WINED3D_CHANNEL_TYPE_SINT,
WINED3D_CHANNEL_TYPE_FLOAT,
WINED3D_CHANNEL_TYPE_DEPTH,
WINED3D_CHANNEL_TYPE_STENCIL,
WINED3D_CHANNEL_TYPE_UNUSED,
};
struct wined3d_format
{
enum wined3d_format_id id;
......@@ -5865,6 +5915,8 @@ struct wined3d_format
const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter,
enum wined3d_format_id format_id, unsigned int bind_flags) DECLSPEC_HIDDEN;
enum wined3d_format_id wined3d_get_typed_format_id(const struct wined3d_adapter *adapter,
const struct wined3d_format *format, enum wined3d_channel_type channel_type) DECLSPEC_HIDDEN;
void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
UINT wined3d_format_calculate_size(const struct wined3d_format *format,
......
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