Commit eccff1ad authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Implement Vulkan draws.

parent a282a8e7
......@@ -859,6 +859,8 @@ static void *adapter_vk_map_bo_address(struct wined3d_context *context,
return NULL;
}
wined3d_context_vk_end_current_render_pass(context_vk);
vk_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
vk_barrier.pNext = NULL;
vk_barrier.srcAccessMask = vk_access_mask_from_buffer_usage(bo->usage);
......@@ -956,6 +958,8 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context,
return;
}
wined3d_context_vk_end_current_render_pass(context_vk);
src_access_mask = vk_access_mask_from_buffer_usage(src_bo->usage);
dst_access_mask = vk_access_mask_from_buffer_usage(dst_bo->usage);
......@@ -1517,7 +1521,36 @@ static void adapter_vk_flush_context(struct wined3d_context *context)
static void adapter_vk_draw_primitive(struct wined3d_device *device,
const struct wined3d_state *state, const struct wined3d_draw_parameters *parameters)
{
FIXME("device %p, state %p, parameters %p.\n", device, state, parameters);
const struct wined3d_vk_info *vk_info;
struct wined3d_context_vk *context_vk;
VkCommandBuffer vk_command_buffer;
uint32_t instance_count;
TRACE("device %p, state %p, parameters %p.\n", device, state, parameters);
context_vk = wined3d_context_vk(context_acquire(device, NULL, 0));
vk_info = context_vk->vk_info;
if (!(vk_command_buffer = wined3d_context_vk_apply_draw_state(context_vk, state)))
{
ERR("Failed to apply draw state.\n");
context_release(&context_vk->c);
return;
}
if (!parameters->indirect && !parameters->indexed)
{
instance_count = parameters->u.direct.instance_count;
if (context_vk->c.instance_count)
instance_count = context_vk->c.instance_count;
if (!instance_count)
instance_count = 1;
VK_CALL(vkCmdDraw(vk_command_buffer, parameters->u.direct.index_count, instance_count,
parameters->u.direct.start_idx, parameters->u.direct.start_instance));
}
context_release(&context_vk->c);
}
static void adapter_vk_dispatch_compute(struct wined3d_device *device,
......
......@@ -4367,15 +4367,6 @@ static GLenum gl_tfb_primitive_type_from_d3d(enum wined3d_primitive_type primiti
}
}
static unsigned int get_render_target_writemask(const struct wined3d_blend_state *state, unsigned int index)
{
if (!state)
return 0xf;
if (!state->desc.independent)
index = 0;
return state->desc.rt[index].writemask;
}
/* Routine common to the draw primitive and draw indexed primitive routines */
void draw_primitive(struct wined3d_device *device, const struct wined3d_state *state,
const struct wined3d_draw_parameters *parameters)
......@@ -4433,7 +4424,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
if (!(rtv = fb->render_targets[i]) || rtv->format->id == WINED3DFMT_NULL)
continue;
if (get_render_target_writemask(state->blend_state, i))
if (wined3d_blend_state_get_writemask(state->blend_state, i))
{
wined3d_rendertarget_view_load_location(rtv, context, rtv->resource->draw_binding);
wined3d_rendertarget_view_invalidate_location(rtv, ~rtv->resource->draw_binding);
......
......@@ -6082,18 +6082,6 @@ static void vk_blitter_destroy(struct wined3d_blitter *blitter, struct wined3d_c
heap_free(blitter);
}
static inline VkImageView wined3d_rendertarget_view_vk_get_image_view(struct wined3d_rendertarget_view_vk *rtv_vk,
struct wined3d_context_vk *context_vk)
{
struct wined3d_texture_vk *texture_vk;
if (rtv_vk->vk_image_view)
return rtv_vk->vk_image_view;
texture_vk = wined3d_texture_vk(wined3d_texture_from_resource(rtv_vk->v.resource));
return wined3d_texture_vk_get_default_image_info(texture_vk, context_vk)->imageView;
}
static void vk_blitter_clear_rendertargets(struct wined3d_context_vk *context_vk, unsigned int rt_count,
const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects, const RECT *draw_rect,
uint32_t flags, const struct wined3d_color *colour, float depth, unsigned int stencil)
......@@ -6225,6 +6213,8 @@ static void vk_blitter_clear_rendertargets(struct wined3d_context_vk *context_vk
begin_desc.clearValueCount = attachment_count;
begin_desc.pClearValues = clear_values;
wined3d_context_vk_end_current_render_pass(context_vk);
for (i = 0; i < rect_count; ++i)
{
r.left = max(clear_rects[i].left, draw_rect->left);
......
......@@ -1547,6 +1547,7 @@ static void wined3d_unordered_access_view_vk_cs_init(void *object)
return;
}
wined3d_context_vk_end_current_render_pass(context_vk);
VK_CALL(vkCmdFillBuffer(wined3d_context_vk_get_command_buffer(context_vk),
uav_vk->counter_bo.vk_buffer, uav_vk->counter_bo.buffer_offset, sizeof(uint32_t), 0));
wined3d_context_vk_reference_bo(context_vk, &uav_vk->counter_bo);
......
......@@ -2362,6 +2362,15 @@ struct wined3d_context_vk
struct
{
VkShaderModule vk_modules[WINED3D_SHADER_TYPE_GRAPHICS_COUNT];
VkPipeline vk_pipeline;
VkPipelineLayout vk_pipeline_layout;
VkDescriptorSetLayout vk_set_layout;
struct wined3d_shader_resource_bindings bindings;
} graphics;
struct
{
VkPipeline vk_pipeline;
VkPipelineLayout vk_pipeline_layout;
VkDescriptorSetLayout vk_set_layout;
......@@ -2381,6 +2390,8 @@ struct wined3d_context_vk
struct wined3d_shader_descriptor_writes_vk descriptor_writes;
VkFramebuffer vk_framebuffer;
VkRenderPass vk_render_pass;
VkDescriptorPool vk_descriptor_pool;
struct wined3d_retired_objects_vk retired;
......@@ -2400,6 +2411,8 @@ VkDeviceMemory wined3d_context_vk_allocate_vram_chunk_memory(struct wined3d_cont
unsigned int pool, size_t size) DECLSPEC_HIDDEN;
VkCommandBuffer wined3d_context_vk_apply_compute_state(struct wined3d_context_vk *context_vk,
const struct wined3d_state *state, struct wined3d_buffer_vk *indirect_vk) DECLSPEC_HIDDEN;
VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *context_vk,
const struct wined3d_state *state) DECLSPEC_HIDDEN;
void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size,
VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
......@@ -2419,6 +2432,7 @@ void wined3d_context_vk_destroy_memory(struct wined3d_context_vk *context_vk,
VkDeviceMemory vk_memory, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
void wined3d_context_vk_destroy_sampler(struct wined3d_context_vk *context_vk,
VkSampler vk_sampler, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
void wined3d_context_vk_end_current_render_pass(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
struct wined3d_pipeline_layout_vk *wined3d_context_vk_get_pipeline_layout(struct wined3d_context_vk *context_vk,
VkDescriptorSetLayoutBinding *bindings, SIZE_T binding_count) DECLSPEC_HIDDEN;
......@@ -3387,6 +3401,16 @@ struct wined3d_blend_state
struct wine_rb_entry entry;
};
static inline unsigned int wined3d_blend_state_get_writemask(const struct wined3d_blend_state *state,
unsigned int index)
{
if (!state)
return 0xf;
if (!state->desc.independent)
index = 0;
return state->desc.rt[index].writemask;
}
struct wined3d_rasterizer_state
{
LONG refcount;
......@@ -4704,6 +4728,18 @@ static inline struct wined3d_rendertarget_view_vk *wined3d_rendertarget_view_vk(
return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_vk, v);
}
static inline VkImageView wined3d_rendertarget_view_vk_get_image_view(struct wined3d_rendertarget_view_vk *rtv_vk,
struct wined3d_context_vk *context_vk)
{
struct wined3d_texture_vk *texture_vk;
if (rtv_vk->vk_image_view)
return rtv_vk->vk_image_view;
texture_vk = wined3d_texture_vk(wined3d_texture_from_resource(rtv_vk->v.resource));
return wined3d_texture_vk_get_default_image_info(texture_vk, context_vk)->imageView;
}
HRESULT wined3d_rendertarget_view_vk_init(struct wined3d_rendertarget_view_vk *view_vk,
const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
......
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