mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
vk: force clean up vertex push constants
This commit is contained in:
parent
833932ce44
commit
b685aa4683
6 changed files with 25 additions and 12 deletions
|
@ -213,6 +213,8 @@ typedef enum
|
|||
// Vulkan constants: command and dynamic buffer count
|
||||
#define NUM_CMDBUFFERS 32
|
||||
#define NUM_DYNBUFFERS 2
|
||||
#define PUSH_CONSTANT_VERTEX_SIZE 17
|
||||
#define PUSH_CONSTANT_FRAGMENT_SIZE 11
|
||||
|
||||
// Vulkan instance
|
||||
extern VkInstance vk_instance;
|
||||
|
|
|
@ -2676,6 +2676,7 @@ QVk_Draw2DCallsRender(void)
|
|||
uint8_t *vertData, *uboData;
|
||||
VkBuffer vbo;
|
||||
uint32_t uboOffset;
|
||||
float dummy[PUSH_CONSTANT_VERTEX_SIZE] = {0};
|
||||
|
||||
float imgTransform[] = {
|
||||
0, 0,
|
||||
|
@ -2692,6 +2693,8 @@ QVk_Draw2DCallsRender(void)
|
|||
memcpy(vertData, draw2dcolor_calls, vertSize);
|
||||
|
||||
QVk_BindPipeline(&vk_drawColorQuadPipeline[draw2dcolor_rpType]);
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_worldWarpPipeline.layout,
|
||||
VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(dummy), dummy);
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
vk_drawColorQuadPipeline[draw2dcolor_rpType].layout, 0, 1, &uboDescriptorSet, 1, &uboOffset);
|
||||
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1,
|
||||
|
@ -2708,6 +2711,7 @@ QVk_Draw2DCallsRender(void)
|
|||
VkBuffer vbo;
|
||||
uint32_t uboOffset;
|
||||
float gamma = 2.1F - vid_gamma->value;
|
||||
float dummy[PUSH_CONSTANT_VERTEX_SIZE] = {0};
|
||||
|
||||
float imgTransform[] = {
|
||||
0, 0, 1.0, 1.0,
|
||||
|
@ -2723,8 +2727,10 @@ QVk_Draw2DCallsRender(void)
|
|||
uboDescriptorSet
|
||||
};
|
||||
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_worldWarpPipeline.layout,
|
||||
VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(dummy), dummy);
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, PUSH_CONSTANT_VERTEX_SIZE * sizeof(float), sizeof(gamma), &gamma);
|
||||
|
||||
vertSize = draw2dcolor_num * 16 * sizeof(float);
|
||||
vertData = QVk_GetVertexBuffer(vertSize, &vbo, &vboOffset);
|
||||
|
|
|
@ -217,7 +217,7 @@ R_DrawSpriteModel(entity_t *currententity, const model_t *currentmodel)
|
|||
float gamma = 2.1F - vid_gamma->value;
|
||||
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, PUSH_CONSTANT_VERTEX_SIZE * sizeof(float), sizeof(gamma), &gamma);
|
||||
|
||||
if (currententity->frame < currentmodel->numskins)
|
||||
{
|
||||
|
@ -510,7 +510,7 @@ Vk_DrawParticles(int num_particles, const particle_t particles[])
|
|||
float gamma = 2.1F - vid_gamma->value;
|
||||
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, PUSH_CONSTANT_VERTEX_SIZE * sizeof(float), sizeof(gamma), &gamma);
|
||||
|
||||
if (vk_custom_particles->value == 2)
|
||||
{
|
||||
|
@ -898,7 +898,8 @@ R_SetupVulkan (void)
|
|||
// precalculate view-projection matrix
|
||||
Mat_Mul(r_view_matrix, r_projection_matrix, r_viewproj_matrix);
|
||||
// view-projection matrix will always be stored as the first push constant item, so set no offset
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout,
|
||||
VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
|
||||
}
|
||||
|
||||
static void R_Flash( void )
|
||||
|
@ -989,6 +990,8 @@ RE_RenderView(refdef_t *fd)
|
|||
|
||||
qboolean RE_EndWorldRenderpass(void)
|
||||
{
|
||||
float dummy[PUSH_CONSTANT_VERTEX_SIZE] = {0};
|
||||
|
||||
// still some issues?
|
||||
if (!vk_frameStarted)
|
||||
{
|
||||
|
@ -1035,7 +1038,9 @@ qboolean RE_EndWorldRenderpass(void)
|
|||
r_newrefdef.height,
|
||||
};
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_worldWarpPipeline.layout,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(pushConsts), pushConsts);
|
||||
VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(dummy), dummy);
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_worldWarpPipeline.layout,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, PUSH_CONSTANT_VERTEX_SIZE * sizeof(float), sizeof(pushConsts), pushConsts);
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_worldWarpPipeline.layout, 0, 1, &vk_colorbuffer.descriptorSet, 0, NULL);
|
||||
QVk_BindPipeline(&vk_worldWarpPipeline);
|
||||
// Restore full viewport for future steps.
|
||||
|
@ -1068,7 +1073,7 @@ R_SetVulkan2D(const VkViewport* viewport, const VkRect2D* scissor)
|
|||
{
|
||||
float pushConsts[] = { vk_postprocess->value, (2.1 - vid_gamma->value)};
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_postprocessPipeline.layout,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(pushConsts), pushConsts);
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, PUSH_CONSTANT_VERTEX_SIZE * sizeof(float), sizeof(pushConsts), pushConsts);
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_postprocessPipeline.layout, 0, 1, &vk_colorbufferWarp.descriptorSet, 0, NULL);
|
||||
QVk_BindPipeline(&vk_postprocessPipeline);
|
||||
vkCmdDraw(vk_activeCmdbuffer, 3, 1, 0, 0);
|
||||
|
|
|
@ -164,12 +164,12 @@ void QVk_CreatePipeline(const VkDescriptorSetLayout *descriptorLayout,
|
|||
{
|
||||
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
|
||||
.offset = 0,
|
||||
.size = 17 * sizeof(float)
|
||||
.size = PUSH_CONSTANT_VERTEX_SIZE * sizeof(float)
|
||||
},
|
||||
{
|
||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
.offset = 17 * sizeof(float),
|
||||
.size = 11 * sizeof(float)
|
||||
.offset = PUSH_CONSTANT_VERTEX_SIZE * sizeof(float),
|
||||
.size = PUSH_CONSTANT_FRAGMENT_SIZE * sizeof(float)
|
||||
}};
|
||||
|
||||
VkPipelineLayoutCreateInfo plCreateInfo = {
|
||||
|
|
|
@ -78,7 +78,7 @@ DrawVkPoly(msurface_t *fa, image_t *texture, const float *color)
|
|||
float gamma = 2.1F - vid_gamma->value;
|
||||
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, PUSH_CONSTANT_VERTEX_SIZE * sizeof(float), sizeof(gamma), &gamma);
|
||||
|
||||
Mesh_VertsRealloc((p->numverts - 2) * 3);
|
||||
GenFanIndexes(vertIdxData, 0, p->numverts - 2);
|
||||
|
|
|
@ -109,7 +109,7 @@ EmitWaterPolys(msurface_t *fa, image_t *texture, const float *modelMatrix,
|
|||
float gamma = 2.1F - vid_gamma->value;
|
||||
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, PUSH_CONSTANT_VERTEX_SIZE * sizeof(float), sizeof(gamma), &gamma);
|
||||
|
||||
if (solid_surface)
|
||||
{
|
||||
|
@ -253,7 +253,7 @@ R_DrawSkyBox(void)
|
|||
float gamma = 2.1F - vid_gamma->value;
|
||||
|
||||
vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline[vk_state.current_renderpass].layout,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, 17 * sizeof(float), sizeof(gamma), &gamma);
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT, PUSH_CONSTANT_VERTEX_SIZE * sizeof(float), sizeof(gamma), &gamma);
|
||||
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
vk_drawSkyboxPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);
|
||||
|
|
Loading…
Reference in a new issue