VulkanRaytracingCycles 0.0.0
Cycles Render Engine With VulkanRaytracingShaderModules. ( Experiment , in progress)
vthreepy_types.h
Go to the documentation of this file.
1#pragma once
2#ifndef VTHREEPY_TYPES
3#define VTHREEPY_TYPES
4
5#include "config_aeolus.h"
6#include "enum.hpp"
7#include "vulkan/vulkan.h"
8#include "util/log.hpp"
9#include <vector>
10
11typedef unsigned char TypeType;
12
13#define UNDEFINED_TYPE 127
14#define FLUSH_TYPE 126
15
16
18#define CONTEXTVK 0
19
20#ifdef ENABLED_VULKAN_OPTIX
21typedef struct ContextExVk ContextVk;
22#else
23typedef struct Context0Vk ContextVk;
24#endif
25
26#define WINDOWVK 1
27typedef struct WindowVk WindowVk;
28#define DESCRIPTORVK 2
29typedef struct DescriptorVk DescriptorVk;
30#define IMAGESVK 3
31typedef struct ImagesVk ImagesVk;
32#define OVRVK 4
33typedef struct OVR OVR;
34#define OBJECTSVK 5
35typedef struct ObjectsVk ObjectsVk;
36#define VISIBLEOBJECTSVK 6
38#define ATTACHMENTSVK 7
40#define PIPELINEVK 8
41typedef struct PipelineVk PipelineVk;
42
43namespace types {
44
45 template<class T>
46 TypeType Type(T* _) {
47 if (std::is_same<T, ContextVk>::value) return CONTEXTVK;
48 else if (std::is_same<T, WindowVk>::value) return WINDOWVK;
49 else if (std::is_same<T, DescriptorVk>::value) return DESCRIPTORVK;
50 else if (std::is_same<T, ImagesVk>::value) return IMAGESVK;
51 else if (std::is_same<T, OVR>::value) return OVRVK;
52 else if (std::is_same<T, ObjectsVk>::value) return OBJECTSVK;
53 else if (std::is_same<T, VisibleObjectsVk>::value) return VISIBLEOBJECTSVK;
54 else if (std::is_same<T, AttachmentsVk>::value) return ATTACHMENTSVK;
55 else if (std::is_same<T, PipelineVk>::value) return PIPELINEVK;
57 };
58
59};
60
61
62
63
64
65typedef struct UniformVk UniformVk;
66typedef struct DescriptorVk DescriptorVk;
67namespace vkmm {
68 typedef struct Allocator_T* Allocator;
69};
70
71extern VkInstance __instance;
72extern VkPhysicalDevice __physicaldevice;
73extern VkDevice __device;
74extern VkQueue __queue;
75extern ContextVk* __ctx__;
78{
79 uint32_t stcg;
80 uint32_t stc;
81 uint32_t st;
82};
83
85
86typedef struct _Vkformat {
87
88 VkFormat COLORFORMAT;
89 VkColorSpaceKHR COLORSPACE;
90 VkFormat DEPTHFORMAT;
93
95
96extern _Vkformat __format;
97extern VkPhysicalDeviceProperties __properties;
98extern VkPhysicalDeviceFeatures __features;
99extern VkPhysicalDeviceMemoryProperties __memoryProperties;
101 VkFormat COLORFORMAT;
102 VkColorSpaceKHR COLORSPACE;
103 VkFormat DEPTHFORMAT;
104 void copy(FormatConfig form) {
106 COLORSPACE = form.COLORSPACE;
108 };
109};
110
111
112
113
114#define $instance __instance
115#define $physicaldevice __physicaldevice
116#define $device __device
117#define $queue __queue
118#define $queueIdx __queueFamilyIndices
119#define $format __format
120#define $properties __properties
121#define $features __features
122#define $memoryProperties __memoryProperties
123#define $ctx __ctx__
124
125#define $des des
126#define $tank otank
127#define $pallocator __vkmmallocator
128#define $allocator (*__vkmmallocator)
129
130
131typedef struct MBvk {
132
133 VkDeviceMemory memory;
134 VkBuffer buffer = VK_NULL_HANDLE;
135 VkIndexType idxType;
136 int version = { -1 };
137 uint32_t count;
139 memory(VK_NULL_HANDLE),
140 buffer(VK_NULL_HANDLE),
141 version(-1),
142 count(0),
143 idxType(VK_INDEX_TYPE_UINT32)
144 {};
145 bool isValid() {
146 return buffer != VK_NULL_HANDLE;
147 }
148 void dealloc() {
149 if (buffer != VK_NULL_HANDLE) {
150 vkDestroyBuffer($device, buffer, nullptr);
151 vkFreeMemory($device, memory, nullptr);
152 buffer = VK_NULL_HANDLE;
153 memory = VK_NULL_HANDLE;
154 };
155 };
156
158
159typedef struct MIBvk {
160
161 VkBuffer buffer = VK_NULL_HANDLE;
162 VkDescriptorBufferInfo info;
163 VkDeviceMemory memory = VK_NULL_HANDLE;
164 size_t size = 0;
165 uint32_t count;
166
167 int version = { -1 };
168
170 memory(VK_NULL_HANDLE),
171 buffer(VK_NULL_HANDLE),
172 info({}),
173 version(-1),
174 count(0),
175 size(0)
176 {
177 };
178
179 void dealloc() {
180 if (buffer) {
181 vkDestroyBuffer($device, buffer, nullptr);
182 vkFreeMemory($device, memory, nullptr);
183 }
184 };
185 void copy(MIBvk v) {
186 memory = v.memory;
187 buffer = v.buffer;
188 count = v.count;
189 version = v.version;
190 info = v.info;
191 size = v.size;
192 }
193 bool isValid() {
194 return buffer != VK_NULL_HANDLE;
195 }
197
198typedef struct MIBmvk {
199
200 VkDeviceMemory memory = VK_NULL_HANDLE;
201 VkDescriptorBufferInfo info;
202 VkBuffer buffer = VK_NULL_HANDLE;
203 void* mapped;
204 size_t size = 0;
205
206 int version = { -1 };
207 void dealloc() {
208 if (buffer != VK_NULL_HANDLE) {
209 vkDestroyBuffer($device, buffer, nullptr);
210 vkFreeMemory($device, memory, nullptr);
211 buffer = VK_NULL_HANDLE;
212 };
213 };
214 bool isValid() {
215 return buffer != VK_NULL_HANDLE;
216 }
217
219
220
221typedef struct MIVSIvk {
222 size_t size;
223 uint32_t w, h, d, l, c,mipLevel;
224 VkMemoryRequirements memReqs;
225 VkDeviceMemory memory;
226 VkImage image;
227 VkImageView view;
228 VkSampler sampler;
229 VkDescriptorImageInfo Info;
230 VkFormat format;
231 BYTE* mapped;
232 bool valid;
233 int version = { -1 };
234 MIVSIvk* next = nullptr;
236 memory(VK_NULL_HANDLE),
237 image(VK_NULL_HANDLE),
238 view(VK_NULL_HANDLE),
239 sampler(VK_NULL_HANDLE),
240 memReqs({}),
241 Info({}),
242 valid(false),
243 mapped(nullptr),
244 next(nullptr)
245 {
246 size = 0;
247 w = h = d = l = c = 0;
248 };
249 void dealloc() {
250 if (sampler != VK_NULL_HANDLE) vkDestroySampler($device, sampler, nullptr);
251 if (view != VK_NULL_HANDLE) vkDestroyImageView($device, view, nullptr);
252 if (image != VK_NULL_HANDLE) vkDestroyImage($device, image, nullptr);
253 if (memory != VK_NULL_HANDLE) vkFreeMemory($device, memory, nullptr);
254
255 memory = VK_NULL_HANDLE,
256 image = VK_NULL_HANDLE,
257 view = VK_NULL_HANDLE,
258 sampler = VK_NULL_HANDLE;
259 size = 0;
260 w = h = d = l = c = 0;
261 if (next != nullptr) {
262 next->dealloc();
263 delete next; next = nullptr;
264 }
265 };
266 bool isValid() {
267 return memory != VK_NULL_HANDLE;
268 }
270
271
272typedef struct MBIVSIvk {
273 size_t size;
274 uint32_t w, h, d, l, c, mipLevel;
275 VkMemoryRequirements memReqs;
276 VkDeviceMemory memory;
277 VkImage image;
278 VkImageView view;
279 VkSampler sampler;
280 VkBuffer buffer;
281 VkDescriptorImageInfo Info;
282 VkDescriptorBufferInfo bInfo;
283 VkFormat format;
284 bool valid;
285 int version = { -1 };
287 memory(VK_NULL_HANDLE),
288 image(VK_NULL_HANDLE),
289 view(VK_NULL_HANDLE),
290 sampler(VK_NULL_HANDLE),
291 buffer(VK_NULL_HANDLE),
292 memReqs({}),
293 Info({}),
294 valid(false)
295 {
296 size = 0;
297 w = h = d = l = c = 0;
298 };
299 void dealloc() {
300
301 if (sampler != VK_NULL_HANDLE) vkDestroySampler($device, sampler, nullptr);
302 if (view != VK_NULL_HANDLE) vkDestroyImageView($device, view, nullptr);
303 if (image != VK_NULL_HANDLE) vkDestroyImage($device, image, nullptr);
304 if (buffer != VK_NULL_HANDLE) vkDestroyBuffer($device,buffer, nullptr);
305 if (memory != VK_NULL_HANDLE) vkFreeMemory($device, memory, nullptr);
306
307 memory = VK_NULL_HANDLE,
308 image = VK_NULL_HANDLE,
309 view = VK_NULL_HANDLE,
310 buffer = VK_NULL_HANDLE,
311 sampler = VK_NULL_HANDLE;
312 };
313 bool isValid() {
314 return memory != VK_NULL_HANDLE;
315 }
317
318typedef struct MIVvk {
319
320 size_t size;
321 uint32_t w, h, d, l, c;
322 VkDeviceMemory memory;
323 VkImage image;
324 VkImageView view;
325 VkDescriptorImageInfo Info;
326 int version = { -1 };
328 memory(VK_NULL_HANDLE),
329 image(VK_NULL_HANDLE),
330 view(VK_NULL_HANDLE),
331 Info({})
332 {
333 size = 0;
334 w = h = d = l = c = 0;
335 };
336 void dealloc() {
337
338 if (view != VK_NULL_HANDLE) vkDestroyImageView($device, view, nullptr);
339 if (image != VK_NULL_HANDLE) vkDestroyImage($device, image, nullptr);
340 if (memory != VK_NULL_HANDLE) vkFreeMemory($device, memory, nullptr);
341
342 memory = VK_NULL_HANDLE,
343 image = VK_NULL_HANDLE,
344 view = VK_NULL_HANDLE;
345
346 };
347 bool isValid() {
348 return memory != VK_NULL_HANDLE;
349 }
350
352
353
354typedef struct PvSvk {
355
356 VkPipeline pipeline = VK_NULL_HANDLE;
357 std::vector<VkShaderModule> shaderModules;
358 PvSvk() :pipeline(VK_NULL_HANDLE), shaderModules({}) {};
359 void dealloc() {
360
361 if (pipeline != VK_NULL_HANDLE) {
362 for (auto& shaderModule : shaderModules)
363 {
364 vkDestroyShaderModule($device, shaderModule, nullptr);
365 };
366 vkDestroyPipeline($device, pipeline, nullptr);
367 pipeline = VK_NULL_HANDLE;
368 };
369
370 };
371 bool isValid() {
372 return pipeline != VK_NULL_HANDLE;
373 }
375
376typedef struct Mvk {
377
378 VkDeviceMemory memory = VK_NULL_HANDLE;
379 size_t size = 0;
380 int version = { -1 };
381 void dealloc() {
382 if (memory != VK_NULL_HANDLE) {
383 vkFreeMemory($device, memory, nullptr);
384 memory = VK_NULL_HANDLE;
385 };
386 };
387 bool isValid() {
388 return memory != VK_NULL_HANDLE;
389 }
391
392typedef struct IBmvk {
393
394 VkDescriptorBufferInfo info;
395 VkBuffer buffer = VK_NULL_HANDLE;
396 void* mapped;
397 VkDeviceSize size = 0;
398 VkDeviceSize offset = 0;
399 int version = { -1 };
400 void dealloc() {
401 if (buffer != VK_NULL_HANDLE) {
402 vkDestroyBuffer($device, buffer, nullptr);
403 buffer = VK_NULL_HANDLE;
404 };
405 };
406 bool isValid() {
407 return buffer != VK_NULL_HANDLE;
408 };
409
411
412typedef struct ImVvk :VkDescriptorBufferInfo {
413 void* mapped = nullptr;
414 int version = { -1 };
415
416 void dealloc() {
417 if (mapped != nullptr)mapped = nullptr;
418 };
419
420 bool isValid() {
421 return mapped != nullptr;
422 };
423
425
426typedef struct AttachCD {
430
431
432typedef struct SLvk {
433 VkDescriptorSet Set;
434 VkDescriptorSetLayout Layout;
436
437typedef struct Hache {
438 long id;
440 size_t hash;
442
443
444
446
447 VkPipelineLayout vkPL;
448 VkRenderPass vkRP;
449 VkPipelineCache vkPC;
450 VkPipelineVertexInputStateCreateInfo* vkPVISci;
451 std::string spv;
452 arth::GEOMETRY defulettype;
453 uint32_t multisample;
454};
455
456struct CLambda {
457
458
459 template<typename Tret, typename T>
460 static Tret lambda_ptr_exec() {
461 return (Tret)(*(T*)fn<T>())();
462 }
463
464
465
466 template<typename Tret, typename T, typename ...In>
467 static Tret lambda_ptr_exec(In... arguments) {
468 return (Tret)(*(T*)fn<T>())(arguments...);
469 }
470
471
472 template<typename Tret = void, typename T>
473 static auto vptr(T& t) {
474 using Tfp = Tret(*)(void);
475 fn<T>(&t);
476 return (Tfp)lambda_ptr_exec<Tret, T>;
477 }
478
479
480 template<typename Tret = void, typename ...In, typename T>
481 static auto ptr(T& t) {
482 using Tfp = Tret(*)(In ...);
483 fn<T>(&t);
484 return (Tfp)lambda_ptr_exec<Tret, T, In...>;
485 }
486
487 template<typename T>
488 static void* fn(void* new_fn = nullptr) {
489 static void* fn;
491 if (new_fn != nullptr)
492 fn = new_fn;
493 return fn;
494 }
495
496};
497
498typedef std::vector<VkPipelineShaderStageCreateInfo>& (*ShaderStagesTy)(void*);
499typedef VkPipelineDynamicStateCreateInfo* (*DynamicTy)(void*);
500typedef VkPipelineViewportStateCreateInfo* (*ViewportTy)(void*);
501typedef VkPipelineMultisampleStateCreateInfo* (*MultisampleTy)(void*);
502typedef VkPipelineInputAssemblyStateCreateInfo* (*InputAssemblyTy)(void*);
503typedef VkPipelineRasterizationStateCreateInfo* (*RasterizationTy)(void*);
504typedef VkPipelineDepthStencilStateCreateInfo* (*DepthStencilTy)(void*);
505typedef VkPipelineColorBlendStateCreateInfo* (*ColorBlendTy)(void*);
506
508
511
514
519
520
521};
522
523namespace info {
524
526 {
527 VkBlendOp advance;
528 VkBlendOverlapEXT overlap;
529 };
530
531 const char* String_VkBlendOp(VkBlendOp op);
532
533 //constexpr
534 VkBlendOp getVkBlendOp(const uint32_t N) noexcept;
535
536 //constexpr
537 UINT getVkBlendOpNum(const VkBlendOp op) noexcept;
538
539 const char* String_VkBlendOverlap(VkBlendOverlapEXT op);
540
541
542 extern constexpr UINT MAX_BLEND_OP = UINT(VK_BLEND_OP_BLUE_EXT) - (UINT)0x3b9d0c20;
543 extern constexpr UINT MAX_OVERLAP_OP = UINT(VK_BLEND_OVERLAP_CONJOINT_EXT) + 1;
544 extern uint64_t HAS_BLENDOP[3];
545
546
547};
548
549
550
551
552
553
554
555#endif
const char * String_VkBlendOverlap(VkBlendOverlapEXT op)
const char * String_VkBlendOp(VkBlendOp op)
constexpr UINT MAX_BLEND_OP
uint64_t HAS_BLENDOP[3]
constexpr UINT MAX_OVERLAP_OP
UINT getVkBlendOpNum(const VkBlendOp op) noexcept
VkBlendOp getVkBlendOp(const uint32_t N) noexcept
TypeType Type(T *_)
interface
struct Allocator_T * Allocator
VkColorSpaceKHR COLORSPACE
VkFormat COLORFORMAT_VR
VkFormat COLORFORMAT
VkFormat COLORFORMAT_RT
VkFormat DEPTHFORMAT
MIVvk * color
MIVvk * depth
static auto ptr(T &t)
static void * fn(void *new_fn=nullptr)
static auto vptr(T &t)
static Tret lambda_ptr_exec()
static Tret lambda_ptr_exec(In... arguments)
#include <set>
Definition: ScriptorVk.h:60
void copy(FormatConfig form)
VkFormat DEPTHFORMAT
VkColorSpaceKHR COLORSPACE
VkFormat COLORFORMAT
size_t hash
long version
int version
VkDeviceSize offset
void * mapped
VkDescriptorBufferInfo info
VkBuffer buffer
bool isValid()
VkDeviceSize size
void dealloc()
void dealloc()
void * mapped
bool isValid()
int version
VkSampler sampler
size_t size
uint32_t h
uint32_t mipLevel
uint32_t l
VkMemoryRequirements memReqs
uint32_t d
uint32_t w
VkDescriptorBufferInfo bInfo
uint32_t c
VkImageView view
VkBuffer buffer
VkDescriptorImageInfo Info
void dealloc()
VkImage image
bool isValid()
VkFormat format
VkDeviceMemory memory
uint32_t count
void dealloc()
VkBuffer buffer
bool isValid()
VkIndexType idxType
VkDeviceMemory memory
int version
size_t size
VkBuffer buffer
void dealloc()
bool isValid()
VkDescriptorBufferInfo info
void * mapped
VkDeviceMemory memory
void dealloc()
VkBuffer buffer
void copy(MIBvk v)
bool isValid()
VkDescriptorBufferInfo info
VkDeviceMemory memory
uint32_t count
int version
size_t size
void dealloc()
size_t size
VkDescriptorImageInfo Info
VkDeviceMemory memory
uint32_t l
MIVSIvk * next
uint32_t c
VkMemoryRequirements memReqs
VkFormat format
uint32_t mipLevel
uint32_t h
VkImageView view
uint32_t d
VkImage image
BYTE * mapped
uint32_t w
VkSampler sampler
bool isValid()
VkImage image
void dealloc()
bool isValid()
VkImageView view
uint32_t w
uint32_t l
int version
VkDescriptorImageInfo Info
uint32_t h
uint32_t c
VkDeviceMemory memory
uint32_t d
size_t size
VkDeviceMemory memory
size_t size
bool isValid()
int version
void dealloc()
VkPipelineLayout vkPL
VkPipelineVertexInputStateCreateInfo * vkPVISci
arth::GEOMETRY defulettype
VkPipelineCache vkPC
VkRenderPass vkRP
RasterizationTy Rasterization
InputAssemblyTy InputAssembly
void dealloc()
VkPipeline pipeline
bool isValid()
std::vector< VkShaderModule > shaderModules
VkDescriptorSetLayout Layout
VkDescriptorSet Set
VkBlendOverlapEXT overlap
VkPipelineDynamicStateCreateInfo *(* DynamicTy)(void *)
VkQueue __queue
#define IMAGESVK
DescriptorVk.
struct MBIVSIvk MBIVSIvk
struct OVR OVR
struct IBmvk IBmvk
struct SLvk SLvk
struct AttachCD AttachCD
_Vkformat __format
VkPipelineColorBlendStateCreateInfo *(* ColorBlendTy)(void *)
ContextVk * __ctx__
VkPhysicalDeviceMemoryProperties __memoryProperties
vkmm::Allocator __vkmmallocator
struct MIBmvk MIBmvk
struct PvSvk PvSvk
struct MIBvk MIBvk
unsigned char TypeType
#define PIPELINEVK
VkDevice __device
#define WINDOWVK
Context1Vk.
struct MBvk MBvk
VkPhysicalDeviceFeatures __features
VkInstance __instance
#define OVRVK
#define OBJECTSVK
VkPhysicalDevice __physicaldevice
struct _Vkformat _Vkformat
VkPipelineDepthStencilStateCreateInfo *(* DepthStencilTy)(void *)
struct MIVvk MIVvk
VkPipelineInputAssemblyStateCreateInfo *(* InputAssemblyTy)(void *)
#define CONTEXTVK
Exculsive Class Definition.
struct Mvk Mvk
ImVvk ImVvk
VkPipelineMultisampleStateCreateInfo *(* MultisampleTy)(void *)
VkPhysicalDeviceProperties __properties
#define VISIBLEOBJECTSVK
#define UNDEFINED_TYPE
VkPipelineRasterizationStateCreateInfo *(* RasterizationTy)(void *)
queueFamilyIndices __queueFamilyIndices
struct Hache Hache
struct Context0Vk ContextVk
#define ATTACHMENTSVK
struct MIVSIvk MIVSIvk
VkPipelineViewportStateCreateInfo *(* ViewportTy)(void *)
#define DESCRIPTORVK
WindowVk.
std::vector< VkPipelineShaderStageCreateInfo > &(* ShaderStagesTy)(void *)
struct PipelineVk PipelineVk