This is a part of a larger effort to reorganize wined3d a bit so that backend functions are fully quarantined into their own files. There are a few advantages to this:
* We avoid including (large) headers in files that don't need them.
* This has helped me find functions that are currently incorrectly tied to backends [e.g. wined3d_texture_update_desc(), wined3d_texture_set_lod()].
* This may also help find code (struct members, helpers, etc.) which should be made local to a backend.
* I find that this aids the reader in logically separating wined3d code. For some time the wined3d code base has resisted modularity of compilation units, simply on the grounds that this is not necessary. I find files comprising several thousand lines to be a bit unwieldy, however, and that comprehension and navigation are eased when drawing physical lines even when such separation was already obvious. It also can be nice for compilation speed.
There are a few steps to this:
- move GL and Vulkan declarations to wined3d_gl.h and wined3d_vk.h respectively
- introduce "resource_gl.c" and "resource_vk.c", and move most resource code to those functions. This collapses the separation between buffer, texture, sampler, and view code, though, and there may be some benefit in keeping those separate.
It's worth mentioning though that the bulk of those files ends up being the texture code. It's also worth mentioning that resources are generally interrelated—e.g. views delegate to buffers or textures—and we've talked about generalizing more of the buffer/texture code to share more code. Of course, *everything* is interrelated, so the lines that we're drawing now are kind of arbitrary. I at least find that GL/Vulkan are *useful* lines to draw.
- add format_gl.c, because there are about 3000 lines of code to deal with GL format detection.
- add ffp_gl.c, which contains the fixed-function vertex and fragment pipelines. This is about 3500 lines.
- move other functions to backend-specific adapter or context functions, where it makes sense. Swapchain code mostly gets moved to context_*.c, though I'm not sure whether that makes the most sense or not.
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/wined3d_private.h | 16 ---------------- dlls/wined3d/wined3d_vk.h | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index e67c2e17791..c87d66cd2da 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -341,22 +341,7 @@ extern const GLenum magLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN; static const uint32_t WINED3D_READ_ONLY_BIND_MASK = WINED3D_BIND_VERTEX_BUFFER | WINED3D_BIND_INDEX_BUFFER | WINED3D_BIND_CONSTANT_BUFFER | WINED3D_BIND_SHADER_RESOURCE | WINED3D_BIND_INDIRECT_BUFFER;
-static const VkAccessFlags WINED3D_READ_ONLY_ACCESS_FLAGS = VK_ACCESS_INDIRECT_COMMAND_READ_BIT - | VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT - | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT - | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_HOST_READ_BIT - | VK_ACCESS_MEMORY_READ_BIT; - GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f) DECLSPEC_HIDDEN; -VkAccessFlags vk_access_mask_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN; -VkCompareOp vk_compare_op_from_wined3d(enum wined3d_cmp_func op) DECLSPEC_HIDDEN; -VkImageViewType vk_image_view_type_from_wined3d(enum wined3d_resource_type type, uint32_t flags) DECLSPEC_HIDDEN; -VkPipelineStageFlags vk_pipeline_stage_mask_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN; -VkShaderStageFlagBits vk_shader_stage_from_wined3d(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN; -VkAccessFlags vk_access_mask_from_buffer_usage(VkBufferUsageFlags usage) DECLSPEC_HIDDEN; -VkPipelineStageFlags vk_pipeline_stage_mask_from_buffer_usage(VkBufferUsageFlags usage) DECLSPEC_HIDDEN; -VkBufferUsageFlags vk_buffer_usage_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN; -VkMemoryPropertyFlags vk_memory_type_from_access_flags(uint32_t access, uint32_t usage) DECLSPEC_HIDDEN;
static inline enum wined3d_cmp_func wined3d_sanitize_cmp_func(enum wined3d_cmp_func func) { @@ -4374,7 +4359,6 @@ const char *wined3d_debug_resource_access(uint32_t access) DECLSPEC_HIDDEN; const char *wined3d_debug_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN; const char *wined3d_debug_view_desc(const struct wined3d_view_desc *d, const struct wined3d_resource *resource) DECLSPEC_HIDDEN; -const char *wined3d_debug_vkresult(VkResult vr) DECLSPEC_HIDDEN;
static inline ULONG wined3d_atomic_decrement_mutex_lock(volatile LONG *refcount) { diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h index 9135cff9143..1e7fbf57ada 100644 --- a/dlls/wined3d/wined3d_vk.h +++ b/dlls/wined3d/wined3d_vk.h @@ -19,6 +19,8 @@ #ifndef __WINE_WINED3D_VK_H #define __WINE_WINED3D_VK_H
+#include "stdint.h" +#include "wine/wined3d.h" #define VK_NO_PROTOTYPES #include "wine/vulkan.h"
@@ -229,4 +231,21 @@ struct wined3d_vk_info
#define VK_CALL(f) (vk_info->vk_ops.f)
+static const VkAccessFlags WINED3D_READ_ONLY_ACCESS_FLAGS = VK_ACCESS_INDIRECT_COMMAND_READ_BIT + | VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT + | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT + | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_HOST_READ_BIT + | VK_ACCESS_MEMORY_READ_BIT; + +VkAccessFlags vk_access_mask_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN; +VkCompareOp vk_compare_op_from_wined3d(enum wined3d_cmp_func op) DECLSPEC_HIDDEN; +VkImageViewType vk_image_view_type_from_wined3d(enum wined3d_resource_type type, uint32_t flags) DECLSPEC_HIDDEN; +VkPipelineStageFlags vk_pipeline_stage_mask_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN; +VkShaderStageFlagBits vk_shader_stage_from_wined3d(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN; +VkAccessFlags vk_access_mask_from_buffer_usage(VkBufferUsageFlags usage) DECLSPEC_HIDDEN; +VkPipelineStageFlags vk_pipeline_stage_mask_from_buffer_usage(VkBufferUsageFlags usage) DECLSPEC_HIDDEN; +VkBufferUsageFlags vk_buffer_usage_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN; +VkMemoryPropertyFlags vk_memory_type_from_access_flags(uint32_t access, uint32_t usage) DECLSPEC_HIDDEN; +const char *wined3d_debug_vkresult(VkResult vr) DECLSPEC_HIDDEN; + #endif /* __WINE_WINED3D_VK */
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/wined3d_private.h | 47 +--------------------------------- dlls/wined3d/wined3d_vk.h | 46 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 46 deletions(-)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index c87d66cd2da..63a4a641973 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -54,7 +54,6 @@ #include "objbase.h" #include "wine/wined3d.h" #include "wined3d_gl.h" -#include "wined3d_vk.h" #include "wine/list.h" #include "wine/rbtree.h" #include "wine/wgl_driver.h" @@ -1723,51 +1722,7 @@ struct wined3d_bo_user bool valid; };
-struct wined3d_bo_vk -{ - struct wined3d_bo b; - - VkBuffer vk_buffer; - struct wined3d_allocator_block *memory; - struct wined3d_bo_slab_vk *slab; - - VkDeviceMemory vk_memory; - - VkDeviceSize size; - VkBufferUsageFlags usage; - VkMemoryPropertyFlags memory_type; - - uint64_t command_buffer_id; - bool host_synced; -}; - -static inline struct wined3d_bo_vk *wined3d_bo_vk(struct wined3d_bo *bo) -{ - return CONTAINING_RECORD(bo, struct wined3d_bo_vk, b); -} - -struct wined3d_bo_slab_vk_key -{ - VkMemoryPropertyFlags memory_type; - VkBufferUsageFlags usage; - VkDeviceSize size; -}; - -struct wined3d_bo_slab_vk -{ - struct wine_rb_entry entry; - struct wined3d_bo_slab_vk *next; - VkMemoryPropertyFlags requested_memory_type; - struct wined3d_bo_vk bo; - unsigned int map_count; - void *map_ptr; - uint32_t map; -}; - -void *wined3d_bo_slab_vk_map(struct wined3d_bo_slab_vk *slab_vk, - struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; -void wined3d_bo_slab_vk_unmap(struct wined3d_bo_slab_vk *slab_vk, - struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; +#include "wined3d_vk.h"
struct wined3d_bo_address { diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h index 1e7fbf57ada..0f074207807 100644 --- a/dlls/wined3d/wined3d_vk.h +++ b/dlls/wined3d/wined3d_vk.h @@ -248,4 +248,50 @@ VkBufferUsageFlags vk_buffer_usage_from_bind_flags(uint32_t bind_flags) DECLSPEC VkMemoryPropertyFlags vk_memory_type_from_access_flags(uint32_t access, uint32_t usage) DECLSPEC_HIDDEN; const char *wined3d_debug_vkresult(VkResult vr) DECLSPEC_HIDDEN;
+struct wined3d_bo_vk +{ + struct wined3d_bo b; + + VkBuffer vk_buffer; + struct wined3d_allocator_block *memory; + struct wined3d_bo_slab_vk *slab; + + VkDeviceMemory vk_memory; + + VkDeviceSize size; + VkBufferUsageFlags usage; + VkMemoryPropertyFlags memory_type; + + uint64_t command_buffer_id; + bool host_synced; +}; + +static inline struct wined3d_bo_vk *wined3d_bo_vk(struct wined3d_bo *bo) +{ + return CONTAINING_RECORD(bo, struct wined3d_bo_vk, b); +} + +struct wined3d_bo_slab_vk_key +{ + VkMemoryPropertyFlags memory_type; + VkBufferUsageFlags usage; + VkDeviceSize size; +}; + +struct wined3d_bo_slab_vk +{ + struct wine_rb_entry entry; + struct wined3d_bo_slab_vk *next; + VkMemoryPropertyFlags requested_memory_type; + struct wined3d_bo_vk bo; + unsigned int map_count; + void *map_ptr; + uint32_t map; +}; + +void *wined3d_bo_slab_vk_map(struct wined3d_bo_slab_vk *slab_vk, + struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; +void wined3d_bo_slab_vk_unmap(struct wined3d_bo_slab_vk *slab_vk, + struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; + #endif /* __WINE_WINED3D_VK */
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/wined3d_private.h | 12 ++---------- dlls/wined3d/wined3d_vk.h | 8 ++++++++ 2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 63a4a641973..2fecec1d0ff 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1722,8 +1722,6 @@ struct wined3d_bo_user bool valid; };
-#include "wined3d_vk.h" - struct wined3d_bo_address { struct wined3d_bo *buffer_object; @@ -1741,14 +1739,6 @@ static inline struct wined3d_const_bo_address *wined3d_const_bo_address(const st return (struct wined3d_const_bo_address *)data; }
-struct wined3d_image_vk -{ - VkImage vk_image; - struct wined3d_allocator_block *memory; - VkDeviceMemory vk_memory; - uint64_t command_buffer_id; -}; - struct wined3d_stream_info_element { const struct wined3d_format *format; @@ -2114,6 +2104,8 @@ struct wined3d_pipeline_statistics_query
#define WINED3D_QUERY_POOL_SIZE 256
+#include "wined3d_vk.h" + struct wined3d_query_pool_vk { struct list entry; diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h index 0f074207807..5d0ad6fda79 100644 --- a/dlls/wined3d/wined3d_vk.h +++ b/dlls/wined3d/wined3d_vk.h @@ -294,4 +294,12 @@ void *wined3d_bo_slab_vk_map(struct wined3d_bo_slab_vk *slab_vk, void wined3d_bo_slab_vk_unmap(struct wined3d_bo_slab_vk *slab_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
+struct wined3d_image_vk +{ + VkImage vk_image; + struct wined3d_allocator_block *memory; + VkDeviceMemory vk_memory; + uint64_t command_buffer_id; +}; + #endif /* __WINE_WINED3D_VK */
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/wined3d_private.h | 63 ++-------------------------------- dlls/wined3d/wined3d_vk.h | 60 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 61 deletions(-)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 2fecec1d0ff..e127fb48960 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2104,67 +2104,6 @@ struct wined3d_pipeline_statistics_query
#define WINED3D_QUERY_POOL_SIZE 256
-#include "wined3d_vk.h" - -struct wined3d_query_pool_vk -{ - struct list entry; - struct list completed_entry; - - struct list *free_list; - VkQueryPool vk_query_pool; - VkEvent vk_event; - - uint32_t allocated[WINED3D_BITMAP_SIZE(WINED3D_QUERY_POOL_SIZE)]; - uint32_t completed[WINED3D_BITMAP_SIZE(WINED3D_QUERY_POOL_SIZE)]; -}; - -bool wined3d_query_pool_vk_allocate_query(struct wined3d_query_pool_vk *pool_vk, size_t *idx) DECLSPEC_HIDDEN; -void wined3d_query_pool_vk_mark_free(struct wined3d_context_vk *context_vk, struct wined3d_query_pool_vk *pool_vk, - uint32_t start, uint32_t count) DECLSPEC_HIDDEN; -void wined3d_query_pool_vk_cleanup(struct wined3d_query_pool_vk *pool_vk, - struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; -bool wined3d_query_pool_vk_init(struct wined3d_query_pool_vk *pool_vk, struct wined3d_context_vk *context_vk, - enum wined3d_query_type type, struct list *free_pools) DECLSPEC_HIDDEN; - -struct wined3d_query_pool_idx_vk -{ - struct wined3d_query_pool_vk *pool_vk; - size_t idx; -}; - -#define WINED3D_QUERY_VK_FLAG_ACTIVE 0x00000001 -#define WINED3D_QUERY_VK_FLAG_STARTED 0x00000002 -#define WINED3D_QUERY_VK_FLAG_RENDER_PASS 0x00000004 - -struct wined3d_query_vk -{ - struct wined3d_query q; - - struct list entry; - struct wined3d_query_pool_idx_vk pool_idx; - uint8_t flags; - uint64_t command_buffer_id; - uint32_t control_flags; - VkEvent vk_event; - SIZE_T pending_count, pending_size; - struct wined3d_query_pool_idx_vk *pending; -}; - -static inline struct wined3d_query_vk *wined3d_query_vk(struct wined3d_query *query) -{ - return CONTAINING_RECORD(query, struct wined3d_query_vk, q); -} - -struct wined3d_device_vk; - -bool wined3d_query_vk_accumulate_data(struct wined3d_query_vk *query_vk, struct wined3d_device_vk *device_vk, - const struct wined3d_query_pool_idx_vk *pool_idx) DECLSPEC_HIDDEN; -HRESULT wined3d_query_vk_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent, - const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) DECLSPEC_HIDDEN; -void wined3d_query_vk_resume(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; -void wined3d_query_vk_suspend(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; - struct wined3d_gl_view { GLenum target; @@ -2454,6 +2393,8 @@ void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context const struct wined3d_state *state) DECLSPEC_HIDDEN; void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl *context_gl, uint64_t id) DECLSPEC_HIDDEN;
+#include "wined3d_vk.h" + struct wined3d_command_buffer_vk { uint64_t id; diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h index 5d0ad6fda79..9fbe1f00d41 100644 --- a/dlls/wined3d/wined3d_vk.h +++ b/dlls/wined3d/wined3d_vk.h @@ -20,10 +20,13 @@ #define __WINE_WINED3D_VK_H
#include "stdint.h" +#include "wine/list.h" #include "wine/wined3d.h" #define VK_NO_PROTOTYPES #include "wine/vulkan.h"
+struct wined3d_device_vk; + #define VK_INSTANCE_FUNCS() \ VK_INSTANCE_PFN(vkCreateDevice) \ VK_INSTANCE_PFN(vkDestroyInstance) \ @@ -302,4 +305,61 @@ struct wined3d_image_vk uint64_t command_buffer_id; };
+struct wined3d_query_pool_vk +{ + struct list entry; + struct list completed_entry; + + struct list *free_list; + VkQueryPool vk_query_pool; + VkEvent vk_event; + + uint32_t allocated[WINED3D_BITMAP_SIZE(WINED3D_QUERY_POOL_SIZE)]; + uint32_t completed[WINED3D_BITMAP_SIZE(WINED3D_QUERY_POOL_SIZE)]; +}; + +bool wined3d_query_pool_vk_allocate_query(struct wined3d_query_pool_vk *pool_vk, size_t *idx) DECLSPEC_HIDDEN; +void wined3d_query_pool_vk_mark_free(struct wined3d_context_vk *context_vk, struct wined3d_query_pool_vk *pool_vk, + uint32_t start, uint32_t count) DECLSPEC_HIDDEN; +void wined3d_query_pool_vk_cleanup(struct wined3d_query_pool_vk *pool_vk, + struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; +bool wined3d_query_pool_vk_init(struct wined3d_query_pool_vk *pool_vk, struct wined3d_context_vk *context_vk, + enum wined3d_query_type type, struct list *free_pools) DECLSPEC_HIDDEN; + +struct wined3d_query_pool_idx_vk +{ + struct wined3d_query_pool_vk *pool_vk; + size_t idx; +}; + +#define WINED3D_QUERY_VK_FLAG_ACTIVE 0x00000001 +#define WINED3D_QUERY_VK_FLAG_STARTED 0x00000002 +#define WINED3D_QUERY_VK_FLAG_RENDER_PASS 0x00000004 + +struct wined3d_query_vk +{ + struct wined3d_query q; + + struct list entry; + struct wined3d_query_pool_idx_vk pool_idx; + uint8_t flags; + uint64_t command_buffer_id; + uint32_t control_flags; + VkEvent vk_event; + SIZE_T pending_count, pending_size; + struct wined3d_query_pool_idx_vk *pending; +}; + +static inline struct wined3d_query_vk *wined3d_query_vk(struct wined3d_query *query) +{ + return CONTAINING_RECORD(query, struct wined3d_query_vk, q); +} + +bool wined3d_query_vk_accumulate_data(struct wined3d_query_vk *query_vk, struct wined3d_device_vk *device_vk, + const struct wined3d_query_pool_idx_vk *pool_idx) DECLSPEC_HIDDEN; +HRESULT wined3d_query_vk_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent, + const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) DECLSPEC_HIDDEN; +void wined3d_query_vk_resume(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; +void wined3d_query_vk_suspend(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; + #endif /* __WINE_WINED3D_VK */
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/wined3d_private.h | 302 --------------------------------- dlls/wined3d/wined3d_vk.h | 302 +++++++++++++++++++++++++++++++++ 2 files changed, 302 insertions(+), 302 deletions(-)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index e127fb48960..0093c5d68bd 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2395,308 +2395,6 @@ void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl *context_gl
#include "wined3d_vk.h"
-struct wined3d_command_buffer_vk -{ - uint64_t id; - VkCommandBuffer vk_command_buffer; - VkFence vk_fence; -}; - -enum wined3d_retired_object_type_vk -{ - WINED3D_RETIRED_FREE_VK, - WINED3D_RETIRED_FRAMEBUFFER_VK, - WINED3D_RETIRED_DESCRIPTOR_POOL_VK, - WINED3D_RETIRED_MEMORY_VK, - WINED3D_RETIRED_ALLOCATOR_BLOCK_VK, - WINED3D_RETIRED_BO_SLAB_SLICE_VK, - WINED3D_RETIRED_BUFFER_VK, - WINED3D_RETIRED_IMAGE_VK, - WINED3D_RETIRED_BUFFER_VIEW_VK, - WINED3D_RETIRED_IMAGE_VIEW_VK, - WINED3D_RETIRED_SAMPLER_VK, - WINED3D_RETIRED_QUERY_POOL_VK, - WINED3D_RETIRED_EVENT_VK, - WINED3D_RETIRED_PIPELINE_VK, -}; - -struct wined3d_retired_object_vk -{ - enum wined3d_retired_object_type_vk type; - union - { - struct wined3d_retired_object_vk *next; - VkFramebuffer vk_framebuffer; - VkDescriptorPool vk_descriptor_pool; - VkDeviceMemory vk_memory; - struct wined3d_allocator_block *block; - struct - { - struct wined3d_bo_slab_vk *slab; - size_t idx; - } slice; - VkBuffer vk_buffer; - VkImage vk_image; - VkBufferView vk_buffer_view; - VkImageView vk_image_view; - VkSampler vk_sampler; - VkEvent vk_event; - VkPipeline vk_pipeline; - struct - { - struct wined3d_query_pool_vk *pool_vk; - uint32_t start; - uint32_t count; - } queries; - } u; - uint64_t command_buffer_id; -}; - -struct wined3d_retired_objects_vk -{ - struct wined3d_retired_object_vk *objects; - struct wined3d_retired_object_vk *free; - SIZE_T size; - SIZE_T count; -}; - -#define WINED3D_FB_ATTACHMENT_FLAG_DISCARDED 1 -#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_C 2 -#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_S 4 -#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_Z 8 - -struct wined3d_render_pass_attachment_vk -{ - VkFormat vk_format; - VkSampleCountFlagBits vk_samples; - VkImageLayout vk_layout; - uint32_t flags; -}; - -struct wined3d_render_pass_key_vk -{ - struct wined3d_render_pass_attachment_vk rt[WINED3D_MAX_RENDER_TARGETS]; - struct wined3d_render_pass_attachment_vk ds; - uint32_t rt_mask; -}; - -struct wined3d_render_pass_vk -{ - struct wine_rb_entry entry; - struct wined3d_render_pass_key_vk key; - VkRenderPass vk_render_pass; -}; - -struct wined3d_pipeline_layout_key_vk -{ - VkDescriptorSetLayoutBinding *bindings; - SIZE_T binding_count; -}; - -struct wined3d_pipeline_layout_vk -{ - struct wine_rb_entry entry; - struct wined3d_pipeline_layout_key_vk key; - VkPipelineLayout vk_pipeline_layout; - VkDescriptorSetLayout vk_set_layout; -}; - -struct wined3d_graphics_pipeline_key_vk -{ - VkPipelineShaderStageCreateInfo stages[WINED3D_SHADER_TYPE_GRAPHICS_COUNT]; - VkVertexInputBindingDivisorDescriptionEXT divisors[MAX_ATTRIBS]; - VkVertexInputAttributeDescription attributes[MAX_ATTRIBS]; - VkVertexInputBindingDescription bindings[MAX_ATTRIBS]; - VkViewport viewports[WINED3D_MAX_VIEWPORTS]; - VkRect2D scissors[WINED3D_MAX_VIEWPORTS]; - VkSampleMask sample_mask; - VkPipelineColorBlendAttachmentState blend_attachments[WINED3D_MAX_RENDER_TARGETS]; - - VkPipelineVertexInputDivisorStateCreateInfoEXT divisor_desc; - VkPipelineVertexInputStateCreateInfo input_desc; - VkPipelineInputAssemblyStateCreateInfo ia_desc; - VkPipelineTessellationStateCreateInfo ts_desc; - VkPipelineViewportStateCreateInfo vp_desc; - VkPipelineRasterizationStateCreateInfo rs_desc; - VkPipelineMultisampleStateCreateInfo ms_desc; - VkPipelineDepthStencilStateCreateInfo ds_desc; - VkPipelineColorBlendStateCreateInfo blend_desc; - VkPipelineDynamicStateCreateInfo dynamic_desc; - - VkGraphicsPipelineCreateInfo pipeline_desc; -}; - -struct wined3d_graphics_pipeline_vk -{ - struct wine_rb_entry entry; - struct wined3d_graphics_pipeline_key_vk key; - VkPipeline vk_pipeline; -}; - -enum wined3d_shader_descriptor_type -{ - WINED3D_SHADER_DESCRIPTOR_TYPE_CBV, - WINED3D_SHADER_DESCRIPTOR_TYPE_SRV, - WINED3D_SHADER_DESCRIPTOR_TYPE_UAV, - WINED3D_SHADER_DESCRIPTOR_TYPE_UAV_COUNTER, - WINED3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, -}; - -struct wined3d_shader_resource_binding -{ - enum wined3d_shader_type shader_type; - enum wined3d_shader_descriptor_type shader_descriptor_type; - size_t resource_idx; - enum wined3d_shader_resource_type resource_type; - enum wined3d_data_type resource_data_type; - size_t binding_idx; -}; - -struct wined3d_shader_resource_bindings -{ - struct wined3d_shader_resource_binding *bindings; - SIZE_T size, count; -}; - -struct wined3d_shader_descriptor_writes_vk -{ - VkWriteDescriptorSet *writes; - SIZE_T size, count; -}; - -struct wined3d_context_vk -{ - struct wined3d_context c; - - const struct wined3d_vk_info *vk_info; - - uint32_t update_compute_pipeline : 1; - uint32_t update_stream_output : 1; - uint32_t padding : 30; - - struct - { - VkShaderModule vk_modules[WINED3D_SHADER_TYPE_GRAPHICS_COUNT]; - struct wined3d_graphics_pipeline_key_vk pipeline_key_vk; - 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; - struct wined3d_shader_resource_bindings bindings; - } compute; - - VkCommandPool vk_command_pool; - struct wined3d_command_buffer_vk current_command_buffer; - uint64_t completed_command_buffer_id; - VkDeviceSize retired_bo_size; - - struct - { - struct wined3d_command_buffer_vk *buffers; - SIZE_T buffers_size; - SIZE_T buffer_count; - } submitted, completed; - - struct wined3d_shader_descriptor_writes_vk descriptor_writes; - - VkFramebuffer vk_framebuffer; - VkRenderPass vk_render_pass; - - SIZE_T vk_descriptor_pools_size; - SIZE_T vk_descriptor_pool_count; - VkDescriptorPool *vk_descriptor_pools; - - VkSampleCountFlagBits sample_count; - unsigned int rt_count; - - VkBuffer vk_so_counters[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]; - VkDeviceSize vk_so_offsets[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]; - struct wined3d_bo_vk vk_so_counter_bo; - - struct list render_pass_queries; - struct list active_queries; - struct list completed_query_pools; - struct list free_occlusion_query_pools; - struct list free_timestamp_query_pools; - struct list free_pipeline_statistics_query_pools; - struct list free_stream_output_statistics_query_pools; - - struct wined3d_retired_objects_vk retired; - struct wine_rb_tree render_passes; - struct wine_rb_tree pipeline_layouts; - struct wine_rb_tree graphics_pipelines; - struct wine_rb_tree bo_slab_available; -}; - -static inline struct wined3d_context_vk *wined3d_context_vk(struct wined3d_context *context) -{ - return CONTAINING_RECORD(context, struct wined3d_context_vk, c); -} - -bool wined3d_context_vk_allocate_query(struct wined3d_context_vk *context_vk, - enum wined3d_query_type type, struct wined3d_query_pool_idx_vk *pool_idx) DECLSPEC_HIDDEN; -VkDeviceMemory wined3d_context_vk_allocate_vram_chunk_memory(struct wined3d_context_vk *context_vk, - 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, struct wined3d_buffer_vk *indirect_vk, bool indexed) 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; -BOOL wined3d_context_vk_create_image(struct wined3d_context_vk *context_vk, VkImageType vk_image_type, - VkImageUsageFlags usage, VkFormat vk_format, unsigned int width, unsigned int height, unsigned int depth, - unsigned int sample_count, unsigned int mip_levels, unsigned int layer_count, unsigned int flags, - struct wined3d_image_vk *image) DECLSPEC_HIDDEN; -void wined3d_context_vk_destroy_allocator_block(struct wined3d_context_vk *context_vk, - struct wined3d_allocator_block *block, uint64_t command_buffer_id) DECLSPEC_HIDDEN; -void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk, - const struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN; -void wined3d_context_vk_destroy_image(struct wined3d_context_vk *context_vk, - struct wined3d_image_vk *image_vk) DECLSPEC_HIDDEN; -void wined3d_context_vk_destroy_vk_buffer_view(struct wined3d_context_vk *context_vk, - VkBufferView vk_view, uint64_t command_buffer_id) DECLSPEC_HIDDEN; -void wined3d_context_vk_destroy_vk_framebuffer(struct wined3d_context_vk *context_vk, - VkFramebuffer vk_framebuffer, uint64_t command_buffer_id) DECLSPEC_HIDDEN; -void wined3d_context_vk_destroy_vk_image(struct wined3d_context_vk *context_vk, - VkImage vk_image, uint64_t command_buffer_id) DECLSPEC_HIDDEN; -void wined3d_context_vk_destroy_vk_image_view(struct wined3d_context_vk *context_vk, - VkImageView vk_view, uint64_t command_buffer_id) DECLSPEC_HIDDEN; -void wined3d_context_vk_destroy_vk_memory(struct wined3d_context_vk *context_vk, - VkDeviceMemory vk_memory, uint64_t command_buffer_id) DECLSPEC_HIDDEN; -void wined3d_context_vk_destroy_vk_sampler(struct wined3d_context_vk *context_vk, - VkSampler vk_sampler, uint64_t command_buffer_id) DECLSPEC_HIDDEN; -void wined3d_context_vk_destroy_vk_event(struct wined3d_context_vk *context_vk, - VkEvent vk_event, uint64_t command_buffer_id) DECLSPEC_HIDDEN; -void wined3d_context_vk_destroy_vk_pipeline(struct wined3d_context_vk *context_vk, - VkPipeline vk_pipeline, 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; -VkRenderPass wined3d_context_vk_get_render_pass(struct wined3d_context_vk *context_vk, - const struct wined3d_fb_state *fb, unsigned int rt_count, - bool depth_stencil, uint32_t clear_flags) DECLSPEC_HIDDEN; -void wined3d_context_vk_image_barrier(struct wined3d_context_vk *context_vk, - VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask, - VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout, - VkImageLayout new_layout, VkImage image, const VkImageSubresourceRange *range) DECLSPEC_HIDDEN; -HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk, - struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; -void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context_vk, - 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; -VkDescriptorSet wined3d_context_vk_create_vk_descriptor_set(struct wined3d_context_vk *context_vk, - VkDescriptorSetLayout vk_set_layout) DECLSPEC_HIDDEN; - typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id);
struct wined3d_state_entry diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h index 9fbe1f00d41..9eaddbf99c4 100644 --- a/dlls/wined3d/wined3d_vk.h +++ b/dlls/wined3d/wined3d_vk.h @@ -362,4 +362,306 @@ HRESULT wined3d_query_vk_create(struct wined3d_device *device, enum wined3d_quer void wined3d_query_vk_resume(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN; void wined3d_query_vk_suspend(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
+struct wined3d_command_buffer_vk +{ + uint64_t id; + VkCommandBuffer vk_command_buffer; + VkFence vk_fence; +}; + +enum wined3d_retired_object_type_vk +{ + WINED3D_RETIRED_FREE_VK, + WINED3D_RETIRED_FRAMEBUFFER_VK, + WINED3D_RETIRED_DESCRIPTOR_POOL_VK, + WINED3D_RETIRED_MEMORY_VK, + WINED3D_RETIRED_ALLOCATOR_BLOCK_VK, + WINED3D_RETIRED_BO_SLAB_SLICE_VK, + WINED3D_RETIRED_BUFFER_VK, + WINED3D_RETIRED_IMAGE_VK, + WINED3D_RETIRED_BUFFER_VIEW_VK, + WINED3D_RETIRED_IMAGE_VIEW_VK, + WINED3D_RETIRED_SAMPLER_VK, + WINED3D_RETIRED_QUERY_POOL_VK, + WINED3D_RETIRED_EVENT_VK, + WINED3D_RETIRED_PIPELINE_VK, +}; + +struct wined3d_retired_object_vk +{ + enum wined3d_retired_object_type_vk type; + union + { + struct wined3d_retired_object_vk *next; + VkFramebuffer vk_framebuffer; + VkDescriptorPool vk_descriptor_pool; + VkDeviceMemory vk_memory; + struct wined3d_allocator_block *block; + struct + { + struct wined3d_bo_slab_vk *slab; + size_t idx; + } slice; + VkBuffer vk_buffer; + VkImage vk_image; + VkBufferView vk_buffer_view; + VkImageView vk_image_view; + VkSampler vk_sampler; + VkEvent vk_event; + VkPipeline vk_pipeline; + struct + { + struct wined3d_query_pool_vk *pool_vk; + uint32_t start; + uint32_t count; + } queries; + } u; + uint64_t command_buffer_id; +}; + +struct wined3d_retired_objects_vk +{ + struct wined3d_retired_object_vk *objects; + struct wined3d_retired_object_vk *free; + SIZE_T size; + SIZE_T count; +}; + +#define WINED3D_FB_ATTACHMENT_FLAG_DISCARDED 1 +#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_C 2 +#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_S 4 +#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_Z 8 + +struct wined3d_render_pass_attachment_vk +{ + VkFormat vk_format; + VkSampleCountFlagBits vk_samples; + VkImageLayout vk_layout; + uint32_t flags; +}; + +struct wined3d_render_pass_key_vk +{ + struct wined3d_render_pass_attachment_vk rt[WINED3D_MAX_RENDER_TARGETS]; + struct wined3d_render_pass_attachment_vk ds; + uint32_t rt_mask; +}; + +struct wined3d_render_pass_vk +{ + struct wine_rb_entry entry; + struct wined3d_render_pass_key_vk key; + VkRenderPass vk_render_pass; +}; + +struct wined3d_pipeline_layout_key_vk +{ + VkDescriptorSetLayoutBinding *bindings; + SIZE_T binding_count; +}; + +struct wined3d_pipeline_layout_vk +{ + struct wine_rb_entry entry; + struct wined3d_pipeline_layout_key_vk key; + VkPipelineLayout vk_pipeline_layout; + VkDescriptorSetLayout vk_set_layout; +}; + +struct wined3d_graphics_pipeline_key_vk +{ + VkPipelineShaderStageCreateInfo stages[WINED3D_SHADER_TYPE_GRAPHICS_COUNT]; + VkVertexInputBindingDivisorDescriptionEXT divisors[MAX_ATTRIBS]; + VkVertexInputAttributeDescription attributes[MAX_ATTRIBS]; + VkVertexInputBindingDescription bindings[MAX_ATTRIBS]; + VkViewport viewports[WINED3D_MAX_VIEWPORTS]; + VkRect2D scissors[WINED3D_MAX_VIEWPORTS]; + VkSampleMask sample_mask; + VkPipelineColorBlendAttachmentState blend_attachments[WINED3D_MAX_RENDER_TARGETS]; + + VkPipelineVertexInputDivisorStateCreateInfoEXT divisor_desc; + VkPipelineVertexInputStateCreateInfo input_desc; + VkPipelineInputAssemblyStateCreateInfo ia_desc; + VkPipelineTessellationStateCreateInfo ts_desc; + VkPipelineViewportStateCreateInfo vp_desc; + VkPipelineRasterizationStateCreateInfo rs_desc; + VkPipelineMultisampleStateCreateInfo ms_desc; + VkPipelineDepthStencilStateCreateInfo ds_desc; + VkPipelineColorBlendStateCreateInfo blend_desc; + VkPipelineDynamicStateCreateInfo dynamic_desc; + + VkGraphicsPipelineCreateInfo pipeline_desc; +}; + +struct wined3d_graphics_pipeline_vk +{ + struct wine_rb_entry entry; + struct wined3d_graphics_pipeline_key_vk key; + VkPipeline vk_pipeline; +}; + +enum wined3d_shader_descriptor_type +{ + WINED3D_SHADER_DESCRIPTOR_TYPE_CBV, + WINED3D_SHADER_DESCRIPTOR_TYPE_SRV, + WINED3D_SHADER_DESCRIPTOR_TYPE_UAV, + WINED3D_SHADER_DESCRIPTOR_TYPE_UAV_COUNTER, + WINED3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, +}; + +struct wined3d_shader_resource_binding +{ + enum wined3d_shader_type shader_type; + enum wined3d_shader_descriptor_type shader_descriptor_type; + size_t resource_idx; + enum wined3d_shader_resource_type resource_type; + enum wined3d_data_type resource_data_type; + size_t binding_idx; +}; + +struct wined3d_shader_resource_bindings +{ + struct wined3d_shader_resource_binding *bindings; + SIZE_T size, count; +}; + +struct wined3d_shader_descriptor_writes_vk +{ + VkWriteDescriptorSet *writes; + SIZE_T size, count; +}; + +struct wined3d_context_vk +{ + struct wined3d_context c; + + const struct wined3d_vk_info *vk_info; + + uint32_t update_compute_pipeline : 1; + uint32_t update_stream_output : 1; + uint32_t padding : 30; + + struct + { + VkShaderModule vk_modules[WINED3D_SHADER_TYPE_GRAPHICS_COUNT]; + struct wined3d_graphics_pipeline_key_vk pipeline_key_vk; + 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; + struct wined3d_shader_resource_bindings bindings; + } compute; + + VkCommandPool vk_command_pool; + struct wined3d_command_buffer_vk current_command_buffer; + uint64_t completed_command_buffer_id; + VkDeviceSize retired_bo_size; + + struct + { + struct wined3d_command_buffer_vk *buffers; + SIZE_T buffers_size; + SIZE_T buffer_count; + } submitted, completed; + + struct wined3d_shader_descriptor_writes_vk descriptor_writes; + + VkFramebuffer vk_framebuffer; + VkRenderPass vk_render_pass; + + SIZE_T vk_descriptor_pools_size; + SIZE_T vk_descriptor_pool_count; + VkDescriptorPool *vk_descriptor_pools; + + VkSampleCountFlagBits sample_count; + unsigned int rt_count; + + VkBuffer vk_so_counters[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]; + VkDeviceSize vk_so_offsets[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]; + struct wined3d_bo_vk vk_so_counter_bo; + + struct list render_pass_queries; + struct list active_queries; + struct list completed_query_pools; + struct list free_occlusion_query_pools; + struct list free_timestamp_query_pools; + struct list free_pipeline_statistics_query_pools; + struct list free_stream_output_statistics_query_pools; + + struct wined3d_retired_objects_vk retired; + struct wine_rb_tree render_passes; + struct wine_rb_tree pipeline_layouts; + struct wine_rb_tree graphics_pipelines; + struct wine_rb_tree bo_slab_available; +}; + +static inline struct wined3d_context_vk *wined3d_context_vk(struct wined3d_context *context) +{ + return CONTAINING_RECORD(context, struct wined3d_context_vk, c); +} + +bool wined3d_context_vk_allocate_query(struct wined3d_context_vk *context_vk, + enum wined3d_query_type type, struct wined3d_query_pool_idx_vk *pool_idx) DECLSPEC_HIDDEN; +VkDeviceMemory wined3d_context_vk_allocate_vram_chunk_memory(struct wined3d_context_vk *context_vk, + 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, struct wined3d_buffer_vk *indirect_vk, bool indexed) 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; +BOOL wined3d_context_vk_create_image(struct wined3d_context_vk *context_vk, VkImageType vk_image_type, + VkImageUsageFlags usage, VkFormat vk_format, unsigned int width, unsigned int height, unsigned int depth, + unsigned int sample_count, unsigned int mip_levels, unsigned int layer_count, unsigned int flags, + struct wined3d_image_vk *image) DECLSPEC_HIDDEN; +void wined3d_context_vk_destroy_allocator_block(struct wined3d_context_vk *context_vk, + struct wined3d_allocator_block *block, uint64_t command_buffer_id) DECLSPEC_HIDDEN; +void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk, + const struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN; +void wined3d_context_vk_destroy_image(struct wined3d_context_vk *context_vk, + struct wined3d_image_vk *image_vk) DECLSPEC_HIDDEN; +void wined3d_context_vk_destroy_vk_buffer_view(struct wined3d_context_vk *context_vk, + VkBufferView vk_view, uint64_t command_buffer_id) DECLSPEC_HIDDEN; +void wined3d_context_vk_destroy_vk_framebuffer(struct wined3d_context_vk *context_vk, + VkFramebuffer vk_framebuffer, uint64_t command_buffer_id) DECLSPEC_HIDDEN; +void wined3d_context_vk_destroy_vk_image(struct wined3d_context_vk *context_vk, + VkImage vk_image, uint64_t command_buffer_id) DECLSPEC_HIDDEN; +void wined3d_context_vk_destroy_vk_image_view(struct wined3d_context_vk *context_vk, + VkImageView vk_view, uint64_t command_buffer_id) DECLSPEC_HIDDEN; +void wined3d_context_vk_destroy_vk_memory(struct wined3d_context_vk *context_vk, + VkDeviceMemory vk_memory, uint64_t command_buffer_id) DECLSPEC_HIDDEN; +void wined3d_context_vk_destroy_vk_sampler(struct wined3d_context_vk *context_vk, + VkSampler vk_sampler, uint64_t command_buffer_id) DECLSPEC_HIDDEN; +void wined3d_context_vk_destroy_vk_event(struct wined3d_context_vk *context_vk, + VkEvent vk_event, uint64_t command_buffer_id) DECLSPEC_HIDDEN; +void wined3d_context_vk_destroy_vk_pipeline(struct wined3d_context_vk *context_vk, + VkPipeline vk_pipeline, 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; +VkRenderPass wined3d_context_vk_get_render_pass(struct wined3d_context_vk *context_vk, + const struct wined3d_fb_state *fb, unsigned int rt_count, + bool depth_stencil, uint32_t clear_flags) DECLSPEC_HIDDEN; +void wined3d_context_vk_image_barrier(struct wined3d_context_vk *context_vk, + VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask, + VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout, + VkImageLayout new_layout, VkImage image, const VkImageSubresourceRange *range) DECLSPEC_HIDDEN; +HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk, + struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; +void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context_vk, + 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; +VkDescriptorSet wined3d_context_vk_create_vk_descriptor_set(struct wined3d_context_vk *context_vk, + VkDescriptorSetLayout vk_set_layout) DECLSPEC_HIDDEN; + #endif /* __WINE_WINED3D_VK */
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/wined3d_private.h | 35 +++++----------------------------- dlls/wined3d/wined3d_vk.h | 26 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 30 deletions(-)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 0093c5d68bd..bd2ef14ea8c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2393,8 +2393,6 @@ void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context const struct wined3d_state *state) DECLSPEC_HIDDEN; void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl *context_gl, uint64_t id) DECLSPEC_HIDDEN;
-#include "wined3d_vk.h" - typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id);
struct wined3d_state_entry @@ -3196,6 +3194,9 @@ BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int ordinal, void wined3d_adapter_cleanup(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN; BOOL wined3d_get_primary_adapter_luid(LUID *luid) DECLSPEC_HIDDEN;
+struct wined3d_adapter *wined3d_adapter_vk_create(unsigned int ordinal, + unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN; + struct wined3d_adapter_gl { struct wined3d_adapter a; @@ -3217,32 +3218,6 @@ static inline const struct wined3d_adapter_gl *wined3d_adapter_gl_const(const st struct wined3d_adapter *wined3d_adapter_gl_create(unsigned int ordinal, unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
-struct wined3d_adapter_vk -{ - struct wined3d_adapter a; - - struct wined3d_vk_info vk_info; - unsigned int device_extension_count; - const char **device_extensions; - VkPhysicalDevice physical_device; - - VkPhysicalDeviceLimits device_limits; - VkPhysicalDeviceMemoryProperties memory_properties; -}; - -static inline struct wined3d_adapter_vk *wined3d_adapter_vk(struct wined3d_adapter *adapter) -{ - return CONTAINING_RECORD(adapter, struct wined3d_adapter_vk, a); -} - -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, - unsigned int range_count, const struct wined3d_range *ranges) DECLSPEC_HIDDEN; - struct wined3d_caps_gl_ctx { HDC dc; @@ -3262,8 +3237,6 @@ struct wined3d_caps_gl_ctx BOOL wined3d_adapter_gl_init_format_info(struct wined3d_adapter *adapter, struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN; BOOL wined3d_adapter_no3d_init_format_info(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN; -BOOL wined3d_adapter_vk_init_format_info(struct wined3d_adapter_vk *adapter_vk, - const struct wined3d_vk_info *vk_info) DECLSPEC_HIDDEN; ssize_t adapter_adjust_mapped_memory(struct wined3d_adapter *adapter, ssize_t size) DECLSPEC_HIDDEN; UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN;
@@ -3681,6 +3654,8 @@ static inline struct wined3d_device_no3d *wined3d_device_no3d(struct wined3d_dev return CONTAINING_RECORD(device, struct wined3d_device_no3d, d); }
+#include "wined3d_vk.h" + struct wined3d_null_resources_vk { struct wined3d_bo_vk bo; diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h index 9eaddbf99c4..43b40889451 100644 --- a/dlls/wined3d/wined3d_vk.h +++ b/dlls/wined3d/wined3d_vk.h @@ -664,4 +664,30 @@ void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk *context_v VkDescriptorSet wined3d_context_vk_create_vk_descriptor_set(struct wined3d_context_vk *context_vk, VkDescriptorSetLayout vk_set_layout) DECLSPEC_HIDDEN;
+struct wined3d_adapter_vk +{ + struct wined3d_adapter a; + + struct wined3d_vk_info vk_info; + unsigned int device_extension_count; + const char **device_extensions; + VkPhysicalDevice physical_device; + + VkPhysicalDeviceLimits device_limits; + VkPhysicalDeviceMemoryProperties memory_properties; +}; + +static inline struct wined3d_adapter_vk *wined3d_adapter_vk(struct wined3d_adapter *adapter) +{ + return CONTAINING_RECORD(adapter, struct wined3d_adapter_vk, a); +} + +void adapter_vk_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, + const struct wined3d_bo_address *src, + unsigned int range_count, const struct wined3d_range *ranges) 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; +BOOL wined3d_adapter_vk_init_format_info(struct wined3d_adapter_vk *adapter_vk, + const struct wined3d_vk_info *vk_info) DECLSPEC_HIDDEN; + #endif /* __WINE_WINED3D_VK */
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=134455
Your paranoid android.
=== debian11 (32 bit report) ===
oleaut32: vartest.c:9551: Test failed: VarImp: NULL|0x0, DECIMAL|0x0: expected vt I4 hr 0x0, got vt NULL hr 0x0
introduce "resource_gl.c" and "resource_vk.c", and move most resource code to those functions. This collapses the separation between buffer, texture, sampler, and view code, though, and there may be some benefit in keeping those separate.
For what it's worth, in terms of terminology, resources, samplers and views are quite distinct. On the other hand, the separation between buffer, texture, surface, and resource code is largely just historic.
move other functions to backend-specific adapter or context functions, where it makes sense. Swapchain code mostly gets moved to context_*.c, though I'm not sure whether that makes the most sense or not.
Swapchains and contexts are somewhat tied together in the GL code, again largely for historic reasons, but I think the direction we've been moving in has largely been to try to separate them.
introduce "resource_gl.c" and "resource_vk.c", and move most resource code to those functions. This collapses the separation between buffer, texture, sampler, and view code, though, and there may be some benefit in keeping those separate.
For what it's worth, in terms of terminology, resources, samplers and views are quite distinct. On the other hand, the separation between buffer, texture, surface, and resource code is largely just historic.
Sure. In a large sense it's not so much about separate components as about organization. There's a scant amount of backend-specific code for samplers; part of the goal is to avoid putting backend code in any file that isn't backend-specific, but for something like samplers that'd just result in tiny files. Basically I was afraid that having one file per small component wouldn't be received well by others—and that I'd rather see things divided by backend than by... object type, given that what is and isn't a backend function is a much clearer line to draw.
Maybe the whole effort is ultimately not worthwhile, I don't know. It certainly was nice for me to find wined3d_texture_set_lod(), at least, and I feel like new contributors will see it as more readable, but I'm also willing to be told this is pointless churn that's not clearly improving anything.
move other functions to backend-specific adapter or context functions, where it makes sense. Swapchain code mostly gets moved to context_*.c, though I'm not sure whether that makes the most sense or not.
Swapchains and contexts are somewhat tied together in the GL code, again largely for historic reasons, but I think the direction we've been moving in has largely been to try to separate them.
Part of the thing here is that "what is a context function?" is something I don't know how to answer. wined3d_context_gl_set_current(), sure, but then it's pretty much a "misc_gl.c" for anything that doesn't fit in another file. [For Vulkan the distinction is even worse, with code spread between adapter_vk.c, context_vk.c, and sometimes device_vk.c, with no clear pattern.]. So in lieu of creating swapchain_*.c I decided that code made more sense dumped in context_*.c.
Moving backend specific code to backend files seems good. I'm not sure about more fine grained separation, in cases where there's no clear lines to draw I'd rather have things in a single file - that also makes it somewhat easier to refactor things. Anyway, the outlined plan sounds reasonable, but also I wouldn't mind just having backend_vk.c and backend_gl.c files.
This merge request was approved by Jan Sikorski.