4646#include "../drivers_shader/shader_vulkan.h"
4747#include "../include/vulkan/vulkan.h"
4848
49- #define VK_BUFFER_CHAIN_DISCARD (chain ) \
50- { \
51- chain->current = chain->head; \
52- chain->offset = 0; \
53- }
54-
55- #define VULKAN_SYNC_TEXTURE_TO_GPU (device , tex_memory ) \
56- { \
57- VkMappedMemoryRange range; \
58- range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; \
59- range.pNext = NULL; \
60- range.memory = tex_memory; \
61- range.offset = 0; \
62- range.size = VK_WHOLE_SIZE; \
63- vkFlushMappedMemoryRanges(device, 1, &range); \
64- }
65-
66- #define VULKAN_SYNC_TEXTURE_TO_CPU (device , tex_memory ) \
67- { \
68- VkMappedMemoryRange range; \
69- range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; \
70- range.pNext = NULL; \
71- range.memory = tex_memory; \
72- range.offset = 0; \
73- range.size = VK_WHOLE_SIZE; \
74- vkInvalidateMappedMemoryRanges(device, 1, &range); \
75- }
76-
7749#define VULKAN_IMAGE_LAYOUT_TRANSITION_LEVELS (cmd , img , levels , old_layout , new_layout , src_access , dst_access , src_stages , dst_stages , src_queue_family_idx , dst_queue_family_idx ) \
7850{ \
7951 VkImageMemoryBarrier barrier; \
9466 vkCmdPipelineBarrier(cmd, src_stages, dst_stages, 0, 0, NULL, 0, NULL, 1, &barrier); \
9567}
9668
97- #define VULKAN_TRANSFER_IMAGE_OWNERSHIP (cmd , img , layout , src_stages , dst_stages , src_queue_family , dst_queue_family ) VULKAN_IMAGE_LAYOUT_TRANSITION_LEVELS(cmd, img, VK_REMAINING_MIP_LEVELS, layout, layout, 0, 0, src_stages, dst_stages, src_queue_family, dst_queue_family)
98-
9969#define VULKAN_IMAGE_LAYOUT_TRANSITION (cmd , img , old_layout , new_layout , src_access , dst_access , src_stages , dst_stages ) VULKAN_IMAGE_LAYOUT_TRANSITION_LEVELS(cmd, img, VK_REMAINING_MIP_LEVELS, old_layout, new_layout, src_access, dst_access, src_stages, dst_stages, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED)
10070
101- #define VK_DESCRIPTOR_MANAGER_RESTART (manager ) \
102- { \
103- manager->current = manager->head; \
104- manager->count = 0; \
105- }
106-
107- #define VK_MAP_PERSISTENT_TEXTURE (device , texture ) vkMapMemory(device, texture->memory, texture->offset, texture->size, 0, &texture->mapped)
108-
109- #define VULKAN_PASS_SET_TEXTURE (device , set , _sampler , binding , image_view , image_layout ) \
110- { \
111- VkDescriptorImageInfo image_info; \
112- VkWriteDescriptorSet write; \
113- image_info.sampler = _sampler; \
114- image_info.imageView = image_view; \
115- image_info.imageLayout = image_layout; \
116- write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; \
117- write.pNext = NULL; \
118- write.dstSet = set; \
119- write.dstBinding = binding; \
120- write.dstArrayElement = 0; \
121- write.descriptorCount = 1; \
122- write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; \
123- write.pImageInfo = &image_info; \
124- write.pBufferInfo = NULL; \
125- write.pTexelBufferView = NULL; \
126- vkUpdateDescriptorSets(device, 1, &write, 0, NULL); \
127- }
128-
12971#define VULKAN_SET_UNIFORM_BUFFER (_device , _set , _binding , _buffer , _offset , _range ) \
13072{ \
13173 VkWriteDescriptorSet write; \
14688 vkUpdateDescriptorSets(_device, 1, &write, 0, NULL); \
14789}
14890
149- #define VULKAN_WRITE_QUAD_VBO (pv , _x , _y , _width , _height , _tex_x , _tex_y , _tex_width , _tex_height , vulkan_color ) \
150- { \
151- float r = (vulkan_color)->r; \
152- float g = (vulkan_color)->g; \
153- float b = (vulkan_color)->b; \
154- float a = (vulkan_color)->a; \
155- pv[0].x = (_x) + 0.0f * (_width); \
156- pv[0].y = (_y) + 0.0f * (_height); \
157- pv[0].tex_x = (_tex_x) + 0.0f * (_tex_width); \
158- pv[0].tex_y = (_tex_y) + 0.0f * (_tex_height); \
159- pv[0].color.r = r; \
160- pv[0].color.g = g; \
161- pv[0].color.b = b; \
162- pv[0].color.a = a; \
163- pv[1].x = (_x) + 0.0f * (_width); \
164- pv[1].y = (_y) + 1.0f * (_height); \
165- pv[1].tex_x = (_tex_x) + 0.0f * (_tex_width); \
166- pv[1].tex_y = (_tex_y) + 1.0f * (_tex_height); \
167- pv[1].color.r = r; \
168- pv[1].color.g = g; \
169- pv[1].color.b = b; \
170- pv[1].color.a = a; \
171- pv[2].x = (_x) + 1.0f * (_width); \
172- pv[2].y = (_y) + 0.0f * (_height); \
173- pv[2].tex_x = (_tex_x) + 1.0f * (_tex_width); \
174- pv[2].tex_y = (_tex_y) + 0.0f * (_tex_height); \
175- pv[2].color.r = r; \
176- pv[2].color.g = g; \
177- pv[2].color.b = b; \
178- pv[2].color.a = a; \
179- pv[3].x = (_x) + 1.0f * (_width); \
180- pv[3].y = (_y) + 1.0f * (_height); \
181- pv[3].tex_x = (_tex_x) + 1.0f * (_tex_width); \
182- pv[3].tex_y = (_tex_y) + 1.0f * (_tex_height); \
183- pv[3].color.r = r; \
184- pv[3].color.g = g; \
185- pv[3].color.b = b; \
186- pv[3].color.a = a; \
187- pv[4].x = (_x) + 1.0f * (_width); \
188- pv[4].y = (_y) + 0.0f * (_height); \
189- pv[4].tex_x = (_tex_x) + 1.0f * (_tex_width); \
190- pv[4].tex_y = (_tex_y) + 0.0f * (_tex_height); \
191- pv[4].color.r = r; \
192- pv[4].color.g = g; \
193- pv[4].color.b = b; \
194- pv[4].color.a = a; \
195- pv[5].x = (_x) + 0.0f * (_width); \
196- pv[5].y = (_y) + 1.0f * (_height); \
197- pv[5].tex_x = (_tex_x) + 0.0f * (_tex_width); \
198- pv[5].tex_y = (_tex_y) + 1.0f * (_tex_height); \
199- pv[5].color.r = r; \
200- pv[5].color.g = g; \
201- pv[5].color.b = b; \
202- pv[5].color.a = a; \
203- }
204-
205- /* We don't have to sync against previous TRANSFER,
206- * since we observed the completion by fences.
207- *
208- * If we have a single texture_optimal, we would need to sync against
209- * previous transfers to avoid races.
210- *
211- * We would also need to optionally maintain extra textures due to
212- * changes in resolution, so this seems like the sanest and
213- * simplest solution. */
214- #define VULKAN_SYNC_TEXTURE_TO_GPU_COND_PTR (vk , tex ) \
215- if (((tex)->flags & VK_TEX_FLAG_NEED_MANUAL_CACHE_MANAGEMENT) && (tex)->memory != VK_NULL_HANDLE) \
216- VULKAN_SYNC_TEXTURE_TO_GPU(vk->context->device, (tex)->memory) \
217-
218- #define VULKAN_SYNC_TEXTURE_TO_GPU_COND_OBJ (vk , tex ) \
219- if (((tex).flags & VK_TEX_FLAG_NEED_MANUAL_CACHE_MANAGEMENT) && (tex).memory != VK_NULL_HANDLE) \
220- VULKAN_SYNC_TEXTURE_TO_GPU(vk->context->device, (tex).memory) \
221-
22291RETRO_BEGIN_DECLS
22392
22493enum vk_flags
@@ -241,7 +110,6 @@ enum vk_flags
241110 VK_FLAG_OVERLAY_FULLSCREEN = (1 << 15 )
242111};
243112
244-
245113enum vk_texture_type
246114{
247115 /* We will use the texture as a sampled linear texture. */
0 commit comments