TDME2  1.9.200
VKRenderer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #if defined(_MSC_VER)
4  // this suppresses a warning redefinition of APIENTRY macro
5  #define NOMINMAX
6  #include <windows.h>
7 #endif
8 #define GLFW_INCLUDE_VULKAN
9 #include <GLFW/glfw3.h>
10 
11 #include <ext/vulkan/spirv/GlslangToSpv.h>
12 #include <ext/vulkan/svs/thsvs_simpler_vulkan_synchronization.h>
13 #include <ext/vulkan/vma/src/VmaUsage.h>
14 
15 #include <array>
16 #include <list>
17 #include <string>
18 #include <unordered_map>
19 #include <unordered_set>
20 #include <tuple>
21 #include <variant>
22 #include <vector>
23 
24 #include <tdme/tdme.h>
26 #include <tdme/engine/fwd-tdme.h>
27 #include <tdme/engine/Texture.h>
31 #include <tdme/math/fwd-tdme.h>
36 
37 using std::array;
38 using std::get;
39 using std::list;
40 using std::string;
41 using std::tuple;
42 using std::unordered_map;
43 using std::unordered_set;
44 using std::vector;
45 
60 
61 #define TEXTUREDESCRIPTORSET_MAX_TEXTURES 8
63  std::size_t operator()(const tuple<uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t>& k) const {
64  std::hash<uint64_t> hashVal;
65  return hashVal(
66  static_cast<uint64_t>(get<0>(k)) ^ (static_cast<uint64_t>(get<1>(k)) << 16) ^ (static_cast<uint64_t>(get<2>(k)) << 32) ^ (static_cast<uint64_t>(get<3>(k)) << 48) ^
67  static_cast<uint64_t>(get<4>(k)) ^ (static_cast<uint64_t>(get<5>(k)) << 16) ^ (static_cast<uint64_t>(get<6>(k)) << 32) ^ (static_cast<uint64_t>(get<7>(k)) << 48)
68  );
69  }
70 };
71 
72 /**
73  * Vulkan renderer
74  * @author Andreas Drewke
75  */
77  : public Renderer
78 {
79  friend class VKGL3CoreShaderProgram;
80 private:
81  static constexpr bool VERBOSE { false };
82  static constexpr int DRAW_COMMANDBUFFER_MAX { 3 };
83  static constexpr int SHADERSSTAGES_MAX { 2 };
84  static constexpr int TEXTUREUNITS_MAX { 16 };
85  static constexpr int SHADERS_MAX { 100 };
86  static constexpr int SHADERS_COMPUTE_MAX { 1 };
87  static constexpr int COMMANDS_MAX { 16 };
88  static constexpr int COMMANDS_MAX_GRAPHICS { 16 };
89  static constexpr int COMMANDS_MAX_COMPUTE { 5 };
90  static constexpr int DESC_MAX_UNCACHED { COMMANDS_MAX };
91  static constexpr int DESC_MAX_CACHED { 512 }; // TODO: make this dynamic
92  static constexpr int OBJECTS_VERTEX_BUFFER_COUNT { 10 };
93  static constexpr int GUI_VERTEX_BUFFER_COUNT { 4 };
94  static constexpr int POINTS_VERTEX_BUFFER_COUNT { 9 };
95  static constexpr int LINES_VERTEX_BUFFER_COUNT { 4 };
96  static constexpr int COMPUTE_STORAGE_BUFFER_COUNT { 8 };
97  static constexpr int BUFFERS_MAX { 65535 };
98  static constexpr int TEXTURES_MAX { 65535 };
99  static constexpr int PROGRAMS_MAX { 128 };
100 
101  static constexpr int CUBEMAPTEXTUREINDEX_MIN { 1 };
102 
105  VkBuffer buffer,
106  VmaAllocation allocation
107  ):
108  buffer(buffer),
110  {}
111  VkBuffer buffer;
112  VmaAllocation allocation;
113  };
114 
117  VkImage image,
118  VmaAllocation allocation,
119  VkImageView imageView,
120  VkSampler sampler
121  ):
122  image(image),
126  {}
127  VkImage image;
128  VmaAllocation allocation;
129  VkImageView imageView;
130  VkSampler sampler;
131  };
132 
135  bool memoryMappable { false };
136  int64_t frameUsedLast { -1 };
137  VkBuffer buffer { VK_NULL_HANDLE };
138  VmaAllocation allocation { VK_NULL_HANDLE };
139  uint32_t size { 0 };
140  };
141  int32_t id { 0 };
142  bool useGPUMemory { false };
143  bool shared { false };
144  list<reusable_buffer> buffers;
145  vector<reusable_buffer*> frameFreeBuffers;
146  uint32_t bufferCount { 0 };
147  int64_t frameUsedLast { -1LL };
148  int64_t frameCleanedLast { -1LL };
151  volatile bool uploading { false };
152  };
153 
156  VkBuffer buffer { VK_NULL_HANDLE };
157  VmaAllocation allocation { VK_NULL_HANDLE };
158  };
159  int bufferIdx { 0 };
160  int size { -1 };
161  vector<uint8_t> uniformBufferData;
162  // TODO: make them a growing list
163  array<uniform_buffer_type_buffer, COMMANDS_MAX_GRAPHICS * DRAW_COMMANDBUFFER_MAX * 5> buffers;
164  };
165 
166  struct shader_type {
169  const string& name,
170  const string& type,
171  const uint8_t location
172  ):
173  name(name),
174  type(type),
176  {}
177  string name;
178  string type;
179  uint8_t location;
180  };
181  struct uniform_type {
183  string name;
184  string newName;
186  int32_t position;
187  uint32_t size;
188  int32_t textureUnit;
189  };
190  vector<attribute_layout> attributeLayouts;
191  unordered_map<string, uniform_type*> uniforms;
192  vector<uniform_type*> uniformList;
193  vector<uniform_type*> samplerUniformList;
194  uint32_t uboSize { 0 };
195  uint32_t samplers { 0 };
196  int32_t maxBindings { -1 };
197  vector<uniform_buffer_type> uniformBuffers;
198  int32_t uboBindingIdx { -1 };
199  string definitions;
200  string source;
201  string file;
202  string cacheId;
203  string hash;
204  vector<uint32_t> spirv;
205  bool valid;
206  int32_t id { 0 };
207  VkShaderStageFlagBits type;
208  VkShaderModule module { VK_NULL_HANDLE };
209  };
210 
212  uint64_t id { 0 };
213  uint32_t width { 0 };
214  uint32_t height { 0 };
215  uint32_t frameBufferId { 0 };
216  array<VkPipeline, 32768> pipelines;
217  };
218 
219  struct program_type {
220  struct command_buffer {
223  array<VkDescriptorSet, DESC_MAX_UNCACHED> uboDescriptorSets;
224  array<VkDescriptorSet, DESC_MAX_UNCACHED> texturesDescriptorSetsUncached;
225  };
226  struct context {
228  array<VkDescriptorSet, DESC_MAX_CACHED> descriptorSets2; // TODO: rename those fuckers
229  unordered_map<tuple<uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t>, int, TextureDescriptorSet_Hash> texturesDescriptorSetsCache;
230  unordered_map<int32_t, unordered_set<tuple<uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t>, TextureDescriptorSet_Hash>> texturesDescriptorSetsCacheTextureIds;
232  array<command_buffer, DRAW_COMMANDBUFFER_MAX> commandBuffers;
233  };
234  int type { 0 };
235  // TODO: clear on viewport dimension change
236  vector<int32_t> shaderIds;
237  vector<shader_type*> shaders;
238  unordered_map<int32_t, string> uniformLocations;
239  uint32_t layoutBindings { 0 };
240  VkPipelineLayout pipelineLayout { VK_NULL_HANDLE };
241  VkDescriptorSetLayout uboDescriptorSetLayout { VK_NULL_HANDLE };
242  VkDescriptorSetLayout texturesDescriptorSetLayout { VK_NULL_HANDLE };
243  int32_t id { 0 };
244  vector<context> contexts;
245  };
246 
248  bool valid { false };
249  VkPipelineStageFlags srcStages { 0 };
250  VkPipelineStageFlags dstStages { 0 };
251  VkImageMemoryBarrier vkImageMemoryBarrier {};
252  array<ThsvsAccessType, 2> accessTypes { THSVS_ACCESS_NONE, THSVS_ACCESS_NONE };
253  ThsvsImageLayout svsLayout { THSVS_IMAGE_LAYOUT_GENERAL };
254  VkImageLayout vkLayout { VK_IMAGE_LAYOUT_UNDEFINED };
255  };
256 
257  struct texture_type {
259  volatile bool uploaded { false };
261  int32_t id { 0 };
262  uint32_t width { 0 };
263  uint32_t height { 0 };
264  VkFormat format { VK_FORMAT_UNDEFINED };
265  VkSampler sampler { VK_NULL_HANDLE };
266  VkImage image { VK_NULL_HANDLE };
267  VkImageAspectFlags aspectMask { 0 };
268  array<array<ThsvsAccessType, 2>, 6> accessTypes
269  {{
270  { THSVS_ACCESS_NONE, THSVS_ACCESS_NONE },
271  { THSVS_ACCESS_NONE, THSVS_ACCESS_NONE },
272  { THSVS_ACCESS_NONE, THSVS_ACCESS_NONE },
273  { THSVS_ACCESS_NONE, THSVS_ACCESS_NONE },
274  { THSVS_ACCESS_NONE, THSVS_ACCESS_NONE },
275  { THSVS_ACCESS_NONE, THSVS_ACCESS_NONE }
276  }};
277  ThsvsImageLayout svsLayout { THSVS_IMAGE_LAYOUT_OPTIMAL };
278  VkImageLayout vkLayout { VK_IMAGE_LAYOUT_UNDEFINED };
279  VmaAllocation allocation { VK_NULL_HANDLE };
280  VkImageView view { VK_NULL_HANDLE };
281  // this texture points to a cube map color buffer/depth buffer
282  // as cube map frame buffer color buffer and cube map frame buffer depth buffer are pseudo textures
283  // only providing views and samplers, but not image itself
285  int32_t cubemapTextureIndex { 0 };
286  // the cube map itself has a attached color buffer and depth buffer
289  //
290  int32_t frameBufferObjectId { 0 };
293  //
294  texture_type* bindTexture { nullptr };
295  };
296 
299  int32_t id { 0 };
301  int32_t depthTextureId { 0 };
302  int32_t colorTextureId { 0 };
303  int32_t cubemapTextureId { 0 };
304  int32_t cubemapTextureIndex { 0 };
305  int32_t depthBufferTextureId { 0 };
314  VkFramebuffer frameBuffer { VK_NULL_HANDLE };
315  VkRenderPass renderPass { VK_NULL_HANDLE };
316  };
317 
319  array<ThsvsAccessType, 2> accessTypes { THSVS_ACCESS_NONE, THSVS_ACCESS_NONE };
320  ThsvsImageLayout svsLayout { THSVS_IMAGE_LAYOUT_OPTIMAL };
321  VkImage image { VK_NULL_HANDLE };
322  VkImageView view { VK_NULL_HANDLE };
323  VkFramebuffer framebuffer { VK_NULL_HANDLE };
324  int width { -1 };
325  int height { -1 };
326  };
327 
328  struct context_type {
329  struct command_buffer {
330  VkCommandBuffer drawCommand;
331  VkFence drawFence;
333  };
334 
335  int32_t idx { 0 };
336 
337  VkCommandPool setupCommandPool;
338  VkCommandBuffer setupCommandInUse;
339  VkCommandBuffer setupCommand;
340  VkFence setupFence;
341 
343 
344  VkCommandPool drawCommandPool;
346  program_type* program { nullptr };
347 
348  //
349  uint16_t pipelineIdx;
350  VkPipeline pipeline { VK_NULL_HANDLE };
351 
352  //
353  array<command_buffer, DRAW_COMMANDBUFFER_MAX> commandBuffers;
354 
355  //
356  array<VkDescriptorBufferInfo, TEXTUREUNITS_MAX + SHADERSSTAGES_MAX> descriptorBufferInfos;
357  array<VkWriteDescriptorSet, TEXTUREUNITS_MAX + SHADERSSTAGES_MAX> descriptorWriteSets;
358  array<VkDescriptorImageInfo, TEXTUREUNITS_MAX + SHADERSSTAGES_MAX> descriptorImageInfos;
359 
360  //
361  VkBuffer boundIndicesBuffer { VK_NULL_HANDLE };
362  array<VkBuffer, 10> boundBuffers {
363  VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE,
364  VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE, VK_NULL_HANDLE,
365  VK_NULL_HANDLE, VK_NULL_HANDLE
366  };
367  array<VkDeviceSize, 10> boundBufferOffsets {
368  0, 0, 0, 0,
369  0, 0, 0, 0,
370  0, 0
371  };
372  array<uint32_t, 10> boundBufferSizes { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
373  int32_t activeTextureUnit { 0 };
374  struct bound_texture {
375  int32_t id { 0 };
376  VkSampler sampler { VK_NULL_HANDLE };
377  VkImageView view { VK_NULL_HANDLE };
378  VkImageLayout layout { VK_IMAGE_LAYOUT_UNDEFINED };
379  };
380  array<bound_texture, TEXTUREUNITS_MAX> boundTextures;
381 
382  vector<VkBuffer> computeRenderBarrierBuffers;
383 
384  uint32_t commandCount { 0 };
385 
386  bool cullingEnabled { true };
387  int frontFace { VK_FRONT_FACE_COUNTER_CLOCKWISE + 1 };
388  int frontFaceIndex { VK_FRONT_FACE_COUNTER_CLOCKWISE + 1 };
389 
390  unordered_set<int32_t> uploadedTextureIds;
391  };
392 
393  VkSurfaceKHR surface { VK_NULL_HANDLE };
394 
395  VkInstance instance { VK_NULL_HANDLE };
396  VkPhysicalDevice physicalDevice { VK_NULL_HANDLE };
397  VkDevice device { VK_NULL_HANDLE };
399  VkQueue queue { VK_NULL_HANDLE };
400  VkPhysicalDeviceProperties gpuProperties;
401  VkPhysicalDeviceFeatures gpuFeatures;
402  VkQueueFamilyProperties *queueProperties { nullptr };
403  VkPhysicalDeviceMemoryProperties memoryProperties;
404  uint32_t graphicsQueueNodeIndex { 0 };
405 
406  PFN_vkGetPhysicalDeviceSurfaceSupportKHR fpGetPhysicalDeviceSurfaceSupportKHR { nullptr };
407  PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR fpGetPhysicalDeviceSurfaceCapabilitiesKHR { nullptr };
408  PFN_vkGetPhysicalDeviceSurfaceFormatsKHR fpGetPhysicalDeviceSurfaceFormatsKHR { nullptr };
409  PFN_vkGetPhysicalDeviceSurfacePresentModesKHR fpGetPhysicalDeviceSurfacePresentModesKHR { nullptr };
410  PFN_vkCreateSwapchainKHR fpCreateSwapchainKHR { nullptr };
411  PFN_vkDestroySwapchainKHR fpDestroySwapchainKHR { nullptr };
412  PFN_vkGetSwapchainImagesKHR fpGetSwapchainImagesKHR { nullptr };
413  PFN_vkAcquireNextImageKHR fpAcquireNextImageKHR { nullptr };
414  PFN_vkQueuePresentKHR fpQueuePresentKHR { nullptr };
415 
417  VkSwapchainKHR windowSwapchain { VK_NULL_HANDLE };
418  vector<window_frambuffer_buffer_type> windowFramebufferBuffers;
419  uint32_t lastWindowFramebufferIdx { 0 };
421 
423  uint64_t framebufferPipelinesId { 0 };
425  vector<framebuffer_pipelines_type*> framebuffersPipelines;
426 
427  VkRenderPass renderPass { VK_NULL_HANDLE };
428 
429  int32_t shaderIdx { 1 };
430  int32_t bufferIdx { 1 };
431  int32_t textureIdx { 1 };
432  vector<program_type*> programVector { nullptr };
433  unordered_map<int32_t, shader_type*> shaders;
434  array<buffer_object_type*, BUFFERS_MAX + 1> buffers;
435  array<texture_type*, TEXTURES_MAX + 1> textures;
436  vector<int32_t> freeTextureIds;
437  vector<int32_t> freeBufferIds;
438  vector<framebuffer_object_type*> framebuffers { nullptr };
439 
442 
443  uint32_t windowWidth { 0 };
444  uint32_t windowHeight { 0 };
445  VkFormat windowFormat { VK_FORMAT_UNDEFINED };
446  VkColorSpaceKHR windowColorSpace { VK_COLOR_SPACE_SRGB_NONLINEAR_KHR };
447 
455 
456  VkDescriptorPool descriptorPool1 { VK_NULL_HANDLE };
457  VkDescriptorPool descriptorPool2 { VK_NULL_HANDLE };
458 
459  uint32_t queueCount { 0 };
460 
461  VkSemaphore imageAcquiredSemaphore { VK_NULL_HANDLE };
462  VkSemaphore drawCompleteSemaphore { VK_NULL_HANDLE };
463 
464  float clearRed { 0.0f };
465  float clearGreen { 0.0f };
466  float clearBlue { 0.0f };
467  float clearAlpha { 1.0f };
468 
469  VkViewport viewport;
470  VkRect2D scissor;
471 
472  int32_t boundFrameBufferId { 0 };
473 
476  VkCullModeFlagBits cullMode { VK_CULL_MODE_FRONT_BIT};
477  bool depthBufferWriting { true };
478  bool depthBufferTesting { true };
479  int depthFunction { VK_COMPARE_OP_LESS_OR_EQUAL };
480  float lineWidth { 1.0f };
481  int64_t frame { 0 };
482 
484  vector<delete_buffer_type> deleteBuffers;
485  vector<delete_image_type> deleteImages;
486 
488  vector<int32_t> disposeTextures;
489  vector<int32_t> disposeBuffers;
490  vector<VkPipeline> disposePipelines;
491 
492  VmaAllocator vmaAllocator { VK_NULL_HANDLE };
494 
495  vector<context_type> contexts;
496  vector<VkFence> contextsDrawFences;
497 
498  string deviceName;
499 
500  VkPresentModeKHR swapchainPresentMode { VK_PRESENT_MODE_IMMEDIATE_KHR };
501  VkPresentModeKHR lastSwapchainPresentMode { VK_PRESENT_MODE_IMMEDIATE_KHR };
502  bool vSync { false };
503 
506 
507  //
508  VkBool32 checkLayers(uint32_t checkCount, const char **checkNames, const vector<VkLayerProperties>& instanceLayers);
509  void setImageLayout(int contextIdx, texture_type* textureObject, const array<ThsvsAccessType,2>& nextAccessTypes, ThsvsImageLayout nextLayout, bool discardContent, uint32_t baseMipLevel = 0, uint32_t levelCount = 1, bool submit = true);
511  image_layout_change& imageLayoutChange,
512  texture_type* textureObject,
513  const array<ThsvsAccessType,2>& prevAccessTypes,
514  const array<ThsvsAccessType,2>& nextAccessTypes,
515  ThsvsImageLayout prevLayout,
516  ThsvsImageLayout nextLayout,
517  bool discardContent,
518  uint32_t baseMipLevel = 0,
519  uint32_t levelCount = 1
520  );
521  void applyImageLayoutChange(int contextIdx, const image_layout_change& imageLayoutChange, texture_type* textureObject, bool submit = true);
522  void applyImageLayoutChanges(int contextIdx, const array<image_layout_change, 8> imageLayoutChanges, array<texture_type*, 8> textureObjects, bool submit = true);
523  void setImageLayout2(int contextIdx, texture_type* textureObject, const array<ThsvsAccessType,2>& accessTypes, const array<ThsvsAccessType,2>& nextAccessTypes, ThsvsImageLayout layout, ThsvsImageLayout nextLayout, bool discardContent, uint32_t baseMipLevel, uint32_t levelCount, uint32_t baseArrayLayer, uint32_t layerCount, bool updateTextureObject);
524  void setImageLayout3(int contextIdx, VkImage image, VkImageAspectFlags aspectMask, const array<ThsvsAccessType,2>& accessTypes, const array<ThsvsAccessType,2>& nextAccessTypes, ThsvsImageLayout layout, ThsvsImageLayout nextLayout);
525  void prepareTextureImage(int contextIdx, struct texture_type* textureObject, VkImageTiling tiling, VkImageUsageFlags usage, VkFlags requiredFlags, Texture* texture, const array<ThsvsAccessType,2>& nextAccesses, ThsvsImageLayout imageLayout, bool disableMipMaps = true, uint32_t baseLevel = 0, uint32_t levelCount = 1);
526  void prepareMipMapTextureImage(int contextIdx, struct texture_type* textureObject, VkImageTiling tiling, VkImageUsageFlags usage, VkFlags requiredFlags, Texture* texture, const Texture::MipMapTexture& mipMapTexture, const array<ThsvsAccessType,2>& nextAccesses, ThsvsImageLayout imageLayout);
527  VkBuffer getBindBufferObjectInternal(int32_t bufferObjectId, uint32_t& size);
528  void createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VmaAllocation& allocation, VmaAllocationInfo& allocationInfo);
529  buffer_object_type* getBufferObjectInternal(int32_t bufferObjectId);
530  void vmaMemCpy(VmaAllocation allocationDst, const uint8_t* src, uint32_t size, uint32_t offset = 0);
531  void uploadBufferObjectInternal(int contextIdx, buffer_object_type* buffer, int32_t size, const uint8_t* data, VkBufferUsageFlagBits usage);
532  void uploadBufferObjectInternal(int contextIdx, int32_t bufferObjectId, int32_t size, const uint8_t* data, VkBufferUsageFlagBits usage);
533  texture_type* getTextureInternal(int32_t textureId);
534  texture_type* getBindTextureInternal(int32_t textureId);
537  VkPipeline getPipelineInternal(int contextIdx, program_type* programm, uint64_t framebuffePipelineId, uint32_t pipelineIdx);
538  void setProgramUniformInternal(int contextIdx, int32_t uniformId, uint8_t* data, int32_t size);
539  void initializeSwapChain();
540  void initializeFrameBuffers();
542  void requestSubmitDrawBuffers(int contextIdx);
543  void initializeRenderPass();
544  void startRenderPass(int contextIdx);
545  void endRenderPass(int contextIdx);
546  void createRenderProgram(program_type* program);
547  void createGUIRenderingPipeline(int contextIdx, program_type* program);
548  void setupGUIRenderingPipeline(int contextIdx, program_type* program);
549  void createObjectsRenderingPipeline(int contextIdx, program_type* program);
550  void setupObjectsRenderingPipeline(int contextIdx, program_type* program);
551  void createPointsRenderingPipeline(int contextIdx, program_type* program);
552  void setupPointsRenderingPipeline(int contextIdx, program_type* program);
553  void createLinesRenderingPipeline(int contextIdx, program_type* program);
554  void setupLinesRenderingPipeline(int contextIdx, program_type* program);
556  void setupSkinningComputingPipeline(int contextIdx, program_type* program);
557  void unsetPipeline(int contextIdx);
558  void prepareSetupCommandBuffer(int contextIdx);
559  void finishSetupCommandBuffer(int contextIdx);
561  void reshape();
562  void createRasterizationStateCreateInfo(int contextIdx, VkPipelineRasterizationStateCreateInfo& rasterizationStateCreateInfo);
563  void createColorBlendAttachmentState(VkPipelineColorBlendAttachmentState& blendAttachmentState);
564  void createDepthStencilStateCreateInfo(VkPipelineDepthStencilStateCreateInfo& depthStencilStateCreateInfo);
565  uint64_t createPipelineFramebufferId();
566  uint16_t createPipelineIndex(program_type* program, int contextIdx);
567  void createDepthBufferTexture(int32_t textureId, int32_t width, int32_t height, int32_t cubeMapTextureId, int32_t cubeMapTextureIndex);
568  void createBufferTexture(int32_t textureId, int32_t width, int32_t height, int32_t cubeMapTextureId, int32_t cubeMapTextureIndex, VkFormat format);
569  void drawInstancedTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset, VkBuffer indicesBuffer, int32_t instances);
570  void createFramebufferObject(int32_t frameBufferId);
571  bool beginDrawCommandBuffer(int contextIdx, int bufferId = -1);
572  VkCommandBuffer endDrawCommandBuffer(int contextIdx, int bufferId = -1, bool cycleBuffers = true);
573  void submitDrawCommandBuffers(int commandBufferCount, VkCommandBuffer* commandBuffers, VkFence& fence);
574  void uploadCubeMapSingleTexture(int contextIdx, texture_type* cubemapTextureType, Texture* texture, uint32_t baseArrayLayer);
575  void finishRendering();
576  void invalidateTextureDescriptorCaches(int textureId);
577  void invalidatePipelines();
578 
579 protected:
580  // forbid class copy
582 
583  /**
584  * Protected constructor
585  */
586  VKRenderer();
587 
588 public:
589  const string getVendor() override;
590  const string getRenderer() override;
591  const string getShaderVersion() override;
592  void initialize() override;
593  void initializeFrame() override;
594  void finishFrame() override;
595  bool isSupportingMultithreadedRendering() override;
596  bool isTextureCompressionAvailable() override;
597  bool isUsingProgramAttributeLocation() override;
598  bool isSupportingIntegerProgramAttributes() override;
599  bool isSpecularMappingAvailable() override;
600  bool isNormalMappingAvailable() override;
601  bool isInstancedRenderingAvailable() override;
602  bool isPBRAvailable() override;
603  bool isComputeShaderAvailable() override;
604  bool isGLCLAvailable() override;
605  bool isUsingShortIndices() override;
606  bool isDeferredShadingAvailable() override;
607  int32_t getTextureUnits() override;
608  int32_t loadShader(int32_t type, const string& pathName, const string& fileName, const string& definitions = string(), const string& functions = string()) override;
609  void useProgram(int contextIdx, int32_t programId) override;
610  int32_t createProgram(int type) override;
611  void attachShaderToProgram(int32_t programId, int32_t shaderId) override;
612  bool linkProgram(int32_t programId) override;
613  int32_t getProgramUniformLocation(int32_t programId, const string& name) override;
614  void setProgramUniformInteger(int contextIdx, int32_t uniformId, int32_t value) override;
615  void setProgramUniformFloat(int contextIdx, int32_t uniformId, float value) override;
616  void setProgramUniformFloatMatrix3x3(int contextIdx, int32_t uniformId, const array<float, 9>& data) override;
617  void setProgramUniformFloatMatrix4x4(int contextIdx, int32_t uniformId, const array<float, 16>& data) override;
618  void setProgramUniformFloatMatrices4x4(int contextIdx, int32_t uniformId, int32_t count, FloatBuffer* data) override;
619  void setProgramUniformFloatVec4(int contextIdx, int32_t uniformId, const array<float, 4>& data) override;
620  void setProgramUniformFloatVec3(int contextIdx, int32_t uniformId, const array<float, 3>& data) override;
621  void setProgramUniformFloatVec2(int contextIdx, int32_t uniformId, const array<float, 2>& data) override;
622  void setProgramAttributeLocation(int32_t programId, int32_t location, const string& name) override;
623  void setViewPort(int32_t width, int32_t height) override;
624  void updateViewPort() override;
625  void setClearColor(float red, float green, float blue, float alpha) override;
626  void enableCulling(int contextIdx) override;
627  void disableCulling(int contextIdx) override;
628  void setFrontFace(int contextIdx, int32_t frontFace) override;
629  void setCullFace(int32_t cullFace) override;
630  void enableBlending() override;
631  void enableAdditionBlending() override;
632  void disableBlending() override;
633  void enableDepthBufferWriting() override;
634  void disableDepthBufferWriting() override;
635  void disableDepthBufferTest() override;
636  void enableDepthBufferTest() override;
637  void setDepthFunction(int32_t depthFunction) override;
638  void setColorMask(bool red, bool green, bool blue, bool alpha) override;
639  void clear(int32_t mask) override;
640  int32_t createTexture() override;
641  int32_t createDepthBufferTexture(int32_t width, int32_t height, int32_t cubeMapTextureId, int32_t cubeMapTextureIndex) override;
642  int32_t createColorBufferTexture(int32_t width, int32_t height, int32_t cubeMapTextureId, int32_t cubeMapTextureIndex) override;
643  int32_t createGBufferGeometryTexture(int32_t width, int32_t height) override;
644  int32_t createGBufferColorTexture(int32_t width, int32_t height) override;
645  void uploadTexture(int contextIdx, Texture* texture) override;
646  void uploadCubeMapTexture(int contextIdx, Texture* textureLeft, Texture* textureRight, Texture* textureTop, Texture* textureBottom, Texture* textureFront, Texture* textureBack) override;
647  int32_t createCubeMapTexture(int contextIdx, int32_t width, int32_t height) override;
648  void resizeDepthBufferTexture(int32_t textureId, int32_t width, int32_t height) override;
649  void resizeColorBufferTexture(int32_t textureId, int32_t width, int32_t height) override;
650  void resizeGBufferGeometryTexture(int32_t textureId, int32_t width, int32_t height) override;
651  void resizeGBufferColorTexture(int32_t textureId, int32_t width, int32_t height) override;
652  void bindTexture(int contextIdx, int32_t textureId) override;
653  void bindCubeMapTexture(int contextIdx, int32_t textureId) override;
654  void disposeTexture(int32_t textureId) override;
655  int32_t createFramebufferObject(int32_t depthBufferTextureId, int32_t colorBufferTextureId, int32_t cubeMapTextureId = 0, int32_t cubeMapTextureIndex = 0) override;
657  int32_t depthBufferTextureId,
658  int32_t geometryBufferTextureId1,
659  int32_t geometryBufferTextureId2,
660  int32_t geometryBufferTextureId3,
661  int32_t colorBufferTextureId1,
662  int32_t colorBufferTextureId2,
663  int32_t colorBufferTextureId3,
664  int32_t colorBufferTextureId4,
665  int32_t colorBufferTextureId5
666  ) override;
667  void bindFrameBuffer(int32_t frameBufferId) override;
668  void disposeFrameBufferObject(int32_t frameBufferId) override;
669  vector<int32_t> createBufferObjects(int32_t bufferCount, bool useGPUMemory, bool shared) override;
670  void uploadBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, FloatBuffer* data) override;
671  void uploadBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, ShortBuffer* data) override;
672  void uploadBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, IntBuffer* data) override;
673  void uploadIndicesBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, ShortBuffer* data) override;
674  void uploadIndicesBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, IntBuffer* data) override;
675  void bindIndicesBufferObject(int contextIdx, int32_t bufferObjectId) override;
676  void bindSolidColorsBufferObject(int contextIdx, int32_t bufferObjectId) override;
677  void bindTextureCoordinatesBufferObject(int contextIdx, int32_t bufferObjectId) override;
678  void bindVerticesBufferObject(int contextIdx, int32_t bufferObjectId) override;
679  void bindVertices2BufferObject(int contextIdx, int32_t bufferObjectId) override;
680  void bindNormalsBufferObject(int contextIdx, int32_t bufferObjectId) override;
681  void bindColorsBufferObject(int contextIdx, int32_t bufferObjectId) override;
682  void bindTangentsBufferObject(int contextIdx, int32_t bufferObjectId) override;
683  void bindBitangentsBufferObject(int contextIdx, int32_t bufferObjectId) override;
684  void bindModelMatricesBufferObject(int contextIdx, int32_t bufferObjectId) override;
685  void bindEffectColorMulsBufferObject(int contextIdx, int32_t bufferObjectId, int32_t divisor) override;
686  void bindEffectColorAddsBufferObject(int contextIdx, int32_t bufferObjectIdd, int32_t divisor) override;
687  void bindOriginsBufferObject(int contextIdx, int32_t bufferObjectId) override;
688  void bindTextureSpriteIndicesBufferObject(int contextIdx, int32_t bufferObjectId) override;
689  void bindPointSizesBufferObject(int contextIdx, int32_t bufferObjectId) override;
690  void bindSpriteSheetDimensionBufferObject(int contextIdx, int32_t bufferObjectId) override;
691  void drawInstancedIndexedTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset, int32_t instances) override;
692  void drawIndexedTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset) override;
693  void drawInstancedTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset, int32_t instances) override;
694  void drawTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset) override;
695  void drawPointsFromBufferObjects(int contextIdx, int32_t points, int32_t pointsOffset) override;
696  void setLineWidth(float lineWidth) override;
697  void drawLinesFromBufferObjects(int contextIdx, int32_t points, int32_t pointsOffset) override;
698  void unbindBufferObjects(int contextIdx) override;
699  void disposeBufferObjects(vector<int32_t>& bufferObjectIds) override;
700  float readPixelDepth(int32_t x, int32_t y) override;
701  ByteBuffer* readPixels(int32_t x, int32_t y, int32_t width, int32_t height) override;
702  void initGuiMode() override;
703  void doneGuiMode() override;
704 
705  // overridden methods for skinning on GPU via compute shader
706  void dispatchCompute(int contextIdx, int32_t numNodesX, int32_t numNodesY, int32_t numNodesZ) override;
707  void memoryBarrier() override;
708  void uploadSkinningBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, FloatBuffer* data) override;
709  void uploadSkinningBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, IntBuffer* data) override;
710  void bindSkinningVerticesBufferObject(int contextIdx, int32_t bufferObjectId) override;
711  void bindSkinningNormalsBufferObject(int contextIdx, int32_t bufferObjectId) override;
712  void bindSkinningVertexJointsBufferObject(int contextIdx, int32_t bufferObjectId) override;
713  void bindSkinningVertexJointIdxsBufferObject(int contextIdx, int32_t bufferObjectId) override;
714  void bindSkinningVertexJointWeightsBufferObject(int contextIdx, int32_t bufferObjectId) override;
715  void bindSkinningVerticesResultBufferObject(int contextIdx, int32_t bufferObjectId) override;
716  void bindSkinningNormalsResultBufferObject(int contextIdx, int32_t bufferObjectId) override;
717  void bindSkinningMatricesBufferObject(int contextIdx, int32_t bufferObjectId) override;
718 
719  //
720  int32_t getTextureUnit(int contextIdx) override;
721  void setTextureUnit(int contextIdx, int32_t textureUnit) override;
722  const Renderer_Statistics getStatistics() override;
723 
724  //
725  void setVSync(bool vSync) override;
726 
727 };
Engine main class.
Definition: Engine.h:131
TDME2 engine entity shader parameters.
Frame buffer class.
Definition: FrameBuffer.h:22
Texture entity.
Definition: Texture.h:24
void setClearColor(float red, float green, float blue, float alpha) override
Set up clear color.
void prepareTextureImage(int contextIdx, struct texture_type *textureObject, VkImageTiling tiling, VkImageUsageFlags usage, VkFlags requiredFlags, Texture *texture, const array< ThsvsAccessType, 2 > &nextAccesses, ThsvsImageLayout imageLayout, bool disableMipMaps=true, uint32_t baseLevel=0, uint32_t levelCount=1)
Definition: VKRenderer.cpp:662
void enableDepthBufferWriting() override
Enable depth buffer writing.
void bindSpriteSheetDimensionBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind sprite sheet dimension buffer object.
void bindTexture(int contextIdx, int32_t textureId) override
Binds a texture with given id or unbinds when using ID_NONE.
void clear(int32_t mask) override
Clear render buffer with given mask.
void createSkinningComputingProgram(program_type *program)
void bindTangentsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind tangents buffer object.
void disposeBufferObjects(vector< int32_t > &bufferObjectIds) override
Disposes a frame buffer object.
int32_t getTextureUnit(int contextIdx) override
Get texture unit.
void setProgramUniformFloatMatrix3x3(int contextIdx, int32_t uniformId, const array< float, 9 > &data) override
Set up a float matrix 3x3 uniform value.
VkPhysicalDeviceProperties gpuProperties
Definition: VKRenderer.h:400
void doneGuiMode() override
Set up renderer for 3d rendering.
void setColorMask(bool red, bool green, bool blue, bool alpha) override
Set up GL rendering colormask.
void bindTextureCoordinatesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind texture coordinates buffer object.
void submitDrawCommandBuffers(int commandBufferCount, VkCommandBuffer *commandBuffers, VkFence &fence)
Definition: VKRenderer.cpp:387
void setImageLayout2(int contextIdx, texture_type *textureObject, const array< ThsvsAccessType, 2 > &accessTypes, const array< ThsvsAccessType, 2 > &nextAccessTypes, ThsvsImageLayout layout, ThsvsImageLayout nextLayout, bool discardContent, uint32_t baseMipLevel, uint32_t levelCount, uint32_t baseArrayLayer, uint32_t layerCount, bool updateTextureObject)
Definition: VKRenderer.cpp:579
void bindSkinningVertexJointWeightsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning vertex joint weights buffer object.
vector< delete_buffer_type > deleteBuffers
Definition: VKRenderer.h:484
void attachShaderToProgram(int32_t programId, int32_t shaderId) override
Attaches a shader to a program.
void setupObjectsRenderingPipeline(int contextIdx, program_type *program)
void dispatchCompute(int contextIdx, int32_t numNodesX, int32_t numNodesY, int32_t numNodesZ) override
Dispatch compute.
void setFrontFace(int contextIdx, int32_t frontFace) override
Set up clock wise or counter clock wise faces as front face.
void setTextureUnit(int contextIdx, int32_t textureUnit) override
Sets up texture unit.
void drawLinesFromBufferObjects(int contextIdx, int32_t points, int32_t pointsOffset) override
Draw lines from buffer objects.
void createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer &buffer, VmaAllocation &allocation, VmaAllocationInfo &allocationInfo)
void createLinesRenderingPipeline(int contextIdx, program_type *program)
void disableBlending() override
Disables blending.
PFN_vkDestroySwapchainKHR fpDestroySwapchainKHR
Definition: VKRenderer.h:411
void setProgramAttributeLocation(int32_t programId, int32_t location, const string &name) override
Bind attribute to a input location.
VkBool32 checkLayers(uint32_t checkCount, const char **checkNames, const vector< VkLayerProperties > &instanceLayers)
Definition: VKRenderer.cpp:185
void setViewPort(int32_t width, int32_t height) override
Set up viewport parameter.
PFN_vkAcquireNextImageKHR fpAcquireNextImageKHR
Definition: VKRenderer.h:413
void bindSkinningVerticesResultBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning vertices result buffer object.
void setProgramUniformFloat(int contextIdx, int32_t uniformId, float value) override
Set up a float uniform value.
const Renderer_Statistics getStatistics() override
void uploadCubeMapSingleTexture(int contextIdx, texture_type *cubemapTextureType, Texture *texture, uint32_t baseArrayLayer)
void initialize() override
Initialize renderer.
void setVSync(bool vSync) override
Enable/Disable v-sync.
int32_t createGBufferColorTexture(int32_t width, int32_t height) override
Creates a geometry buffer color RGBA texture.
PFN_vkCreateSwapchainKHR fpCreateSwapchainKHR
Definition: VKRenderer.h:410
unordered_map< int32_t, shader_type * > shaders
Definition: VKRenderer.h:433
uint16_t createPipelineIndex(program_type *program, int contextIdx)
void setProgramUniformFloatVec3(int contextIdx, int32_t uniformId, const array< float, 3 > &data) override
Set up a float vec3 uniform value.
void disposeFrameBufferObject(int32_t frameBufferId) override
Disposes a frame buffer object.
void uploadBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, FloatBuffer *data) override
Uploads buffer data to buffer object.
void uploadBufferObjectInternal(int contextIdx, buffer_object_type *buffer, int32_t size, const uint8_t *data, VkBufferUsageFlagBits usage)
void setProgramUniformInternal(int contextIdx, int32_t uniformId, uint8_t *data, int32_t size)
void memoryBarrier() override
Memory barrier.
void createBufferTexture(int32_t textureId, int32_t width, int32_t height, int32_t cubeMapTextureId, int32_t cubeMapTextureIndex, VkFormat format)
void setupSkinningComputingPipeline(int contextIdx, program_type *program)
void setProgramUniformInteger(int contextIdx, int32_t uniformId, int32_t value) override
Set up a integer uniform value.
int32_t getProgramUniformLocation(int32_t programId, const string &name) override
Returns location of given uniform variable.
void disableDepthBufferWriting() override
Disable depth buffer writing.
void createRenderProgram(program_type *program)
void setImageLayout(int contextIdx, texture_type *textureObject, const array< ThsvsAccessType, 2 > &nextAccessTypes, ThsvsImageLayout nextLayout, bool discardContent, uint32_t baseMipLevel=0, uint32_t levelCount=1, bool submit=true)
Definition: VKRenderer.cpp:419
void bindSkinningVertexJointIdxsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning vertex joint indices buffer object.
void applyImageLayoutChange(int contextIdx, const image_layout_change &imageLayoutChange, texture_type *textureObject, bool submit=true)
Definition: VKRenderer.cpp:522
void bindNormalsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind normals buffer object.
void drawPointsFromBufferObjects(int contextIdx, int32_t points, int32_t pointsOffset) override
Draw points from buffer objects.
void vmaMemCpy(VmaAllocation allocationDst, const uint8_t *src, uint32_t size, uint32_t offset=0)
void disposeTexture(int32_t textureId) override
Dispose a texture.
int32_t createColorBufferTexture(int32_t width, int32_t height, int32_t cubeMapTextureId, int32_t cubeMapTextureIndex) override
Creates a color buffer texture.
void disableCulling(int contextIdx) override
Disable culling.
VkBuffer getBindBufferObjectInternal(int32_t bufferObjectId, uint32_t &size)
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR fpGetPhysicalDeviceSurfaceCapabilitiesKHR
Definition: VKRenderer.h:407
void bindEffectColorMulsBufferObject(int contextIdx, int32_t bufferObjectId, int32_t divisor) override
Bind effect color muls buffer object.
int32_t createCubeMapTexture(int contextIdx, int32_t width, int32_t height) override
Create cube map texture from frame buffers.
void bindCubeMapTexture(int contextIdx, int32_t textureId) override
Binds a cube map texture with given id or unbinds when using ID_NONE.
framebuffer_pipelines_type * framebufferPipelinesCache
Definition: VKRenderer.h:424
void setProgramUniformFloatVec4(int contextIdx, int32_t uniformId, const array< float, 4 > &data) override
Set up a float vec4 uniform value.
void setDepthFunction(int32_t depthFunction) override
Set up depth function.
void uploadCubeMapTexture(int contextIdx, Texture *textureLeft, Texture *textureRight, Texture *textureTop, Texture *textureBottom, Texture *textureFront, Texture *textureBack) override
Uploads cube map texture data to current bound texture.
void bindFrameBuffer(int32_t frameBufferId) override
Enables a framebuffer to be rendered.
int32_t loadShader(int32_t type, const string &pathName, const string &fileName, const string &definitions=string(), const string &functions=string()) override
Loads a shader.
vector< framebuffer_pipelines_type * > framebuffersPipelines
Definition: VKRenderer.h:425
void createDepthStencilStateCreateInfo(VkPipelineDepthStencilStateCreateInfo &depthStencilStateCreateInfo)
void resizeDepthBufferTexture(int32_t textureId, int32_t width, int32_t height) override
Resizes a depth texture.
void resizeGBufferGeometryTexture(int32_t textureId, int32_t width, int32_t height) override
Resizes a geometry buffer geometry texture.
void finishFrame() override
Finish frame.
bool isInstancedRenderingAvailable() override
Checks if instanced rendering is available.
void drawTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset) override
Draw triangles from buffer objects.
void setupGUIRenderingPipeline(int contextIdx, program_type *program)
void createDepthBufferTexture(int32_t textureId, int32_t width, int32_t height, int32_t cubeMapTextureId, int32_t cubeMapTextureIndex)
void setImageLayout3(int contextIdx, VkImage image, VkImageAspectFlags aspectMask, const array< ThsvsAccessType, 2 > &accessTypes, const array< ThsvsAccessType, 2 > &nextAccessTypes, ThsvsImageLayout layout, ThsvsImageLayout nextLayout)
Definition: VKRenderer.cpp:623
void initGuiMode() override
Set up renderer for GUI rendering.
framebuffer_pipelines_type * createFramebufferPipelines(uint64_t framebufferPipelinesId)
void applyImageLayoutChanges(int contextIdx, const array< image_layout_change, 8 > imageLayoutChanges, array< texture_type *, 8 > textureObjects, bool submit=true)
Definition: VKRenderer.cpp:542
void bindSkinningVertexJointsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning vertex joints buffer object.
void setCullFace(int32_t cullFace) override
Sets up which face will be culled.
vector< int32_t > createBufferObjects(int32_t bufferCount, bool useGPUMemory, bool shared) override
Generate buffer objects for vertex data and such.
void enableBlending() override
Enables blending.
void setupPointsRenderingPipeline(int contextIdx, program_type *program)
static constexpr int COMPUTE_STORAGE_BUFFER_COUNT
Definition: VKRenderer.h:96
void setupLinesRenderingPipeline(int contextIdx, program_type *program)
void createObjectsRenderingPipeline(int contextIdx, program_type *program)
void uploadIndicesBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, ShortBuffer *data) override
Uploads buffer data to buffer object.
void drawInstancedTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset, VkBuffer indicesBuffer, int32_t instances)
bool linkProgram(int32_t programId) override
Links attached shaders to a program.
void createGUIRenderingPipeline(int contextIdx, program_type *program)
void setProgramUniformFloatMatrix4x4(int contextIdx, int32_t uniformId, const array< float, 16 > &data) override
Set up a float matrix 4x4 uniform value.
void enableCulling(int contextIdx) override
Enable culling.
vector< delete_image_type > deleteImages
Definition: VKRenderer.h:485
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR fpGetPhysicalDeviceSurfacePresentModesKHR
Definition: VKRenderer.h:409
bool beginDrawCommandBuffer(int contextIdx, int bufferId=-1)
Definition: VKRenderer.cpp:271
array< buffer_object_type *, BUFFERS_MAX+1 > buffers
Definition: VKRenderer.h:434
void bindOriginsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind origins buffer object.
int32_t createProgram(int type) override
Creates a shader program.
void bindIndicesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind indices buffer object.
void initializeFrame() override
Pre Frame Initialization.
int32_t createGBufferGeometryTexture(int32_t width, int32_t height) override
Creates a geometry buffer geometry texture.
void uploadSkinningBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, FloatBuffer *data) override
Upload skinning buffer object.
void enableAdditionBlending() override
Enable blending with c = a + b.
framebuffer_pipelines_type * getFramebufferPipelines(uint64_t framebufferPipelinesId)
void bindVerticesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind vertices buffer object.
texture_type * getBindTextureInternal(int32_t textureId)
void prepareMipMapTextureImage(int contextIdx, struct texture_type *textureObject, VkImageTiling tiling, VkImageUsageFlags usage, VkFlags requiredFlags, Texture *texture, const Texture::MipMapTexture &mipMapTexture, const array< ThsvsAccessType, 2 > &nextAccesses, ThsvsImageLayout imageLayout)
Definition: VKRenderer.cpp:753
void createRasterizationStateCreateInfo(int contextIdx, VkPipelineRasterizationStateCreateInfo &rasterizationStateCreateInfo)
void drawInstancedIndexedTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset, int32_t instances) override
Draw instanced indexed triangles from buffer objects.
void bindVertices2BufferObject(int contextIdx, int32_t bufferObjectId) override
Bind vertices 2 buffer object.
PFN_vkGetSwapchainImagesKHR fpGetSwapchainImagesKHR
Definition: VKRenderer.h:412
void useProgram(int contextIdx, int32_t programId) override
Use shader program.
void bindColorsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind colors buffer object.
void bindPointSizesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind point sizes buffer object.
void bindSkinningVerticesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning vertices buffer object.
void createColorBlendAttachmentState(VkPipelineColorBlendAttachmentState &blendAttachmentState)
void bindBitangentsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind bitangents buffer object.
void bindSkinningNormalsResultBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning normals result buffer object.
void setProgramUniformFloatMatrices4x4(int contextIdx, int32_t uniformId, int32_t count, FloatBuffer *data) override
Set up a float matrices 4x4 uniform values.
void resizeGBufferColorTexture(int32_t textureId, int32_t width, int32_t height) override
Resizes a geometry buffer color RGBA texture.
void bindSkinningMatricesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning matrices result buffer object.
int32_t createGeometryBufferObject(int32_t depthBufferTextureId, int32_t geometryBufferTextureId1, int32_t geometryBufferTextureId2, int32_t geometryBufferTextureId3, int32_t colorBufferTextureId1, int32_t colorBufferTextureId2, int32_t colorBufferTextureId3, int32_t colorBufferTextureId4, int32_t colorBufferTextureId5) override
Creates a geometry frame buffer object.
vector< window_frambuffer_buffer_type > windowFramebufferBuffers
Definition: VKRenderer.h:418
void updateViewPort() override
Update viewport.
void createFramebufferObject(int32_t frameBufferId)
VkPipeline getPipelineInternal(int contextIdx, program_type *programm, uint64_t framebuffePipelineId, uint32_t pipelineIdx)
void bindModelMatricesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind model matrices buffer object.
void createPointsRenderingPipeline(int contextIdx, program_type *program)
void drawIndexedTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset) override
Draw indexed triangles from buffer objects.
void disableDepthBufferTest() override
Disable depth buffer test.
void bindSkinningNormalsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind skinning normal buffer object.
void unbindBufferObjects(int contextIdx) override
Unbind buffer objects.
array< texture_type *, TEXTURES_MAX+1 > textures
Definition: VKRenderer.h:435
VkPhysicalDeviceMemoryProperties memoryProperties
Definition: VKRenderer.h:403
texture_type * getTextureInternal(int32_t textureId)
void bindEffectColorAddsBufferObject(int contextIdx, int32_t bufferObjectIdd, int32_t divisor) override
Bind effect color adds buffer object.
int32_t createTexture() override
Creates a texture.
VkQueueFamilyProperties * queueProperties
Definition: VKRenderer.h:402
float readPixelDepth(int32_t x, int32_t y) override
Reads a pixel depth.
void uploadTexture(int contextIdx, Texture *texture) override
Uploads texture data to current bound texture.
void getImageLayoutChange(image_layout_change &imageLayoutChange, texture_type *textureObject, const array< ThsvsAccessType, 2 > &prevAccessTypes, const array< ThsvsAccessType, 2 > &nextAccessTypes, ThsvsImageLayout prevLayout, ThsvsImageLayout nextLayout, bool discardContent, uint32_t baseMipLevel=0, uint32_t levelCount=1)
Definition: VKRenderer.cpp:471
VkCommandBuffer endDrawCommandBuffer(int contextIdx, int bufferId=-1, bool cycleBuffers=true)
Definition: VKRenderer.cpp:357
void setLineWidth(float lineWidth) override
Set line width.
ByteBuffer * readPixels(int32_t x, int32_t y, int32_t width, int32_t height) override
Read pixels.
void enableDepthBufferTest() override
Enable depth buffer test.
void resizeColorBufferTexture(int32_t textureId, int32_t width, int32_t height) override
Resize color buffer texture.
static constexpr int OBJECTS_VERTEX_BUFFER_COUNT
Definition: VKRenderer.h:92
void bindTextureSpriteIndicesBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind texture and sprite indices buffer object.
void setProgramUniformFloatVec2(int contextIdx, int32_t uniformId, const array< float, 2 > &data) override
Set up a float vec2 uniform value.
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR fpGetPhysicalDeviceSurfaceFormatsKHR
Definition: VKRenderer.h:408
buffer_object_type * getBufferObjectInternal(int32_t bufferObjectId)
void bindSolidColorsBufferObject(int contextIdx, int32_t bufferObjectId) override
Bind solid colors buffer object.
PFN_vkGetPhysicalDeviceSurfaceSupportKHR fpGetPhysicalDeviceSurfaceSupportKHR
Definition: VKRenderer.h:406
vector< framebuffer_object_type * > framebuffers
Definition: VKRenderer.h:438
Matrix3x3 class representing matrix3x3 mathematical structure and operations for 2d space.
Definition: Matrix3x3.h:20
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Definition: Matrix4x4.h:23
Mutex implementation.
Definition: Mutex.h:19
Implementation for read/write lock.
Definition: ReadWriteLock.h:17
Spin Lock implementation.
Definition: SpinLock.h:17
Byte buffer class.
Definition: ByteBuffer.h:27
Float buffer class.
Definition: FloatBuffer.h:18
Integer buffer class.
Definition: IntBuffer.h:14
Short buffer class.
Definition: ShortBuffer.h:14
std::size_t operator()(const tuple< uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t > &k) const
Definition: VKRenderer.h:63
array< VkDescriptorBufferInfo, TEXTUREUNITS_MAX+SHADERSSTAGES_MAX > descriptorBufferInfos
Definition: VKRenderer.h:356
array< bound_texture, TEXTUREUNITS_MAX > boundTextures
Definition: VKRenderer.h:380
array< command_buffer, DRAW_COMMANDBUFFER_MAX > commandBuffers
Definition: VKRenderer.h:353
array< VkDescriptorImageInfo, TEXTUREUNITS_MAX+SHADERSSTAGES_MAX > descriptorImageInfos
Definition: VKRenderer.h:358
array< VkWriteDescriptorSet, TEXTUREUNITS_MAX+SHADERSSTAGES_MAX > descriptorWriteSets
Definition: VKRenderer.h:357
delete_buffer_type(VkBuffer buffer, VmaAllocation allocation)
Definition: VKRenderer.h:104
delete_image_type(VkImage image, VmaAllocation allocation, VkImageView imageView, VkSampler sampler)
Definition: VKRenderer.h:116
array< VkDescriptorSet, DESC_MAX_UNCACHED > texturesDescriptorSetsUncached
Definition: VKRenderer.h:224
unordered_map< tuple< uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t >, int, TextureDescriptorSet_Hash > texturesDescriptorSetsCache
Definition: VKRenderer.h:229
array< VkDescriptorSet, DESC_MAX_CACHED > descriptorSets2
Definition: VKRenderer.h:228
array< command_buffer, DRAW_COMMANDBUFFER_MAX > commandBuffers
Definition: VKRenderer.h:232
unordered_map< int32_t, unordered_set< tuple< uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, uint16_t >, TextureDescriptorSet_Hash > > texturesDescriptorSetsCacheTextureIds
Definition: VKRenderer.h:230
attribute_layout(const string &name, const string &type, const uint8_t location)
Definition: VKRenderer.h:168
unordered_map< string, uniform_type * > uniforms
Definition: VKRenderer.h:191
array< array< ThsvsAccessType, 2 >, 6 > accessTypes
Definition: VKRenderer.h:269
array< uniform_buffer_type_buffer, COMMANDS_MAX_GRAPHICS *DRAW_COMMANDBUFFER_MAX *5 > buffers
Definition: VKRenderer.h:163
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6