Advertisement
Guest User

Untitled

a guest
Dec 11th, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 24.95 KB | None | 0 0
  1. #pragma once
  2.  
  3. //Shader binaries, in headers to avoid clutter
  4. //TODO: Maybe should use a macro to clean this up at least a little.
  5. #include "shaders/generic_colored_frag.h"
  6. const VkShaderModuleCreateInfo generic_colored_frag_info =
  7. {
  8.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  9.     nullptr, //pNext,
  10.     0, //flags,
  11.     sizeof(generic_colored_frag), //codesize
  12.     (uint32_t*)generic_colored_frag //pCode
  13. };
  14. VkShaderModule generic_colored_frag_module;
  15.  
  16. #include "shaders/screen_colored_vert.h"
  17. const VkShaderModuleCreateInfo screen_colored_vert_info =
  18. {
  19.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  20.     nullptr, //pNext
  21.     0, //flags
  22.     sizeof(screen_colored_vert), //codeSize
  23.     (uint32_t*)screen_colored_vert //pCode
  24. };
  25. VkShaderModule screen_colored_vert_module;
  26.  
  27. #include "shaders/screen_textured_frag.h"
  28. const VkShaderModuleCreateInfo screen_textured_frag_info =
  29. {
  30.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  31.     nullptr, //pNext
  32.     0, //flags
  33.     sizeof(screen_textured_frag), //codeSize
  34.     (uint32_t*)screen_textured_frag, //pCode
  35. };
  36. VkShaderModule screen_textured_frag_module;
  37.  
  38. #include "shaders/screen_textured_vert.h"
  39. const VkShaderModuleCreateInfo screen_textured_vert_info =
  40. {
  41.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  42.     nullptr,
  43.     0,
  44.     sizeof(screen_textured_vert),
  45.     (uint32_t*)screen_textured_vert,
  46. };
  47. VkShaderModule screen_textured_vert_module;
  48.  
  49. //ref_vk requires the following vertex formats:
  50. //screen: vec3 position, vec4 color, vec2 UVs
  51. //world: vec3 position, vec2 UV, vec2 lightmapUV, int layer;
  52. //alias: int index, vec2 UV. Actual vertex position is calculated at runtime from a storage buffer.
  53.  
  54. const VkVertexInputBindingDescription screen_vertex_binding =
  55. {
  56.     0, //binding
  57.     sizeof(float) * 9, //stride
  58.     VK_VERTEX_INPUT_RATE_VERTEX //inputRate
  59. };
  60.  
  61. const VkVertexInputAttributeDescription screen_vertex_attributes[] =
  62. {
  63.     {
  64.         0, //location
  65.         0, //binding
  66.         VK_FORMAT_R32G32B32_SFLOAT, //format
  67.         0 //offset
  68.     },
  69.     {
  70.         1,
  71.         0,
  72.         VK_FORMAT_R32G32B32A32_SFLOAT,
  73.         3 * sizeof(float)
  74.     },
  75.     {
  76.         2,
  77.         0,
  78.         VK_FORMAT_R32G32_SFLOAT,
  79.         7 * sizeof(float)
  80.     }
  81. };
  82.  
  83. const VkPipelineVertexInputStateCreateInfo screen_vertex_info =
  84. {
  85.     VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
  86.     nullptr, //pNext
  87.     0, //flags
  88.     1, //vertexBindingDescriptionCount,
  89.     &screen_vertex_binding, //pVertexBindingDescriptions
  90.     sizeof(screen_vertex_attributes) / sizeof(screen_vertex_attributes[0]), //vertexAttributeDescriptionCount
  91.     screen_vertex_attributes //pVertexAttributeDescriptions
  92. };
  93.  
  94. /*typedef struct VkPipelineInputAssemblyStateCreateInfo {
  95.     VkStructureType                            sType;
  96.     const void*                                pNext;
  97.     VkPipelineInputAssemblyStateCreateFlags    flags;
  98.     VkPrimitiveTopology                        topology;
  99.     VkBool32                                   primitiveRestartEnable;
  100. } VkPipelineInputAssemblyStateCreateInfo;*/
  101.  
  102. const VkPipelineInputAssemblyStateCreateInfo triangle_input_info =
  103. {
  104.     VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
  105.     nullptr, //pNext
  106.     0, //flags,
  107.     VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, //topology
  108.     VK_FALSE //primitiveRestartEnable
  109. };
  110.  
  111. //This stands as a substitute for quads when rendering UI elements
  112. const VkPipelineInputAssemblyStateCreateInfo triangle_strip_input_info =
  113. {
  114.     VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
  115.     nullptr, //pNext
  116.     0, //flags,
  117.     VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, //topology
  118.     VK_FALSE //primitiveRestartEnable
  119. };
  120.  
  121. //Single points, used for particles.
  122. const VkPipelineInputAssemblyStateCreateInfo point_input_info =
  123. {
  124.     VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
  125.     nullptr, //pNext
  126.     0, //flags,
  127.     VK_PRIMITIVE_TOPOLOGY_POINT_LIST, //topology
  128.     VK_FALSE //primitiveRestartEnable
  129. };
  130.  
  131. //These must be filled out at pipeline compile time, and therefore aren't consts.
  132. VkRect2D scissors_rect;
  133. VkViewport viewport, viewport_depthhack;
  134.  
  135. /*typedef struct VkPipelineViewportStateCreateInfo {
  136.     VkStructureType                       sType;
  137.     const void* pNext;
  138.     VkPipelineViewportStateCreateFlags    flags;
  139.     uint32_t                              viewportCount;
  140.     const VkViewport* pViewports;
  141.     uint32_t                              scissorCount;
  142.     const VkRect2D* pScissors;
  143. } VkPipelineViewportStateCreateInfo;*/
  144.  
  145. const VkDynamicState viewport_dynamic_states[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
  146.  
  147. const VkPipelineDynamicStateCreateInfo viewport_dynamic_info =
  148. {
  149.     VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
  150.     nullptr,
  151.     0, //flags
  152.     2, //dynamicStateCount,
  153.     viewport_dynamic_states //pDynamicState
  154. };
  155.  
  156. const VkPipelineViewportStateCreateInfo viewport_info =
  157. {
  158.     VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
  159.     nullptr, //pNext,
  160.     0, //flags,
  161.     1, //viewportCount
  162.     &viewport, //pViewports
  163.     1, //scissorCount
  164.     &scissors_rect //pScissors
  165. };
  166.  
  167. const VkPipelineViewportStateCreateInfo viewport_depthhack_info =
  168. {
  169.     VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
  170.     nullptr, //pNext,
  171.     0, //flags,
  172.     1, //viewportCount
  173.     & viewport_depthhack, //pViewports
  174.     1, //scissorCount
  175.     & scissors_rect //pScissors
  176. };
  177.  
  178. /*typedef struct VkPipelineRasterizationStateCreateInfo {
  179.     VkStructureType                            sType;
  180.     const void* pNext;
  181.     VkPipelineRasterizationStateCreateFlags    flags;
  182.     VkBool32                                   depthClampEnable;
  183.     VkBool32                                   rasterizerDiscardEnable;
  184.     VkPolygonMode                              polygonMode;
  185.     VkCullModeFlags                            cullMode;
  186.     VkFrontFace                                frontFace;
  187.     VkBool32                                   depthBiasEnable;
  188.     float                                      depthBiasConstantFactor;
  189.     float                                      depthBiasClamp;
  190.     float                                      depthBiasSlopeFactor;
  191.     float                                      lineWidth;
  192. } VkPipelineRasterizationStateCreateInfo;*/
  193.  
  194. const VkPipelineRasterizationStateCreateInfo rasterization_info =
  195. {
  196.     VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
  197.     nullptr,
  198.     0, //flags,
  199.     VK_FALSE, //depthClampEnable
  200.     VK_FALSE, //rasterizerDiscardEnable,
  201.     VK_POLYGON_MODE_FILL, //polygonMode,
  202.     VK_CULL_MODE_BACK_BIT, //cullMode
  203.     VK_FRONT_FACE_COUNTER_CLOCKWISE, //frontFace,
  204.     VK_FALSE, //depthBiasEnable
  205.     0, //depthBiasConstantFactor
  206.     0, //depthBiasClamp
  207.     0, //depthBiasSlopeFactor
  208.     1.0f //lineWidth
  209. };
  210.  
  211. const VkPipelineRasterizationStateCreateInfo rasterization_info_wires =
  212. {
  213.     VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
  214.     nullptr,
  215.     0, //flags,
  216.     VK_FALSE, //depthClampEnable
  217.     VK_FALSE, //rasterizerDiscardEnable,
  218.     VK_POLYGON_MODE_LINE, //polygonMode,
  219.     VK_CULL_MODE_BACK_BIT, //cullMode
  220.     VK_FRONT_FACE_COUNTER_CLOCKWISE, //frontFace,
  221.     VK_FALSE, //depthBiasEnable
  222.     0, //depthBiasConstantFactor
  223.     0, //depthBiasClamp
  224.     0, //depthBiasSlopeFactor
  225.     1.0f //lineWidth
  226. };
  227.  
  228. //Alias winding flips the faces, just change the culling rather than bother with fixing the winding
  229. const VkPipelineRasterizationStateCreateInfo rasterization_info_alias =
  230. {
  231.     VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
  232.     nullptr,
  233.     0, //flags,
  234.     VK_FALSE, //depthClampEnable
  235.     VK_FALSE, //rasterizerDiscardEnable,
  236.     VK_POLYGON_MODE_FILL, //polygonMode,
  237.     VK_CULL_MODE_FRONT_BIT, //cullMode
  238.     VK_FRONT_FACE_COUNTER_CLOCKWISE, //frontFace,
  239.     VK_FALSE, //depthBiasEnable
  240.     0, //depthBiasConstantFactor
  241.     0, //depthBiasClamp
  242.     0, //depthBiasSlopeFactor
  243.     1.0f //lineWidth
  244. };
  245.  
  246. /*typedef struct VkPipelineMultisampleStateCreateInfo {
  247.     VkStructureType                          sType;
  248.     const void*                              pNext;
  249.     VkPipelineMultisampleStateCreateFlags    flags;
  250.     VkSampleCountFlagBits                    rasterizationSamples;
  251.     VkBool32                                 sampleShadingEnable;
  252.     float                                    minSampleShading;
  253.     const VkSampleMask*                      pSampleMask;
  254.     VkBool32                                 alphaToCoverageEnable;
  255.     VkBool32                                 alphaToOneEnable;
  256. } VkPipelineMultisampleStateCreateInfo;*/
  257.  
  258. const VkPipelineMultisampleStateCreateInfo no_multisample_info =
  259. {
  260.     VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
  261.     nullptr, //pNext,
  262.     0, //flags
  263.     VK_SAMPLE_COUNT_1_BIT, //rasterizationSamples
  264. };
  265.  
  266. /*
  267. typedef struct VkPipelineDepthStencilStateCreateInfo {
  268.     VkStructureType                           sType;
  269.     const void*                               pNext;
  270.     VkPipelineDepthStencilStateCreateFlags    flags;
  271.     VkBool32                                  depthTestEnable;
  272.     VkBool32                                  depthWriteEnable;
  273.     VkCompareOp                               depthCompareOp;
  274.     VkBool32                                  depthBoundsTestEnable;
  275.     VkBool32                                  stencilTestEnable;
  276.     VkStencilOpState                          front;
  277.     VkStencilOpState                          back;
  278.     float                                     minDepthBounds;
  279.     float                                     maxDepthBounds;
  280. } VkPipelineDepthStencilStateCreateInfo;*/
  281.  
  282. const VkPipelineDepthStencilStateCreateInfo no_depth_test_state =
  283. {
  284.     VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
  285.     nullptr, //pNext,
  286.     0, //flags,
  287.     VK_FALSE //depthTestEnable
  288. };
  289.  
  290. const VkPipelineDepthStencilStateCreateInfo full_depth_test_state =
  291. {
  292.     VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
  293.     nullptr, //pNext,
  294.     0, //flags,
  295.     VK_TRUE, //depthTestEnable
  296.     VK_TRUE, //depthWriteEnable
  297.     VK_COMPARE_OP_LESS_OR_EQUAL //depthCompareOp
  298. };
  299.  
  300. const VkPipelineDepthStencilStateCreateInfo depth_test_no_write_state =
  301. {
  302.     VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
  303.     nullptr, //pNext,
  304.     0, //flags,
  305.     VK_TRUE, //depthTestEnable
  306.     VK_FALSE, //depthWriteEnable
  307.     VK_COMPARE_OP_LESS_OR_EQUAL //depthCompareOp
  308. };
  309.  
  310. /*typedef struct VkPipelineColorBlendAttachmentState
  311. {
  312.     VkBool32                 blendEnable;
  313.     VkBlendFactor            srcColorBlendFactor;
  314.     VkBlendFactor            dstColorBlendFactor;
  315.     VkBlendOp                colorBlendOp;
  316.     VkBlendFactor            srcAlphaBlendFactor;
  317.     VkBlendFactor            dstAlphaBlendFactor;
  318.     VkBlendOp                alphaBlendOp;
  319.     VkColorComponentFlags    colorWriteMask;
  320. } VkPipelineColorBlendAttachmentState;*/
  321.  
  322.  
  323. const VkPipelineColorBlendAttachmentState color_attachment_no_blend_state =
  324. {
  325.     VK_FALSE, //blendEnable
  326.     VK_BLEND_FACTOR_ZERO, //srcColorBlendFactor
  327.     VK_BLEND_FACTOR_ZERO, //dstColorBlendFactor
  328.     VK_BLEND_OP_ADD, //colorBlendOp
  329.     VK_BLEND_FACTOR_ZERO, //srcAlphaBlendFactor
  330.     VK_BLEND_FACTOR_ZERO, //dstAlphaBlendFactor
  331.     VK_BLEND_OP_ADD, //alphaBlendOp
  332.     VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT |  VK_COLOR_COMPONENT_A_BIT //colorWriteMask
  333. };
  334.  
  335. /*typedef struct VkPipelineColorBlendStateCreateInfo {
  336.     VkStructureType                               sType;
  337.     const void*                                   pNext;
  338.     VkPipelineColorBlendStateCreateFlags          flags;
  339.     VkBool32                                      logicOpEnable;
  340.     VkLogicOp                                     logicOp;
  341.     uint32_t                                      attachmentCount;
  342.     const VkPipelineColorBlendAttachmentState*    pAttachments;
  343.     float                                         blendConstants[4];
  344. } VkPipelineColorBlendStateCreateInfo;*/
  345.  
  346. const VkPipelineColorBlendStateCreateInfo no_blend_info =
  347. {
  348.     VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
  349.     nullptr, //pNext
  350.     0, //flags
  351.     VK_FALSE, //logicOpEnable
  352.     VK_LOGIC_OP_CLEAR, //logicOp
  353.     1, //attachmentCount
  354.     &color_attachment_no_blend_state,
  355. };
  356.  
  357. const VkPipelineColorBlendAttachmentState color_attachment_normal_blend_state =
  358. {
  359.     VK_TRUE, //blendEnable
  360.     VK_BLEND_FACTOR_SRC_ALPHA, //srcColorBlendFactor
  361.     VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, //dstColorBlendFactor
  362.     VK_BLEND_OP_ADD, //colorBlendOp
  363.     VK_BLEND_FACTOR_SRC_ALPHA, //srcAlphaBlendFactor
  364.     VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, //dstAlphaBlendFactor
  365.     VK_BLEND_OP_ADD, //alphaBlendOp
  366.     VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT //colorWriteMask
  367. };
  368.  
  369. const VkPipelineColorBlendStateCreateInfo normal_blend_info =
  370. {
  371.     VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
  372.     nullptr, //pNext
  373.     0, //flags
  374.     VK_FALSE, //logicOpEnable
  375.     VK_LOGIC_OP_CLEAR, //logicOp
  376.     1, //attachmentCount
  377.     &color_attachment_normal_blend_state,
  378. };
  379.  
  380. //here just in case I decide to support vk_flashblend
  381. const VkPipelineColorBlendAttachmentState color_attachment_additive_blend_state =
  382. {
  383.     VK_TRUE, //blendEnable
  384.     VK_BLEND_FACTOR_SRC_ALPHA, //srcColorBlendFactor
  385.     VK_BLEND_FACTOR_ONE, //dstColorBlendFactor
  386.     VK_BLEND_OP_ADD, //colorBlendOp
  387.     VK_BLEND_FACTOR_SRC_ALPHA, //srcAlphaBlendFactor
  388.     VK_BLEND_FACTOR_ONE, //dstAlphaBlendFactor
  389.     VK_BLEND_OP_ADD, //alphaBlendOp
  390.     VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT //colorWriteMask
  391. };
  392.  
  393. const VkPipelineColorBlendStateCreateInfo additive_blend_info =
  394. {
  395.     VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
  396.     nullptr, //pNext
  397.     0, //flags
  398.     VK_FALSE, //logicOpEnable
  399.     VK_LOGIC_OP_CLEAR, //logicOp
  400.     1, //attachmentCount
  401.     & color_attachment_additive_blend_state,
  402. };
  403.  
  404. /*typedef struct VkDescriptorSetLayoutBinding {
  405.     uint32_t              binding;
  406.     VkDescriptorType      descriptorType;
  407.     uint32_t              descriptorCount;
  408.     VkShaderStageFlags    stageFlags;
  409.     const VkSampler*      pImmutableSamplers;
  410. } VkDescriptorSetLayoutBinding;*/
  411.  
  412. const VkDescriptorSetLayoutBinding projection_layout_binding =
  413. {
  414.     0, //binding
  415.     VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, //descriptorType
  416.     1, //descriptorCount
  417.     VK_SHADER_STAGE_VERTEX_BIT //stageFlags
  418. };
  419.  
  420. const VkDescriptorSetLayoutBinding modelview_layout_binding =
  421. {
  422.     0,
  423.     VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
  424.     1,
  425.     VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT
  426. };
  427.  
  428. const VkDescriptorSetLayoutBinding dynamic_uniform_layout_binding =
  429. {
  430.     0,
  431.     VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
  432.     1,
  433.     VK_SHADER_STAGE_VERTEX_BIT
  434. };
  435.  
  436. const VkDescriptorSetLayoutBinding alias_storage_layout_binding =
  437. {
  438.     0,
  439.     VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
  440.     1,
  441.     VK_SHADER_STAGE_VERTEX_BIT
  442. };
  443.  
  444. const VkDescriptorSetLayoutBinding texture_layout_binding =
  445. {
  446.     0,
  447.     VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
  448.     1,
  449.     VK_SHADER_STAGE_FRAGMENT_BIT
  450. };
  451.  
  452. //ref_vk requires XXX pipelines:
  453. //screen_colored: Simple colored polygons. uses screen vertex attributes. uses projection/modelview descriptors at slot 0.
  454. //screen_textured: Simple textured polygons. uses screen vertex attributes. uses projection/modelview descriptors at slot 0. uses combined image sampler at slot 1.
  455. //world_lightmap: Lightmapped 3d polygons. Uses world vertex attributes. uses projection/modelview descriptors at slot 0. Uses combined image sampler at slot 2. Uses combined image sampler (lightmap array) at slot 3.
  456. // Fragment shader push constant has the modulate value.
  457. //world_lightmap_unclamped: Same as world_lightmap, but different fragment shader allows overbrights.
  458. //world_warp: Same as world_lightmap, but no lightmap descriptor. Warps the world
  459. //world_sky: Skybox. Uses world vertex attributes, but most properties are ignored. uses projection_modeview descriptors at slot 0. Uses combined image sampler at slot 2, cubemap array texture.
  460. //alias_vertexlit: Vertex lit 3d polygons. uses alias vertex attributes. uses projection/modelview descriptors at slot 0. Uses vertex storage buffer at slot 1. Uses combined image sampler at slot 2.
  461. //laser_colored: Laser beams. TBD
  462. //sprite_textured: Sprites. TBD.
  463.  
  464. //brush model specific data.
  465.  
  466. #include "shaders/world_lightmap_frag.h"
  467. const VkShaderModuleCreateInfo world_lightmap_frag_info =
  468. {
  469.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  470.     nullptr,
  471.     0,
  472.     sizeof(world_lightmap_frag),
  473.     world_lightmap_frag,
  474.    
  475. };
  476. VkShaderModule world_lightmap_frag_module;
  477.  
  478. #include "shaders/world_lightmap_unclamped_frag.h"
  479. const VkShaderModuleCreateInfo world_lightmap_unclamped_frag_info =
  480. {
  481.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  482.     nullptr,
  483.     0,
  484.     sizeof(world_lightmap_unclamped_frag),
  485.     world_lightmap_unclamped_frag,
  486.    
  487. };
  488. VkShaderModule world_lightmap_unclamped_frag_module;
  489.  
  490. #include "shaders/world_lightmap_only_frag.h"
  491. const VkShaderModuleCreateInfo world_lightmap_only_frag_info =
  492. {
  493.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  494.     nullptr,
  495.     0,
  496.     sizeof(world_lightmap_only_frag),
  497.     world_lightmap_only_frag,
  498.    
  499. };
  500. VkShaderModule world_lightmap_only_frag_module;
  501.  
  502. #include "shaders/world_lightmap_vert.h"
  503. const VkShaderModuleCreateInfo world_lightmap_vert_info =
  504. {
  505.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  506.     nullptr,
  507.     0,
  508.     sizeof(world_lightmap_vert),
  509.     world_lightmap_vert,
  510. };
  511. VkShaderModule world_lightmap_vert_module;
  512.  
  513. const VkVertexInputBindingDescription world_vertex_binding =
  514. {
  515.     0, //binding
  516.     sizeof(float) * 9, //stride
  517.     VK_VERTEX_INPUT_RATE_VERTEX, //inputRate
  518. };
  519.  
  520. const VkVertexInputAttributeDescription world_vertex_attributes[] =
  521. {
  522.     { //position
  523.         0, //location
  524.         0, //binding
  525.         VK_FORMAT_R32G32B32_SFLOAT, //format
  526.         0 //offset
  527.     },
  528.     { //uv
  529.         1,
  530.         0,
  531.         VK_FORMAT_R32G32_SFLOAT,
  532.         3 * sizeof(float)
  533.     },
  534.     { //scroll_speed
  535.         2,
  536.         0,
  537.         VK_FORMAT_R32_SFLOAT,
  538.         5 * sizeof(float)
  539.     },
  540.     { //lightmap uv
  541.         3,
  542.         0,
  543.         VK_FORMAT_R32G32_SFLOAT,
  544.         6 * sizeof(float)
  545.     },
  546.     { //lightmap layer
  547.         4,
  548.         0,
  549.         VK_FORMAT_R32_UINT,
  550.         8 * sizeof(float)
  551.     }
  552. };
  553.  
  554. /*typedef struct VkPipelineVertexInputStateCreateInfo {
  555.     VkStructureType                             sType;
  556.     const void*                                 pNext;
  557.     VkPipelineVertexInputStateCreateFlags       flags;
  558.     uint32_t                                    vertexBindingDescriptionCount;
  559.     const VkVertexInputBindingDescription*      pVertexBindingDescriptions;
  560.     uint32_t                                    vertexAttributeDescriptionCount;
  561.     const VkVertexInputAttributeDescription*    pVertexAttributeDescriptions;
  562. } VkPipelineVertexInputStateCreateInfo;*/
  563.  
  564. const VkPipelineVertexInputStateCreateInfo world_vertex_info =
  565. {
  566.     VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
  567.     nullptr,
  568.     0,
  569.     1,
  570.     &world_vertex_binding,
  571.     sizeof(world_vertex_attributes) / sizeof(world_vertex_attributes[0]),
  572.     world_vertex_attributes
  573. };
  574.  
  575. /*typedef struct VkPushConstantRange {
  576.     VkShaderStageFlags    stageFlags;
  577.     uint32_t              offset;
  578.     uint32_t              size;
  579. } VkPushConstantRange;
  580. */
  581.  
  582. const VkPushConstantRange light_modulate_range =
  583. {
  584.     VK_SHADER_STAGE_FRAGMENT_BIT,
  585.     0,
  586.     sizeof(float),
  587. };
  588.  
  589. const VkPushConstantRange intensity_time_range =
  590. {
  591.     VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
  592.     0,
  593.     sizeof(float) * 2,
  594. };
  595.  
  596. const VkPushConstantRange particle_size_range =
  597. {
  598.     VK_SHADER_STAGE_VERTEX_BIT,
  599.     0,
  600.     sizeof(float) * 3,
  601. };
  602.  
  603. //unlit brush model data.
  604.  
  605. #include "shaders/world_unlit_frag.h"
  606. const VkShaderModuleCreateInfo world_unlit_frag_info =
  607. {
  608.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  609.     nullptr, //pNext
  610.     0, //flags
  611.     sizeof(world_unlit_frag), //codeSize
  612.     world_unlit_frag, //pCode
  613. };
  614. VkShaderModule world_unlit_frag_module;
  615.  
  616. #include "shaders/world_unlit_warped_frag.h"
  617. const VkShaderModuleCreateInfo world_unlit_warped_frag_info =
  618. {
  619.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  620.     nullptr, //pNext
  621.     0, //flags
  622.     sizeof(world_unlit_warped_frag),
  623.     world_unlit_warped_frag,
  624.  
  625. };
  626. VkShaderModule world_unlit_warped_frag_module;
  627.  
  628. #include "shaders/world_unlit_vert.h"
  629. const VkShaderModuleCreateInfo world_unlit_vert_info =
  630. {
  631.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  632.     nullptr, //pNext
  633.     0, //flags
  634.     sizeof(world_unlit_vert),
  635.     world_unlit_vert,
  636. };
  637. VkShaderModule world_unlit_vert_module;
  638.  
  639. const VkVertexInputAttributeDescription world_unlit_vertex_attributes[] =
  640. {
  641.     { //position
  642.         0,
  643.         0,
  644.         VK_FORMAT_R32G32B32_SFLOAT,
  645.         0
  646.     },
  647.     { //uv
  648.         1,
  649.         0,
  650.         VK_FORMAT_R32G32_SFLOAT,
  651.         3 * sizeof(float)
  652.     },
  653.     { //scroll speed
  654.         2,
  655.         0,
  656.         VK_FORMAT_R32_SFLOAT,
  657.         5 * sizeof(float)
  658.     },
  659.     { //alpha
  660.         3,
  661.         0,
  662.         VK_FORMAT_R32_SFLOAT,
  663.         6 * sizeof(float)
  664.     }
  665. };
  666.  
  667. const VkPipelineVertexInputStateCreateInfo world_unlit_vertex_info =
  668. {
  669.     VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
  670.     nullptr,
  671.     0,
  672.     1,
  673.     & world_vertex_binding,
  674.     sizeof(world_unlit_vertex_attributes) / sizeof(world_unlit_vertex_attributes[0]),
  675.     world_unlit_vertex_attributes
  676. };
  677.  
  678. //stuff for inline bmodels
  679. #include "shaders/brush_lightmap_vert.h"
  680. const VkShaderModuleCreateInfo brush_lightmap_vert_info =
  681. {
  682.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  683.     nullptr, //pNext
  684.     0, //flags
  685.     sizeof(brush_lightmap_vert),
  686.     brush_lightmap_vert,
  687. };
  688. VkShaderModule brush_lightmap_vert_module;
  689.  
  690. const VkPushConstantRange local_modelview_range =
  691. {
  692.     VK_SHADER_STAGE_VERTEX_BIT,
  693.     4,
  694.     sizeof(float) * 8,
  695. };
  696.  
  697. //Alias model specific data
  698. #include "shaders/alias_vertexlit_vert.h"
  699. const VkShaderModuleCreateInfo alias_vertexlit_vert_info =
  700. {
  701.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  702.     nullptr, //pNext
  703.     0, //flags
  704.     sizeof(alias_vertexlit_vert),
  705.     alias_vertexlit_vert,
  706. };
  707. VkShaderModule alias_vertexlit_vert_module;
  708.  
  709. #include "shaders/alias_vertexlit_frag.h"
  710. const VkShaderModuleCreateInfo alias_vertexlit_frag_info =
  711. {
  712.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  713.     nullptr, //pNext
  714.     0, //flags
  715.     sizeof(alias_vertexlit_frag),
  716.     alias_vertexlit_frag,
  717. };
  718. VkShaderModule alias_vertexlit_frag_module;
  719.  
  720. const VkVertexInputBindingDescription alias_vertex_binding =
  721. {
  722.     0, //binding
  723.     sizeof(int) + sizeof(float) * 2, //stride
  724.     VK_VERTEX_INPUT_RATE_VERTEX, //inputRate
  725. };
  726.  
  727. const VkVertexInputAttributeDescription alias_vertex_attributes[] =
  728. {
  729.     { //index
  730.         0, //location
  731.         0, //binding
  732.         VK_FORMAT_R32_SINT, //format
  733.         0 //offset
  734.     },
  735.     { //uv
  736.         1,
  737.         0,
  738.         VK_FORMAT_R32G32_SFLOAT,
  739.         sizeof(int)
  740.     },
  741. };
  742.  
  743. const VkPipelineVertexInputStateCreateInfo alias_vertex_info =
  744. {
  745.     VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
  746.     nullptr,
  747.     0,
  748.     1,
  749.     &alias_vertex_binding,
  750.     sizeof(alias_vertex_attributes) / sizeof(alias_vertex_attributes[0]),
  751.     alias_vertex_attributes
  752. };
  753.  
  754. //Sky nonsense
  755. #include "shaders/world_sky_vert.h"
  756. const VkShaderModuleCreateInfo world_sky_vert_info =
  757. {
  758.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  759.     nullptr, //pNext
  760.     0, //flags
  761.     sizeof(world_sky_vert),
  762.     world_sky_vert,
  763. };
  764. VkShaderModule world_sky_vert_module;
  765.  
  766. #include "shaders/world_sky_frag.h"
  767. const VkShaderModuleCreateInfo world_sky_frag_info =
  768. {
  769.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  770.     nullptr, //pNext
  771.     0, //flags
  772.     sizeof(world_sky_frag),
  773.     world_sky_frag,
  774. };
  775. VkShaderModule world_sky_frag_module;
  776.  
  777. const VkVertexInputAttributeDescription world_sky_vertex_attributes[] =
  778. {
  779.     0, //location
  780.     0, //binding
  781.     VK_FORMAT_R32G32B32_SFLOAT, //format
  782.     0 //offset
  783. };
  784.  
  785. const VkPipelineVertexInputStateCreateInfo world_sky_vertex_info =
  786. {
  787.     VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
  788.     nullptr,
  789.     0,
  790.     1,
  791.     &world_vertex_binding,
  792.     sizeof(world_sky_vertex_attributes) / sizeof(world_sky_vertex_attributes[0]),
  793.     world_sky_vertex_attributes
  794. };
  795.  
  796. const VkPushConstantRange sky_spin_range =
  797. {
  798.     VK_SHADER_STAGE_VERTEX_BIT,
  799.     0,
  800.     sizeof(float) * 4,
  801. };
  802.  
  803. //sprite nonsense
  804. #include "shaders/sprite_textured_vert.h"
  805. const VkShaderModuleCreateInfo sprite_textured_vert_info =
  806. {
  807.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  808.     nullptr, //pNext
  809.     0, //flags
  810.     sizeof(sprite_textured_vert),
  811.     sprite_textured_vert,
  812. };
  813. VkShaderModule sprite_textured_vert_module;
  814.  
  815. #include "shaders/sprite_textured_frag.h"
  816. const VkShaderModuleCreateInfo sprite_textured_frag_info =
  817. {
  818.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  819.     nullptr, //pNext
  820.     0, //flags
  821.     sizeof(sprite_textured_frag),
  822.     sprite_textured_frag,
  823. };
  824. VkShaderModule sprite_textured_frag_module;
  825.  
  826. const VkPipelineVertexInputStateCreateInfo sprite_textured_vertex_info =
  827. {
  828.     VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
  829.     nullptr,
  830.     0,
  831.     0,
  832.     nullptr,
  833.     0,
  834.     nullptr
  835. };
  836.  
  837. //particle nonsense
  838. #include "shaders/particle_vert.h"
  839. const VkShaderModuleCreateInfo particle_vert_info =
  840. {
  841.     VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
  842.     nullptr, //pNext
  843.     0, //flags
  844.     sizeof(particle_vert),
  845.     particle_vert,
  846. };
  847. VkShaderModule particle_vert_module;
  848.  
  849. const VkVertexInputBindingDescription particle_vertex_binding =
  850. {
  851.     0, //binding
  852.     sizeof(float) * 7, //stride
  853.     VK_VERTEX_INPUT_RATE_VERTEX, //inputRate
  854. };
  855.  
  856. const VkVertexInputAttributeDescription particle_vertex_attributes[] =
  857. {
  858.     { //index
  859.         0, //location
  860.         0, //binding
  861.         VK_FORMAT_R32G32B32_SFLOAT, //format
  862.         0 //offset
  863.     },
  864.     { //color
  865.         1, //location
  866.         0, //binding
  867.         VK_FORMAT_R32G32B32A32_SFLOAT, //format
  868.         sizeof(float) * 3 //offset
  869.     },
  870. };
  871.  
  872. const VkPipelineVertexInputStateCreateInfo particle_vertex_info =
  873. {
  874.     VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
  875.     nullptr,
  876.     0,
  877.     1,
  878.     &particle_vertex_binding,
  879.     sizeof(particle_vertex_attributes) / sizeof(particle_vertex_attributes[0]),
  880.     particle_vertex_attributes
  881. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement