#include <windows.h>
#include <vulkan/vulkan.h>
#include "vk_mem_alloc.h"
#include "vk_shaders.h"
Go to the source code of this file.
|
#define | QVVKTEXTURE_INIT |
|
#define | QVVKTEXTURE_CLEAR(i) |
|
#define | QVKPIPELINE_INIT |
|
#define | QVk_DebugSetObjectName(a, b, c) |
|
#define | QVk_DebugSetObjectTag(a, b, c, d, e) |
|
#define | QVk_DebugLabelBegin(a, b, c, d, e) |
|
#define | QVk_DebugLabelEnd(a) |
|
#define | QVk_DebugLabelInsert(a, b, c, d, e) |
|
|
enum | qvksampler_t {
S_NEAREST = 0,
S_LINEAR = 1,
S_MIPMAP_NEAREST = 2,
S_MIPMAP_LINEAR = 3,
S_ANISO_NEAREST = 4,
S_ANISO_LINEAR = 5,
S_ANISO_MIPMAP_NEAREST = 6,
S_ANISO_MIPMAP_LINEAR = 7,
S_SAMPLER_CNT = 8
} |
|
enum | qvkrenderpasstype_t { RP_WORLD = 0,
RP_UI = 1,
RP_WORLD_WARP = 2,
RP_COUNT = 3
} |
|
|
qboolean | QVk_Init (void) |
|
void | QVk_Shutdown (void) |
|
void | QVk_CreateValidationLayers (void) |
|
void | QVk_DestroyValidationLayers (void) |
|
qboolean | QVk_CreateDevice (int preferredDeviceIdx) |
|
VkResult | QVk_CreateSwapchain (void) |
|
VkFormat | QVk_FindDepthFormat (void) |
|
VkResult | QVk_CreateCommandPool (VkCommandPool *commandPool, uint32_t queueFamilyIndex) |
|
VkResult | QVk_CreateImageView (const VkImage *image, VkImageAspectFlags aspectFlags, VkImageView *imageView, VkFormat format, uint32_t mipLevels) |
|
VkResult | QVk_CreateImage (uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VmaMemoryUsage memUsage, qvktexture_t *texture) |
|
void | QVk_CreateDepthBuffer (VkSampleCountFlagBits sampleCount, qvktexture_t *depthBuffer) |
|
void | QVk_CreateColorBuffer (VkSampleCountFlagBits sampleCount, qvktexture_t *colorBuffer, int extraFlags) |
|
void | QVk_CreateTexture (qvktexture_t *texture, const unsigned char *data, uint32_t width, uint32_t height, qvksampler_t samplerType) |
|
void | QVk_UpdateTextureData (qvktexture_t *texture, const unsigned char *data, uint32_t offset_x, uint32_t offset_y, uint32_t width, uint32_t height) |
|
VkSampler | QVk_UpdateTextureSampler (qvktexture_t *texture, qvksampler_t samplerType) |
|
void | QVk_ReleaseTexture (qvktexture_t *texture) |
|
void | QVk_ReadPixels (uint8_t *dstBuffer, uint32_t width, uint32_t height) |
|
VkResult | QVk_BeginCommand (const VkCommandBuffer *commandBuffer) |
|
void | QVk_SubmitCommand (const VkCommandBuffer *commandBuffer, const VkQueue *queue) |
|
VkCommandBuffer | QVk_CreateCommandBuffer (const VkCommandPool *commandPool, VkCommandBufferLevel level) |
|
const char * | QVk_GetError (VkResult errorCode) |
|
VkResult | QVk_BeginFrame (void) |
|
VkResult | QVk_EndFrame (qboolean force) |
|
void | QVk_BeginRenderpass (qvkrenderpasstype_t rpType) |
|
void | QVk_RecreateSwapchain (void) |
|
VkResult | QVk_CreateBuffer (VkDeviceSize size, qvkbuffer_t *dstBuffer, const qvkbufferopts_t options) |
|
void | QVk_FreeBuffer (qvkbuffer_t *buffer) |
|
VkResult | QVk_CreateStagingBuffer (VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags) |
|
VkResult | QVk_CreateUniformBuffer (VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags) |
|
void | QVk_CreateVertexBuffer (const void *data, VkDeviceSize size, qvkbuffer_t *dstBuffer, qvkbuffer_t *stagingBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags) |
|
void | QVk_CreateIndexBuffer (const void *data, VkDeviceSize size, qvkbuffer_t *dstBuffer, qvkbuffer_t *stagingBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags) |
|
qvkshader_t | QVk_CreateShader (const uint32_t *shaderSrc, size_t shaderCodeSize, VkShaderStageFlagBits shaderStage) |
|
void | QVk_CreatePipeline (const VkDescriptorSetLayout *descriptorLayout, const uint32_t desLayoutCount, const VkPipelineVertexInputStateCreateInfo *vertexInputInfo, qvkpipeline_t *pipeline, const qvkrenderpass_t *renderpass, const qvkshader_t *shaders, uint32_t shaderCount, VkPushConstantRange *pcRange) |
|
void | QVk_DestroyPipeline (qvkpipeline_t *pipeline) |
|
uint8_t * | QVk_GetVertexBuffer (VkDeviceSize size, VkBuffer *dstBuffer, VkDeviceSize *dstOffset) |
|
uint8_t * | QVk_GetIndexBuffer (VkDeviceSize size, VkDeviceSize *dstOffset) |
|
uint8_t * | QVk_GetUniformBuffer (VkDeviceSize size, uint32_t *dstOffset, VkDescriptorSet *dstUboDescriptorSet) |
|
uint8_t * | QVk_GetStagingBuffer (VkDeviceSize size, int alignment, VkCommandBuffer *cmdBuffer, VkBuffer *buffer, uint32_t *dstOffset) |
|
VkBuffer | QVk_GetTriangleFanIbo (VkDeviceSize indexCount) |
|
void | QVk_DrawColorRect (float *ubo, VkDeviceSize uboSize, qvkrenderpasstype_t rpType) |
|
void | QVk_DrawTexRect (float *ubo, VkDeviceSize uboSize, qvktexture_t *texture) |
|
void | QVk_BindPipeline (qvkpipeline_t *pipeline) |
|
void | QVk_SubmitStagingBuffers (void) |
|
◆ QVk_DebugLabelBegin
#define QVk_DebugLabelBegin |
( |
|
a, |
|
|
|
b, |
|
|
|
c, |
|
|
|
d, |
|
|
|
e |
|
) |
| |
◆ QVk_DebugLabelEnd
#define QVk_DebugLabelEnd |
( |
|
a | ) |
|
◆ QVk_DebugLabelInsert
#define QVk_DebugLabelInsert |
( |
|
a, |
|
|
|
b, |
|
|
|
c, |
|
|
|
d, |
|
|
|
e |
|
) |
| |
◆ QVk_DebugSetObjectName
#define QVk_DebugSetObjectName |
( |
|
a, |
|
|
|
b, |
|
|
|
c |
|
) |
| |
◆ QVk_DebugSetObjectTag
#define QVk_DebugSetObjectTag |
( |
|
a, |
|
|
|
b, |
|
|
|
c, |
|
|
|
d, |
|
|
|
e |
|
) |
| |
◆ QVKPIPELINE_INIT
Value: { \
.layout = VK_NULL_HANDLE, \
.pl = VK_NULL_HANDLE, \
.flags = 0, \
.mode = VK_POLYGON_MODE_FILL, \
.cullMode = VK_CULL_MODE_BACK_BIT, \
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, \
.blendOpts = { \
.blendEnable = VK_FALSE, \
.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA, \
.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, \
.colorBlendOp = VK_BLEND_OP_ADD, \
.srcAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA, \
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, \
.alphaBlendOp = VK_BLEND_OP_ADD, \
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT \
}, \
.depthTestEnable = VK_TRUE, \
.depthWriteEnable = VK_TRUE \
}
Definition at line 172 of file qvk.h.
◆ QVVKTEXTURE_CLEAR
#define QVVKTEXTURE_CLEAR |
( |
|
i | ) |
|
Value: { \
(
i).image = VK_NULL_HANDLE; \
(
i).allocation = VK_NULL_HANDLE; \
(
i).imageView = VK_NULL_HANDLE; \
(
i).sharingMode = VK_SHARING_MODE_MAX_ENUM; \
(
i).sampleCount = VK_SAMPLE_COUNT_1_BIT; \
(
i).
format = VK_FORMAT_R8G8B8A8_UNORM; \
}
Definition at line 104 of file qvk.h.
◆ QVVKTEXTURE_INIT
Value: { \
.image = VK_NULL_HANDLE, \
.allocation = VK_NULL_HANDLE, \
.allocInfo = VK_NULL_HANDLE, \
.vmaFlags = 0, \
.imageView = VK_NULL_HANDLE, \
.sharingMode = VK_SHARING_MODE_MAX_ENUM, \
.sampleCount = VK_SAMPLE_COUNT_1_BIT, \
.format = VK_FORMAT_R8G8B8A8_UNORM, \
.descriptorSet = VK_NULL_HANDLE, \
.mipLevels = 1, \
}
Definition at line 91 of file qvk.h.
◆ qvkrenderpasstype_t
Enumerator |
---|
RP_WORLD | |
RP_UI | |
RP_WORLD_WARP | |
RP_COUNT | |
Definition at line 194 of file qvk.h.
◆ qvksampler_t
Enumerator |
---|
S_NEAREST | |
S_LINEAR | |
S_MIPMAP_NEAREST | |
S_MIPMAP_LINEAR | |
S_ANISO_NEAREST | |
S_ANISO_LINEAR | |
S_ANISO_MIPMAP_NEAREST | |
S_ANISO_MIPMAP_LINEAR | |
S_SAMPLER_CNT | |
Definition at line 63 of file qvk.h.
◆ QVk_BeginCommand()
VkResult QVk_BeginCommand |
( |
const VkCommandBuffer * |
commandBuffer | ) |
|
Definition at line 23 of file vk_cmd.c.
25 VkCommandBufferBeginInfo cmdInfo = {
26 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
28 .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
29 .pInheritanceInfo =
NULL
32 return vkBeginCommandBuffer(*commandBuffer, &cmdInfo);
Referenced by copyBuffer(), CreateStagingBuffers(), and QVk_ReadPixels().
◆ QVk_BeginFrame()
VkResult QVk_BeginFrame |
( |
void |
| ) |
|
Definition at line 1824 of file vk_common.c.
1850 if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || result == VK_ERROR_SURFACE_LOST_KHR)
1855 else if (result != VK_SUCCESS)
1857 Sys_Error(
"QVk_BeginFrame(): unexpected error after vkAcquireNextImageKHR: %s",
QVk_GetError(result));
1864 VkCommandBufferBeginInfo beginInfo = {
1865 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
1867 .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
1868 .pInheritanceInfo =
NULL
Referenced by R_BeginFrame().
◆ QVk_BeginRenderpass()
Definition at line 1946 of file vk_common.c.
1948 VkClearValue clearColors[3] = {
1949 {.color = { 1.f, .0f, .5f, 1.f } },
1950 {.depthStencil = { 1.f, 0 } },
1951 {.color = { 1.f, .0f, .5f, 1.f } },
1954 VkRenderPassBeginInfo renderBeginInfo[] = {
1957 .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
1960 .renderArea.offset = { 0, 0 },
1963 .pClearValues = clearColors
1967 .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
1970 .renderArea.offset = { 0, 0 },
1972 .clearValueCount = 2,
1973 .pClearValues = clearColors
1977 .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
1980 .renderArea.offset = { 0, 0 },
1982 .clearValueCount = 1,
1983 .pClearValues = clearColors
1987 #if defined(_DEBUG) || defined(ENABLE_DEBUG_LABELS)
1991 if (rpType ==
RP_UI) {
Referenced by R_BeginFrame(), and R_EndWorldRenderpass().
◆ QVk_BindPipeline()
Definition at line 2284 of file vk_common.c.
Referenced by DrawVkFlowingPoly(), DrawVkPoly(), EmitWaterPolys(), QVk_DrawColorRect(), QVk_DrawTexRect(), R_DrawBeam(), R_DrawNullModel(), R_DrawParticles(), R_DrawSkyBox(), R_DrawSpriteModel(), R_DrawTriangleOutlines(), R_EndWorldRenderpass(), R_RenderDlight(), R_SetVulkan2D(), Vk_DrawAliasFrameLerp(), Vk_DrawAliasShadow(), Vk_DrawParticles(), and Vk_RenderLightmappedPoly().
◆ QVk_CreateBuffer()
◆ QVk_CreateColorBuffer()
void QVk_CreateColorBuffer |
( |
VkSampleCountFlagBits |
sampleCount, |
|
|
qvktexture_t * |
colorBuffer, |
|
|
int |
extraFlags |
|
) |
| |
◆ QVk_CreateCommandBuffer()
VkCommandBuffer QVk_CreateCommandBuffer |
( |
const VkCommandPool * |
commandPool, |
|
|
VkCommandBufferLevel |
level |
|
) |
| |
Definition at line 78 of file vk_cmd.c.
80 VkCommandBuffer commandBuffer = VK_NULL_HANDLE;
81 VkCommandBufferAllocateInfo allocInfo = {
82 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
84 .commandPool = *commandPool,
86 .commandBufferCount = 1
Referenced by copyBuffer(), CreateStagingBuffers(), and QVk_ReadPixels().
◆ QVk_CreateCommandPool()
VkResult QVk_CreateCommandPool |
( |
VkCommandPool * |
commandPool, |
|
|
uint32_t |
queueFamilyIndex |
|
) |
| |
Definition at line 65 of file vk_cmd.c.
67 VkCommandPoolCreateInfo cpCreateInfo = {
68 .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
71 .flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
72 .queueFamilyIndex = queueFamilyIndex
Referenced by CreateStagingBuffers(), and QVk_Init().
◆ QVk_CreateDepthBuffer()
void QVk_CreateDepthBuffer |
( |
VkSampleCountFlagBits |
sampleCount, |
|
|
qvktexture_t * |
depthBuffer |
|
) |
| |
◆ QVk_CreateDevice()
◆ QVk_CreateImage()
VkResult QVk_CreateImage |
( |
uint32_t |
width, |
|
|
uint32_t |
height, |
|
|
VkFormat |
format, |
|
|
VkImageTiling |
tiling, |
|
|
VkImageUsageFlags |
usage, |
|
|
VmaMemoryUsage |
memUsage, |
|
|
qvktexture_t * |
texture |
|
) |
| |
Definition at line 316 of file vk_image.c.
318 VkImageCreateInfo imageInfo = {
319 .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
320 .imageType = VK_IMAGE_TYPE_2D,
321 .extent.width =
width,
324 .mipLevels =
texture->mipLevels,
328 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
330 .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
331 .samples =
texture->sampleCount,
338 imageInfo.sharingMode = VK_SHARING_MODE_CONCURRENT;
339 imageInfo.queueFamilyIndexCount = 2;
340 imageInfo.pQueueFamilyIndices = queueFamilies;
348 texture->sharingMode = imageInfo.sharingMode;
Referenced by createTextureImage(), QVk_CreateColorBuffer(), and QVk_CreateDepthBuffer().
◆ QVk_CreateImageView()
VkResult QVk_CreateImageView |
( |
const VkImage * |
image, |
|
|
VkImageAspectFlags |
aspectFlags, |
|
|
VkImageView * |
imageView, |
|
|
VkFormat |
format, |
|
|
uint32_t |
mipLevels |
|
) |
| |
Definition at line 293 of file vk_image.c.
295 VkImageViewCreateInfo ivCreateInfo = {
296 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
300 .viewType = VK_IMAGE_VIEW_TYPE_2D,
302 .components.r = VK_COMPONENT_SWIZZLE_IDENTITY,
303 .components.g = VK_COMPONENT_SWIZZLE_IDENTITY,
304 .components.b = VK_COMPONENT_SWIZZLE_IDENTITY,
305 .components.a = VK_COMPONENT_SWIZZLE_IDENTITY,
306 .subresourceRange.aspectMask = aspectFlags,
307 .subresourceRange.baseArrayLayer = 0,
308 .subresourceRange.baseMipLevel = 0,
309 .subresourceRange.layerCount = 1,
310 .subresourceRange.levelCount = mipLevels
Referenced by CreateImageViews(), QVk_CreateColorBuffer(), QVk_CreateDepthBuffer(), and QVk_CreateTexture().
◆ QVk_CreateIndexBuffer()
void QVk_CreateIndexBuffer |
( |
const void * |
data, |
|
|
VkDeviceSize |
size, |
|
|
qvkbuffer_t * |
dstBuffer, |
|
|
qvkbuffer_t * |
stagingBuffer, |
|
|
VkMemoryPropertyFlags |
reqMemFlags, |
|
|
VkMemoryPropertyFlags |
prefMemFlags |
|
) |
| |
◆ QVk_CreatePipeline()
void QVk_CreatePipeline |
( |
const VkDescriptorSetLayout * |
descriptorLayout, |
|
|
const uint32_t |
desLayoutCount, |
|
|
const VkPipelineVertexInputStateCreateInfo * |
vertexInputInfo, |
|
|
qvkpipeline_t * |
pipeline, |
|
|
const qvkrenderpass_t * |
renderpass, |
|
|
const qvkshader_t * |
shaders, |
|
|
uint32_t |
shaderCount, |
|
|
VkPushConstantRange * |
pcRange |
|
) |
| |
Definition at line 51 of file vk_pipeline.c.
54 VkPipelineShaderStageCreateInfo *ssCreateInfos = (VkPipelineShaderStageCreateInfo *)malloc(shaderCount *
sizeof(VkPipelineShaderStageCreateInfo));
55 for (
int i = 0;
i < shaderCount;
i++)
60 VkPipelineInputAssemblyStateCreateInfo iaCreateInfo = {
61 .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
65 .primitiveRestartEnable = VK_FALSE
68 VkViewport viewport = {
83 VkPipelineViewportStateCreateInfo vpCreateInfo = {
84 .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
88 .pViewports = &viewport,
93 VkPipelineRasterizationStateCreateInfo rCreateInfo = {
94 .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
97 .depthClampEnable = VK_FALSE,
98 .rasterizerDiscardEnable = VK_FALSE,
99 .polygonMode = pipeline->
mode,
101 .frontFace = VK_FRONT_FACE_CLOCKWISE,
102 .depthBiasEnable = VK_FALSE,
103 .depthBiasConstantFactor = 0.f,
104 .depthBiasClamp = 0.f,
105 .depthBiasSlopeFactor = 0.f,
109 VkPipelineMultisampleStateCreateInfo msCreateInfo = {
110 .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
117 .alphaToCoverageEnable = VK_FALSE,
118 .alphaToOneEnable = VK_FALSE
121 VkPipelineDepthStencilStateCreateInfo dCreateInfo = {
122 .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
127 .depthCompareOp = VK_COMPARE_OP_LESS,
128 .depthBoundsTestEnable = VK_FALSE,
129 .stencilTestEnable = VK_FALSE,
130 .front = { VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_COMPARE_OP_NEVER, 0, 0, 0 },
131 .back = { VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_COMPARE_OP_NEVER, 0, 0, 0 },
132 .minDepthBounds = 0.f,
133 .maxDepthBounds = 1.f
136 VkPipelineColorBlendStateCreateInfo cbsCreateInfo = {
137 .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
140 .logicOpEnable = VK_FALSE,
141 .logicOp = VK_LOGIC_OP_COPY,
142 .attachmentCount = 1,
144 .blendConstants[0] = 0.f,
145 .blendConstants[1] = 0.f,
146 .blendConstants[2] = 0.f,
147 .blendConstants[3] = 0.f
150 VkDynamicState dynamicStates[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
151 VkPipelineDynamicStateCreateInfo dsCreateInfo = {
152 .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
155 .dynamicStateCount = 2,
156 .pDynamicStates = dynamicStates
159 VkPipelineLayoutCreateInfo plCreateInfo = {
160 .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
163 .setLayoutCount = descLayoutCount,
164 .pSetLayouts = descriptorLayout,
165 .pushConstantRangeCount = pcRange ? 1 : 0,
166 .pPushConstantRanges = pcRange
172 VkGraphicsPipelineCreateInfo pCreateInfo = {
173 .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
175 .flags = pipeline->
flags,
176 .stageCount = shaderCount,
177 .pStages = ssCreateInfos,
178 .pVertexInputState = vertexInputInfo,
179 .pInputAssemblyState = &iaCreateInfo,
180 .pTessellationState =
NULL,
181 .pViewportState = &vpCreateInfo,
182 .pRasterizationState = &rCreateInfo,
183 .pMultisampleState = &msCreateInfo,
184 .pDepthStencilState = &dCreateInfo,
185 .pColorBlendState = &cbsCreateInfo,
186 .pDynamicState = &dsCreateInfo,
187 .layout = pipeline->
layout,
188 .renderPass = renderpass->
rp,
190 .basePipelineHandle = VK_NULL_HANDLE,
191 .basePipelineIndex = -1
Referenced by CreatePipelines().
◆ QVk_CreateShader()
qvkshader_t QVk_CreateShader |
( |
const uint32_t * |
shaderSrc, |
|
|
size_t |
shaderCodeSize, |
|
|
VkShaderStageFlagBits |
shaderStage |
|
) |
| |
Definition at line 23 of file vk_pipeline.c.
26 VkShaderModuleCreateInfo smCreateInfo = {
27 .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
30 .codeSize = shaderCodeSize,
36 VkPipelineShaderStageCreateInfo vssCreateInfo = {
37 .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
43 .pSpecializationInfo =
NULL
◆ QVk_CreateStagingBuffer()
VkResult QVk_CreateStagingBuffer |
( |
VkDeviceSize |
size, |
|
|
qvkbuffer_t * |
dstBuffer, |
|
|
VkMemoryPropertyFlags |
reqMemFlags, |
|
|
VkMemoryPropertyFlags |
prefMemFlags |
|
) |
| |
◆ QVk_CreateSwapchain()
VkResult QVk_CreateSwapchain |
( |
void |
| ) |
|
Definition at line 117 of file vk_swapchain.c.
119 VkSurfaceCapabilitiesKHR surfaceCaps;
120 VkSurfaceFormatKHR *surfaceFormats =
NULL;
121 VkPresentModeKHR *presentModes =
NULL;
122 uint32_t formatCount, presentModesCount;
129 surfaceFormats = (VkSurfaceFormatKHR *)malloc(formatCount *
sizeof(VkSurfaceFormatKHR));
133 if (presentModesCount > 0)
135 presentModes = (VkPresentModeKHR *)malloc(presentModesCount *
sizeof(VkPresentModeKHR));
139 for (
int i = 0;
i < presentModesCount;
i++)
148 VkPresentModeKHR swapPresentMode =
getSwapPresentMode(presentModes, presentModesCount,
vk_vsync->
value > 0 ? VK_PRESENT_MODE_FIFO_KHR : VK_PRESENT_MODE_MAILBOX_KHR);
149 free(surfaceFormats);
152 VkExtent2D extent = surfaceCaps.currentExtent;
153 if(extent.width == UINT32_MAX || extent.height == UINT32_MAX)
155 extent.width =
max(surfaceCaps.minImageExtent.width,
min(surfaceCaps.maxImageExtent.width,
vid.
width));
156 extent.height =
max(surfaceCaps.minImageExtent.height,
min(surfaceCaps.maxImageExtent.height,
vid.
height));
160 uint32_t imageCount =
max(2, surfaceCaps.minImageCount);
161 if (swapPresentMode == VK_PRESENT_MODE_MAILBOX_KHR)
162 imageCount =
max(3, surfaceCaps.minImageCount);
164 if (surfaceCaps.maxImageCount > 0)
165 imageCount =
min(imageCount, surfaceCaps.maxImageCount);
168 VkSwapchainCreateInfoKHR scCreateInfo = {
169 .sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
173 .minImageCount = imageCount,
174 .imageFormat = swapSurfaceFormat.format,
175 .imageColorSpace = swapSurfaceFormat.colorSpace,
176 .imageExtent = extent,
177 .imageArrayLayers = 1,
178 .imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
179 .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
180 .queueFamilyIndexCount = 0,
181 .pQueueFamilyIndices =
NULL,
182 .preTransform = surfaceCaps.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR ? VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR : surfaceCaps.currentTransform,
184 .presentMode = swapPresentMode,
186 .oldSwapchain = oldSwapchain
192 scCreateInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
193 scCreateInfo.queueFamilyIndexCount = 2;
194 scCreateInfo.pQueueFamilyIndices = queueFamilyIndices;
203 if (res != VK_SUCCESS)
211 if (oldSwapchain != VK_NULL_HANDLE)
Referenced by QVk_Init(), and QVk_RecreateSwapchain().
◆ QVk_CreateTexture()
◆ QVk_CreateUniformBuffer()
VkResult QVk_CreateUniformBuffer |
( |
VkDeviceSize |
size, |
|
|
qvkbuffer_t * |
dstBuffer, |
|
|
VkMemoryPropertyFlags |
reqMemFlags, |
|
|
VkMemoryPropertyFlags |
prefMemFlags |
|
) |
| |
◆ QVk_CreateValidationLayers()
void QVk_CreateValidationLayers |
( |
void |
| ) |
|
Definition at line 74 of file vk_validation.c.
76 VkDebugUtilsMessengerCreateInfoEXT callbackInfo = {
77 .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
80 .messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
81 VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
82 .messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
83 VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
84 VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT,
91 callbackInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT |
92 VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
Referenced by QVk_Init().
◆ QVk_CreateVertexBuffer()
void QVk_CreateVertexBuffer |
( |
const void * |
data, |
|
|
VkDeviceSize |
size, |
|
|
qvkbuffer_t * |
dstBuffer, |
|
|
qvkbuffer_t * |
stagingBuffer, |
|
|
VkMemoryPropertyFlags |
reqMemFlags, |
|
|
VkMemoryPropertyFlags |
prefMemFlags |
|
) |
| |
◆ QVk_DestroyPipeline()
Definition at line 198 of file vk_pipeline.c.
200 if (pipeline->
layout != VK_NULL_HANDLE)
202 if (pipeline->
pl != VK_NULL_HANDLE)
205 pipeline->
layout = VK_NULL_HANDLE;
206 pipeline->
pl = VK_NULL_HANDLE;
Referenced by QVk_Shutdown().
◆ QVk_DestroyValidationLayers()
void QVk_DestroyValidationLayers |
( |
void |
| ) |
|
◆ QVk_DrawColorRect()
◆ QVk_DrawTexRect()
void QVk_DrawTexRect |
( |
float * |
ubo, |
|
|
VkDeviceSize |
uboSize, |
|
|
qvktexture_t * |
texture |
|
) |
| |
◆ QVk_EndFrame()
Definition at line 1880 of file vk_common.c.
1884 return VK_NOT_READY;
1902 VkPipelineStageFlags waitStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
1903 VkSubmitInfo submitInfo = {
1904 .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
1905 .waitSemaphoreCount = 1,
1907 .signalSemaphoreCount = 1,
1909 .pWaitDstStageMask = &waitStages,
1910 .commandBufferCount = 1,
1917 VkPresentInfoKHR presentInfo = {
1918 .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
1919 .waitSemaphoreCount = 1,
1921 .swapchainCount = 1,
1930 if (renderResult == VK_ERROR_OUT_OF_DATE_KHR || renderResult == VK_SUBOPTIMAL_KHR || renderResult == VK_ERROR_SURFACE_LOST_KHR)
1935 else if (renderResult != VK_SUCCESS)
1937 Sys_Error(
"QVk_EndFrame(): unexpected error after vkQueuePresentKHR: %s",
QVk_GetError(renderResult));
1943 return renderResult;
Referenced by R_BeginFrame(), and R_EndFrame().
◆ QVk_FindDepthFormat()
VkFormat QVk_FindDepthFormat |
( |
void |
| ) |
|
Definition at line 267 of file vk_common.c.
269 VkFormat depthFormats[] = {
270 VK_FORMAT_D32_SFLOAT_S8_UINT,
271 VK_FORMAT_D32_SFLOAT,
272 VK_FORMAT_D24_UNORM_S8_UINT,
273 VK_FORMAT_D16_UNORM_S8_UINT,
277 for (
int i = 0;
i < 5; ++
i)
279 VkFormatProperties formatProps;
280 vkGetPhysicalDeviceFormatProperties(
vk_device.
physical, depthFormats[
i], &formatProps);
282 if (formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
283 return depthFormats[
i];
286 return VK_FORMAT_D16_UNORM;
Referenced by CreateRenderpasses(), and QVk_CreateDepthBuffer().
◆ QVk_FreeBuffer()
◆ QVk_GetError()
const char* QVk_GetError |
( |
VkResult |
errorCode | ) |
|
◆ QVk_GetIndexBuffer()
uint8_t* QVk_GetIndexBuffer |
( |
VkDeviceSize |
size, |
|
|
VkDeviceSize * |
dstOffset |
|
) |
| |
◆ QVk_GetStagingBuffer()
uint8_t* QVk_GetStagingBuffer |
( |
VkDeviceSize |
size, |
|
|
int |
alignment, |
|
|
VkCommandBuffer * |
cmdBuffer, |
|
|
VkBuffer * |
buffer, |
|
|
uint32_t * |
dstOffset |
|
) |
| |
Definition at line 2153 of file vk_common.c.
2161 Sys_Error(
"QVk_GetStagingBuffer(): Cannot allocate staging buffer space!");
2175 VkCommandBufferBeginInfo beginInfo = {
2176 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
2178 .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
2179 .pInheritanceInfo =
NULL
Referenced by createTextureImage(), and QVk_UpdateTextureData().
◆ QVk_GetTriangleFanIbo()
VkBuffer QVk_GetTriangleFanIbo |
( |
VkDeviceSize |
indexCount | ) |
|
◆ QVk_GetUniformBuffer()
uint8_t* QVk_GetUniformBuffer |
( |
VkDeviceSize |
size, |
|
|
uint32_t * |
dstOffset, |
|
|
VkDescriptorSet * |
dstUboDescriptorSet |
|
) |
| |
Definition at line 2100 of file vk_common.c.
2103 const int align_mod = size % 256;
2104 const uint32_t aligned_size = ((size % 256) == 0) ? size : (size + 256 - align_mod);
Referenced by DrawVkFlowingPoly(), DrawVkPoly(), EmitWaterPolys(), QVk_DrawColorRect(), QVk_DrawTexRect(), R_DrawBeam(), R_DrawNullModel(), R_DrawParticles(), R_DrawSkyBox(), R_DrawTriangleOutlines(), R_RenderDlight(), Vk_DrawAliasFrameLerp(), Vk_DrawAliasShadow(), and Vk_RenderLightmappedPoly().
◆ QVk_GetVertexBuffer()
uint8_t* QVk_GetVertexBuffer |
( |
VkDeviceSize |
size, |
|
|
VkBuffer * |
dstBuffer, |
|
|
VkDeviceSize * |
dstOffset |
|
) |
| |
Definition at line 2019 of file vk_common.c.
Referenced by DrawVkFlowingPoly(), DrawVkPoly(), EmitWaterPolys(), R_DrawBeam(), R_DrawNullModel(), R_DrawParticles(), R_DrawSkyBox(), R_DrawSpriteModel(), R_DrawTriangleOutlines(), R_RenderDlight(), Vk_DrawAliasFrameLerp(), Vk_DrawAliasShadow(), Vk_DrawParticles(), and Vk_RenderLightmappedPoly().
◆ QVk_Init()
Definition at line 1510 of file vk_common.c.
1512 PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion)vkGetInstanceProcAddr(
NULL,
"vkEnumerateInstanceVersion");
1513 uint32_t instanceVersion = VK_API_VERSION_1_0;
1515 if (vkEnumerateInstanceVersion)
1517 VK_VERIFY(vkEnumerateInstanceVersion(&instanceVersion));
1520 VkApplicationInfo appInfo = {
1521 .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
1523 .pApplicationName =
"Quake 2",
1524 .applicationVersion = VK_MAKE_VERSION(3, 21, 0),
1525 .pEngineName =
"id Tech 2",
1526 .engineVersion = VK_MAKE_VERSION(2, 0, 0),
1527 .apiVersion = instanceVersion
1531 char **wantedExtensions;
1553 #if defined(_DEBUG) || defined(ENABLE_DEBUG_LABELS)
1558 wantedExtensions = (
char **)malloc(extCount *
sizeof(
const char *));
1562 wantedExtensions[extCount - 1] = VK_EXT_DEBUG_UTILS_EXTENSION_NAME;
1563 #if defined(_DEBUG) || defined(ENABLE_DEBUG_LABELS)
1565 wantedExtensions[extCount - 1] = VK_EXT_DEBUG_UTILS_EXTENSION_NAME;
1569 for (
int i = 0;
i < extCount;
i++)
1576 VkInstanceCreateInfo createInfo = {
1577 .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
1579 .pApplicationInfo = &appInfo,
1580 .enabledLayerCount = 0,
1581 .ppEnabledLayerNames =
NULL,
1582 .enabledExtensionCount = extCount,
1583 .ppEnabledExtensionNames = (
const char*
const*)wantedExtensions
1586 #if VK_HEADER_VERSION > 101
1587 const char *validationLayers[] = {
"VK_LAYER_KHRONOS_validation" };
1589 const char *validationLayers[] = {
"VK_LAYER_LUNARG_standard_validation" };
1594 createInfo.enabledLayerCount =
sizeof(validationLayers) /
sizeof(validationLayers[0]);
1595 createInfo.ppEnabledLayerNames = validationLayers;
1596 for (
int i = 0;
i < createInfo.enabledLayerCount;
i++)
1603 free(wantedExtensions);
1605 if (res != VK_SUCCESS)
1625 if (res != VK_SUCCESS)
1641 .preferredLargeHeapBlockSize = 0,
1642 .pAllocationCallbacks =
NULL,
1643 .pDeviceMemoryCallbacks =
NULL,
1644 .frameInUseCount = 0,
1645 .pHeapSizeLimit =
NULL,
1646 .pVulkanFunctions =
NULL,
1647 .pRecordSettings =
NULL
1651 if (res != VK_SUCCESS)
1660 if (res != VK_SUCCESS)
1679 VkFenceCreateInfo fCreateInfo = {
1680 .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
1682 .flags = VK_FENCE_CREATE_SIGNALED_BIT
1684 VkSemaphoreCreateInfo sCreateInfo = {
1685 .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
1708 VkSampleCountFlagBits supportedMsaa =
vk_device.
properties.limits.framebufferColorSampleCounts;
1709 if (!(supportedMsaa & msaaMode))
1713 msaaMode = VK_SAMPLE_COUNT_1_BIT;
1722 if (res != VK_SUCCESS)
1731 if (res != VK_SUCCESS)
1737 if (res != VK_SUCCESS)
1752 if (res != VK_SUCCESS)
1761 if (res != VK_SUCCESS)
1771 VkCommandBufferAllocateInfo cbInfo = {
1772 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
1775 .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
1780 if (res != VK_SUCCESS)
1806 VkDescriptorSetAllocateInfo dsAllocInfo = {
1807 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
1810 .descriptorSetCount = 1,
Referenced by R_Init().
◆ QVk_ReadPixels()
void QVk_ReadPixels |
( |
uint8_t * |
dstBuffer, |
|
|
uint32_t |
width, |
|
|
uint32_t |
height |
|
) |
| |
Definition at line 465 of file vk_image.c.
468 VkCommandBuffer cmdBuffer;
470 .
usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT,
471 .reqMemFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
472 .prefMemFlags = VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
488 VkImageMemoryBarrier imgBarrier = {
489 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
491 .srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
492 .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
493 .oldLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
494 .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
495 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
496 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
498 .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
499 .subresourceRange.baseMipLevel = 0,
500 .subresourceRange.baseArrayLayer = 0,
501 .subresourceRange.layerCount = 1,
502 .subresourceRange.levelCount = 1
505 vkCmdPipelineBarrier(cmdBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0,
NULL, 0,
NULL, 1, &imgBarrier);
507 VkBufferImageCopy region = {
509 .bufferRowLength =
width,
510 .bufferImageHeight =
height,
511 .imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
512 .imageSubresource.mipLevel = 0,
513 .imageSubresource.baseArrayLayer = 0,
514 .imageSubresource.layerCount = 1,
515 .imageOffset = { 0, 0, 0 },
Referenced by Vk_ScreenShot_f().
◆ QVk_RecreateSwapchain()
◆ QVk_ReleaseTexture()
◆ QVk_Shutdown()
◆ QVk_SubmitCommand()
void QVk_SubmitCommand |
( |
const VkCommandBuffer * |
commandBuffer, |
|
|
const VkQueue * |
queue |
|
) |
| |
Definition at line 35 of file vk_cmd.c.
37 VK_VERIFY(vkEndCommandBuffer(*commandBuffer));
39 VkSubmitInfo submitInfo = {
40 .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
42 .waitSemaphoreCount = 0,
43 .pWaitSemaphores =
NULL,
44 .pWaitDstStageMask =
NULL,
45 .commandBufferCount = 1,
46 .pCommandBuffers = commandBuffer,
47 .signalSemaphoreCount = 0,
48 .pSignalSemaphores =
NULL
51 VkFenceCreateInfo fCreateInfo = {
52 .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
59 VK_VERIFY(vkQueueSubmit(*queue, 1, &submitInfo, queueFence));
Referenced by copyBuffer(), and QVk_ReadPixels().
◆ QVk_SubmitStagingBuffers()
◆ QVk_UpdateTextureData()
void QVk_UpdateTextureData |
( |
qvktexture_t * |
texture, |
|
|
const unsigned char * |
data, |
|
|
uint32_t |
offset_x, |
|
|
uint32_t |
offset_y, |
|
|
uint32_t |
width, |
|
|
uint32_t |
height |
|
) |
| |
Definition at line 402 of file vk_image.c.
408 VkBuffer staging_buffer;
409 VkCommandBuffer command_buffer;
410 uint32_t staging_offset;
411 void *imgData =
QVk_GetStagingBuffer(imageSize, 4, &command_buffer, &staging_buffer, &staging_offset);
412 memcpy(imgData, data, (
size_t)imageSize);
416 VkBufferImageCopy region = {
417 .bufferOffset = staging_offset,
418 .bufferRowLength = 0,
419 .bufferImageHeight = 0,
420 .imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
421 .imageSubresource.mipLevel = 0,
422 .imageSubresource.baseArrayLayer = 0,
423 .imageSubresource.layerCount = 1,
424 .imageOffset = { offset_x, offset_y, 0 },
428 vkCmdCopyBufferToImage(command_buffer, staging_buffer,
texture->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
438 if (unifiedTransferAndGfx ||
texture->sharingMode == VK_SHARING_MODE_EXCLUSIVE)
441 if (!unifiedTransferAndGfx)
Referenced by Draw_StretchRaw(), LM_UploadBlock(), R_RenderBrushPoly(), Vk_LoadPic(), and Vk_RenderLightmappedPoly().
◆ QVk_UpdateTextureSampler()
Definition at line 2225 of file vk_common.c.
2227 assert((
vk_samplers[samplerType] != VK_NULL_HANDLE) &&
"Sampler is VK_NULL_HANDLE!");
2229 VkDescriptorImageInfo dImgInfo = {
2231 .imageView =
texture->imageView,
2232 .imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
2235 VkWriteDescriptorSet writeSet = {
2236 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
2238 .dstSet =
texture->descriptorSet,
2240 .dstArrayElement = 0,
2241 .descriptorCount = 1,
2242 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
2243 .pImageInfo = &dImgInfo,
2244 .pBufferInfo =
NULL,
2245 .pTexelBufferView =
NULL
Referenced by QVk_CreateTexture(), QVk_Init(), Vk_LmapTextureMode(), and Vk_TextureMode().
◆ qvkCmdBeginDebugUtilsLabelEXT
PFN_vkCmdBeginDebugUtilsLabelEXT qvkCmdBeginDebugUtilsLabelEXT |
◆ qvkCmdEndDebugUtilsLabelEXT
PFN_vkCmdEndDebugUtilsLabelEXT qvkCmdEndDebugUtilsLabelEXT |
◆ qvkCreateDebugUtilsMessengerEXT
PFN_vkCreateDebugUtilsMessengerEXT qvkCreateDebugUtilsMessengerEXT |
◆ qvkDestroyDebugUtilsMessengerEXT
PFN_vkDestroyDebugUtilsMessengerEXT qvkDestroyDebugUtilsMessengerEXT |
◆ qvkInsertDebugUtilsLabelEXT
PFN_vkCmdInsertDebugUtilsLabelEXT qvkInsertDebugUtilsLabelEXT |
◆ qvkSetDebugUtilsObjectNameEXT
PFN_vkSetDebugUtilsObjectNameEXT qvkSetDebugUtilsObjectNameEXT |
◆ qvkSetDebugUtilsObjectTagEXT
PFN_vkSetDebugUtilsObjectTagEXT qvkSetDebugUtilsObjectTagEXT |
◆ vk_activeCmdbuffer
VkCommandBuffer vk_activeCmdbuffer |
Definition at line 127 of file vk_common.c.
Referenced by DrawVkFlowingPoly(), DrawVkPoly(), EmitWaterPolys(), QVk_BeginFrame(), QVk_BindPipeline(), QVk_DrawColorRect(), QVk_DrawTexRect(), QVk_Init(), QVk_Shutdown(), R_DrawAliasModel(), R_DrawBeam(), R_DrawNullModel(), R_DrawParticles(), R_DrawSkyBox(), R_DrawSpriteModel(), R_DrawTriangleOutlines(), R_EndWorldRenderpass(), R_RenderDlight(), R_RenderView(), R_SetupVulkan(), R_SetVulkan2D(), Vk_DrawAliasFrameLerp(), Vk_DrawAliasShadow(), Vk_DrawParticles(), and Vk_RenderLightmappedPoly().
◆ vk_colorbuffer
◆ vk_colorbufferWarp
◆ vk_commandPool
VkCommandPool vk_commandPool |
◆ vk_descriptorPool
VkDescriptorPool vk_descriptorPool |
◆ vk_device
Definition at line 51 of file vk_common.c.
Referenced by copyBuffer(), CreateDescriptorPool(), CreateDescriptorSetLayouts(), CreateFramebuffers(), createLogicalDevice(), CreatePipelines(), CreateRenderpasses(), CreateSamplers(), CreateStagingBuffers(), createTextureImage(), CreateUboDescriptorSet(), DestroyDrawBuffer(), DestroyFramebuffers(), DestroyImageViews(), DestroySamplers(), getBestPhysicalDevice(), QVk_BeginFrame(), QVk_CreateBuffer(), QVk_CreateCommandBuffer(), QVk_CreateCommandPool(), QVk_CreateDevice(), QVk_CreateImage(), QVk_CreateImageView(), QVk_CreatePipeline(), QVk_CreateShader(), QVk_CreateSwapchain(), QVk_CreateTexture(), QVk_DestroyPipeline(), QVk_EndFrame(), QVk_FindDepthFormat(), QVk_GetStagingBuffer(), QVk_Init(), QVk_ReadPixels(), QVk_RecreateSwapchain(), QVk_ReleaseTexture(), QVk_Shutdown(), QVk_SubmitCommand(), QVk_UpdateTextureData(), QVk_UpdateTextureSampler(), R_RenderView(), R_Shutdown(), ReleaseSwapBuffers(), selectPhysicalDevice(), SubmitStagingBuffer(), transitionImageLayout(), Vk_LmapTextureMode(), Vk_Strings_f(), and Vk_TextureMode().
◆ vk_drawBeamPipeline
◆ vk_drawColorQuadPipeline
◆ vk_drawDLightPipeline
◆ vk_drawLefthandModelPipelineFan
◆ vk_drawLefthandModelPipelineStrip
◆ vk_drawModelPipelineFan
◆ vk_drawModelPipelineStrip
◆ vk_drawNoDepthModelPipelineFan
◆ vk_drawNoDepthModelPipelineStrip
◆ vk_drawNullModelPipeline
◆ vk_drawParticlesPipeline
◆ vk_drawPointParticlesPipeline
◆ vk_drawPolyLmapPipeline
◆ vk_drawPolyPipeline
◆ vk_drawPolyWarpPipeline
◆ vk_drawSkyboxPipeline
◆ vk_drawSpritePipeline
◆ vk_drawTexQuadPipeline
◆ vk_frameStarted
◆ vk_instance
◆ vk_malloc
Definition at line 48 of file vk_common.c.
Referenced by CreateDynamicBuffers(), createStagedBuffer(), CreateStagingBuffers(), DestroyDrawBuffer(), QVk_BeginFrame(), QVk_CreateBuffer(), QVk_CreateImage(), QVk_EndFrame(), QVk_FreeBuffer(), QVk_GetIndexBuffer(), QVk_GetUniformBuffer(), QVk_GetVertexBuffer(), QVk_Init(), QVk_ReleaseTexture(), QVk_Shutdown(), and RebuildTriangleFanIndexBuffer().
◆ vk_postprocessPipeline
◆ vk_samplerDescSetLayout
VkDescriptorSetLayout vk_samplerDescSetLayout |
◆ vk_shadowsPipelineFan
◆ vk_shadowsPipelineStrip
◆ vk_showTrisPipeline
◆ vk_surface
◆ vk_swapchain
Definition at line 63 of file vk_common.c.
Referenced by CreateFramebuffers(), CreateImageViews(), CreateRenderpasses(), DestroyFramebuffers(), DestroyImageViews(), QVk_BeginFrame(), QVk_BeginRenderpass(), QVk_CreateColorBuffer(), QVk_CreateDepthBuffer(), QVk_CreatePipeline(), QVk_CreateSwapchain(), QVk_EndFrame(), QVk_Init(), QVk_ReadPixels(), QVk_RecreateSwapchain(), QVk_Shutdown(), Vk_ScreenShot_f(), and Vk_Strings_f().
◆ vk_transferCommandPool
VkCommandPool vk_transferCommandPool |
◆ vk_uboDescSetLayout
VkDescriptorSetLayout vk_uboDescSetLayout |
◆ vk_worldWarpPipeline
uint8_t * QVk_GetUniformBuffer(VkDeviceSize size, uint32_t *dstOffset, VkDescriptorSet *dstUboDescriptorSet)
VkCommandBuffer vk_activeCmdbuffer
#define QVk_DebugSetObjectName(a, b, c)
static void createStagedBuffer(const void *data, VkDeviceSize size, qvkbuffer_t *dstBuffer, qvkbufferopts_t bufferOpts, qvkbuffer_t *stagingBuffer)
VkCommandBuffer cmdBuffer
static qvkbuffer_t vk_dynVertexBuffers[NUM_DYNBUFFERS]
VkPipelineCreateFlags flags
#define QVk_DebugLabelBegin(a, b, c, d, e)
static void CreateDescriptorSetLayouts()
VkFormat QVk_FindDepthFormat(void)
void vmaInvalidateAllocation(VmaAllocator allocator, VmaAllocation allocation, VkDeviceSize offset, VkDeviceSize size)
Invalidates memory of given allocation.
qvkpipeline_t vk_drawDLightPipeline
static const char * vendorNameString(uint32_t vendorId)
VkPipeline current_pipeline
uint8_t * QVk_GetStagingBuffer(VkDeviceSize size, int alignment, VkCommandBuffer *cmdBuffer, VkBuffer *buffer, uint32_t *dstOffset)
VkPipelineShaderStageCreateInfo createInfo
VkFence vk_fences[NUM_CMDBUFFERS]
VkSemaphore vk_renderFinishedSemaphores[NUM_CMDBUFFERS]
static int vk_swapBuffersCnt[NUM_SWAPBUFFER_SLOTS]
void QVk_CreateVertexBuffer(const void *data, VkDeviceSize size, qvkbuffer_t *dstBuffer, qvkbuffer_t *stagingBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags)
VkResult QVk_CreateBuffer(VkDeviceSize size, qvkbuffer_t *dstBuffer, const qvkbufferopts_t options)
qvkbuffer_t vk_texRectVbo
static VkResult createLogicalDevice()
VkPhysicalDeviceProperties properties
qvkpipeline_t vk_drawPolyPipeline
qvkpipeline_t vk_drawPolyWarpPipeline
#define BUFFER_RESIZE_FACTOR
VkSampler QVk_UpdateTextureSampler(qvktexture_t *texture, qvksampler_t samplerType)
static VkDebugUtilsMessengerEXT validationMessenger
void Sys_Error(char *error,...)
void QVk_CreateValidationLayers(void)
void QVk_BindPipeline(qvkpipeline_t *pipeline)
VmaAllocationCreateFlags vmaFlags
void vmaUnmapMemory(VmaAllocator allocator, VmaAllocation allocation)
Unmaps memory represented by given allocation, mapped previously using vmaMapMemory().
#define STAGING_BUFFER_MAXSIZE
uint32_t uniform_buffer_max_usage
VkResult QVk_CreateSwapchain(void)
uint32_t uniform_buffer_usage
Description of a Allocator to be created.
static VkResult CreateFramebuffers()
VkResult QVk_CreateUniformBuffer(VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags)
cvar_t *(* Cvar_Set)(char *name, char *value)
static qvkbuffer_t * vk_swapBuffers[NUM_SWAPBUFFER_SLOTS]
static void transitionImageLayout(const VkCommandBuffer *cmdBuffer, const VkQueue *queue, const qvktexture_t *texture, const VkImageLayout oldLayout, const VkImageLayout newLayout)
static void DestroyFramebuffers()
static void createTextureImage(qvktexture_t *dstTex, const unsigned char *data, uint32_t width, uint32_t height)
static qvkstagingbuffer_t vk_stagingBuffers[NUM_DYNBUFFERS]
VkDescriptorSetLayout vk_samplerDescSetLayout
VkCommandPool vk_transferCommandPool
PFN_vkSetDebugUtilsObjectNameEXT qvkSetDebugUtilsObjectNameEXT
qvkswapchain_t vk_swapchain
static VkDescriptorSet * vk_swapDescriptorSets[NUM_SWAPBUFFER_SLOTS]
VkSemaphore vk_imageAvailableSemaphores[NUM_CMDBUFFERS]
VkMemoryPropertyFlags prefMemFlags
uint32_t triangle_fan_index_count
qvkpipeline_t vk_drawNoDepthModelPipelineStrip
uint32_t index_buffer_size
VkPrimitiveTopology topology
#define VERTEX_BUFFER_SIZE
char * va(char *format,...)
static const char * presentModeString(VkPresentModeKHR presentMode)
static void CreateDrawBuffers()
VkFramebuffer * vk_framebuffers[RP_COUNT]
PFN_vkCmdInsertDebugUtilsLabelEXT qvkInsertDebugUtilsLabelEXT
VkDescriptorSet descriptorSet
qvkpipeline_t vk_drawTexQuadPipeline
uint32_t index_buffer_usage
void(* Con_Printf)(int print_level, char *str,...)
VkAttachmentLoadOp colorLoadOp
@ VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT
Set this flag if the allocation should have its own memory block.
void Vkimp_GetSurfaceExtensions(char **extensions, uint32_t *extCount)
VkCommandPool vk_commandPool
static VkResult CreateRenderpasses()
qboolean QVk_CreateDevice(int preferredDeviceIdx)
static void CreateDynamicBuffers()
const char * extensions[256]
@ VMA_MEMORY_USAGE_CPU_ONLY
Memory will be mappable on host.
#define UNIFORM_ALLOC_SIZE
VkSampleCountFlagBits sampleCount
#define UNIFORM_BUFFER_SIZE
static void DestroySamplers()
static qboolean selectPhysicalDevice(int preferredDeviceIdx)
static VkImageAspectFlags getDepthStencilAspect(VkFormat depthFormat)
qvktexture_t vk_colorbufferWarp
uint32_t index_buffer_max_usage
const char * QVk_GetError(VkResult errorCode)
static VkBuffer * vk_triangleFanIbo
static void CreateDescriptorPool()
VkPipelineColorBlendAttachmentState blendOpts
qvkswapchain_t vk_swapchain
static void DestroyDrawBuffers()
qvkpipeline_t vk_drawPolyLmapPipeline
static void CreatePipelines()
void QVk_SubmitStagingBuffers()
uint32_t vertex_buffer_usage
#define QVk_DebugLabelEnd(a)
static VkCommandPool vk_stagingCommandPool
@ VMA_MEMORY_USAGE_GPU_ONLY
Memory will be used on device only, so fast access from the device is preferred.
VkDeviceSize currentOffset
VkPhysicalDeviceFeatures features
PFN_vkCreateDebugUtilsMessengerEXT qvkCreateDebugUtilsMessengerEXT
void QVk_SubmitCommand(const VkCommandBuffer *commandBuffer, const VkQueue *queue)
static void SubmitStagingBuffer(int index)
qvkpipeline_t vk_shadowsPipelineFan
PFN_vkCmdBeginDebugUtilsLabelEXT qvkCmdBeginDebugUtilsLabelEXT
static void CreateSamplers()
VkCommandPool vk_commandPool
qvktexture_t vk_colorbuffer
qvkpipeline_t vk_drawParticlesPipeline
static VkSampleCountFlagBits GetSampleCount()
qvkpipeline_t vk_showTrisPipeline
qvkpipeline_t vk_drawLefthandModelPipelineStrip
VkResult Vkimp_CreateSurface()
VkBool32 depthWriteEnable
#define TRIANGLE_FAN_INDEX_CNT
void R_EndWorldRenderpass(void)
VkResult QVk_BeginCommand(const VkCommandBuffer *commandBuffer)
VmaAllocationInfo allocInfo
void QVk_FreeBuffer(qvkbuffer_t *buffer)
static int vk_activeDynBufferIdx
VkCommandBuffer QVk_CreateCommandBuffer(const VkCommandPool *commandPool, VkCommandBufferLevel level)
VkResult QVk_CreateImageView(const VkImage *image, VkImageAspectFlags aspectFlags, VkImageView *imageView, VkFormat format, uint32_t mipLevels)
void vmaDestroyAllocator(VmaAllocator allocator)
Destroys allocator object.
#define INDEX_BUFFER_SIZE
VkDescriptorSetLayout vk_uboDescSetLayout
VkResult vmaMapMemory(VmaAllocator allocator, VmaAllocation allocation, void **ppData)
Maps memory represented by given allocation and returns pointer to it.
qvkpipeline_t vk_drawNoDepthModelPipelineFan
PFN_vkDestroyDebugUtilsMessengerEXT qvkDestroyDebugUtilsMessengerEXT
static void CreateStaticBuffers()
VkResult vmaCreateImage(VmaAllocator allocator, const VkImageCreateInfo *pImageCreateInfo, const VmaAllocationCreateInfo *pAllocationCreateInfo, VkImage *pImage, VmaAllocation *pAllocation, VmaAllocationInfo *pAllocationInfo)
Function similar to vmaCreateBuffer().
static VkResult CreateImageViews()
uint32_t vertex_buffer_max_usage
uint32_t uniform_buffer_size
VkSampler QVk_UpdateTextureSampler(qvktexture_t *texture, qvksampler_t samplerType)
VkSampleCountFlagBits sampleCount
qvkpipeline_t vk_drawSkyboxPipeline
void * pMappedData
Pointer to the beginning of this allocation as mapped data.
qvkbuffer_t vk_colorRectVbo
VmaAllocatorCreateFlags flags
Flags for created allocator. Use VmaAllocatorCreateFlagBits enum.
qvkpipeline_t vk_drawSpritePipeline
qvkpipeline_t vk_worldWarpPipeline
void QVk_DestroyPipeline(qvkpipeline_t *pipeline)
static void RebuildTriangleFanIndexBuffer()
PFN_vkSetDebugUtilsObjectTagEXT qvkSetDebugUtilsObjectTagEXT
@ VMA_MEMORY_USAGE_CPU_TO_GPU
Memory that is both mappable on host (guarantees to be HOST_VISIBLE) and preferably fast to access by...
static uint32_t vk_triangleFanIboUsage
qvkpipeline_t vk_drawModelPipelineFan[2]
static VkCompositeAlphaFlagBitsKHR getSupportedCompositeAlpha(VkCompositeAlphaFlagsKHR supportedFlags)
static int vk_swapDescSetsCnt[NUM_SWAPBUFFER_SLOTS]
uint32_t triangle_fan_index_usage
VkResult vmaCreateBuffer(VmaAllocator allocator, const VkBufferCreateInfo *pBufferCreateInfo, const VmaAllocationCreateInfo *pAllocationCreateInfo, VkBuffer *pBuffer, VmaAllocation *pAllocation, VmaAllocationInfo *pAllocationInfo)
VkResult QVk_CreateCommandPool(VkCommandPool *commandPool, uint32_t queueFamilyIndex)
PFN_vkCreateDebugUtilsMessengerEXT qvkCreateDebugUtilsMessengerEXT
VkResult vmaCreateAllocator(const VmaAllocatorCreateInfo *pCreateInfo, VmaAllocator *pAllocator)
Creates Allocator object.
VkDescriptorPool vk_descriptorPool
qvkpipeline_t vk_postprocessPipeline
VkDescriptorPool vk_descriptorPool
qvkpipeline_t vk_drawBeamPipeline
void vmaFlushAllocation(VmaAllocator allocator, VmaAllocation allocation, VkDeviceSize offset, VkDeviceSize size)
Flushes memory of given allocation.
qvkpipeline_t vk_shadowsPipelineStrip
static void ReleaseSwapBuffers()
static void CreateUboDescriptorSet(VkDescriptorSet *descSet, VkBuffer buffer)
qvkpipeline_t vk_drawColorQuadPipeline[2]
VkCommandBuffer * vk_commandbuffers
static VKAPI_ATTR VkBool32 VKAPI_CALL debugUtilsCallback(VkDebugUtilsMessageSeverityFlagBitsEXT msgSeverity, VkDebugUtilsMessageTypeFlagsEXT msgType, const VkDebugUtilsMessengerCallbackDataEXT *callbackData, void *userData)
void vmaDestroyImage(VmaAllocator allocator, VkImage image, VmaAllocation allocation)
Destroys Vulkan image and frees allocated memory.
static VkSurfaceFormatKHR getSwapSurfaceFormat(const VkSurfaceFormatKHR *surfaceFormats, uint32_t formatCount)
@ VMA_ALLOCATION_CREATE_MAPPED_BIT
Set this flag to use a memory that will be persistently mapped and retrieve pointer to it.
void vmaDestroyBuffer(VmaAllocator allocator, VkBuffer buffer, VmaAllocation allocation)
Destroys Vulkan buffer and frees allocated memory.
VkResult QVk_CreateImage(uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VmaMemoryUsage memUsage, qvktexture_t *texture)
static VkDescriptorSet vk_uboDescriptorSets[NUM_DYNBUFFERS]
static void CreateStagingBuffers()
VkResult QVk_CreateBuffer(VkDeviceSize size, qvkbuffer_t *dstBuffer, const qvkbufferopts_t options)
qvkpipeline_t vk_drawPointParticlesPipeline
VmaAllocationCreateFlags vmaFlags
static qvkbuffer_t vk_dynUniformBuffers[NUM_DYNBUFFERS]
VkMemoryPropertyFlags reqMemFlags
PFN_vkCmdEndDebugUtilsLabelEXT qvkCmdEndDebugUtilsLabelEXT
qvkpipeline_t vk_drawModelPipelineStrip[2]
VmaAllocationCreateFlags flags
Use VmaAllocationCreateFlagBits enum.
static qvkbuffer_t vk_dynIndexBuffers[NUM_DYNBUFFERS]
uint32_t vertex_buffer_size
qvkrenderpass_t vk_renderpasses[RP_COUNT]
static VkSampler vk_samplers[S_SAMPLER_CNT]
static VkPresentModeKHR getSwapPresentMode(const VkPresentModeKHR *presentModes, uint32_t presentModesCount, VkPresentModeKHR desiredMode)
PFN_vkDestroyDebugUtilsMessengerEXT qvkDestroyDebugUtilsMessengerEXT
void QVk_CreateIndexBuffer(const void *data, VkDeviceSize size, qvkbuffer_t *dstBuffer, qvkbuffer_t *stagingBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags)
VkDescriptorSetLayout vk_samplerDescSetLayout
void QVk_SubmitStagingBuffers(void)
static void DestroyImageViews()
qvkpipeline_t vk_drawLefthandModelPipelineFan
static int vk_activeSwapBufferIdx
int vk_activeStagingBuffer
static void generateMipmaps(const VkCommandBuffer *cmdBuffer, const qvktexture_t *texture, uint32_t width, uint32_t height)
static const char * deviceTypeString(VkPhysicalDeviceType dType)
void QVk_DestroyValidationLayers(void)
VkPhysicalDevice physical
static int NextPow2(int v)
uint32_t triangle_fan_index_max_usage
const char * supported_present_modes[256]
qvkpipeline_t vk_drawNullModelPipeline
VkDescriptorSetLayout vk_samplerLightmapDescSetLayout
const char * QVk_GetError(VkResult errorCode)