mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
vk: single call render NullModel
This commit is contained in:
parent
409b5bcd20
commit
4ebe9a74c0
4 changed files with 21 additions and 35 deletions
|
@ -339,6 +339,7 @@ IMPLEMENTATION SPECIFIC FUNCTIONS
|
|||
qboolean Vkimp_CreateSurface(SDL_Window *window);
|
||||
|
||||
extern mvtx_t *verts_buffer;
|
||||
extern uint16_t *vertIdxData;
|
||||
|
||||
void Mesh_Init (void);
|
||||
void Mesh_Free (void);
|
||||
|
|
|
@ -291,8 +291,8 @@ R_DrawNullModel(entity_t *currententity)
|
|||
verts[i][2] = shadelight[2];
|
||||
}
|
||||
|
||||
VkBuffer vbo, fan;
|
||||
VkDeviceSize vboOffset, fanOffset;
|
||||
VkBuffer vbo, *buffer;
|
||||
VkDeviceSize vboOffset, dstOffset;
|
||||
uint32_t uboOffset;
|
||||
VkDescriptorSet uboDescriptorSet;
|
||||
uint8_t *vertData = QVk_GetVertexBuffer(sizeof(verts), &vbo, &vboOffset);
|
||||
|
@ -300,13 +300,17 @@ R_DrawNullModel(entity_t *currententity)
|
|||
memcpy(vertData, verts, sizeof(verts));
|
||||
memcpy(uboData, model, sizeof(model));
|
||||
|
||||
fan = QVk_GetTriangleFanIbo(12, &fanOffset);
|
||||
Mesh_VertsRealloc(24);
|
||||
GenFanIndexes(vertIdxData, 0, 4);
|
||||
GenFanIndexes(vertIdxData + 4 * 3, 6, 10);
|
||||
buffer = UpdateIndexBuffer(vertIdxData, 24 * sizeof(uint16_t), &dstOffset);
|
||||
|
||||
QVk_BindPipeline(&vk_drawNullModelPipeline);
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawNullModelPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset);
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
vk_drawNullModelPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset);
|
||||
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
|
||||
vkCmdBindIndexBuffer(vk_activeCmdbuffer, fan, fanOffset, VK_INDEX_TYPE_UINT16);
|
||||
vkCmdDrawIndexed(vk_activeCmdbuffer, 12, 1, 0, 0, 0);
|
||||
vkCmdDrawIndexed(vk_activeCmdbuffer, 12, 1, 0, 6, 0);
|
||||
vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16);
|
||||
vkCmdDrawIndexed(vk_activeCmdbuffer, 24, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef struct {
|
|||
mvtx_t *verts_buffer = NULL;
|
||||
static modelvert *vertList = NULL;
|
||||
static vec3_t *shadowverts = NULL;
|
||||
static uint16_t *vertIdxData = NULL;
|
||||
uint16_t *vertIdxData = NULL;
|
||||
|
||||
static int verts_count = 0;
|
||||
|
||||
|
|
|
@ -448,6 +448,14 @@ Vk_RenderLightmappedPoly(msurface_t *surf, const float *modelMatrix, float alpha
|
|||
Com_Error(ERR_FATAL, "%s: can't allocate memory", __func__);
|
||||
}
|
||||
|
||||
VkDescriptorSet descriptorSets[] = {
|
||||
image->vk_texture.descriptorSet,
|
||||
uboDescriptorSet,
|
||||
vk_state.lightmap_textures[lmtex].descriptorSet
|
||||
};
|
||||
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset);
|
||||
|
||||
if (is_dynamic)
|
||||
{
|
||||
int smax, tmax, size;
|
||||
|
@ -489,12 +497,6 @@ Vk_RenderLightmappedPoly(msurface_t *surf, const float *modelMatrix, float alpha
|
|||
|
||||
VkBuffer vbo;
|
||||
VkDeviceSize vboOffset;
|
||||
VkDescriptorSet descriptorSets[] = {
|
||||
image->vk_texture.descriptorSet,
|
||||
uboDescriptorSet,
|
||||
vk_state.lightmap_textures[lmtex].descriptorSet
|
||||
};
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset);
|
||||
|
||||
for (p = surf->polys; p; p = p->chain)
|
||||
{
|
||||
|
@ -522,13 +524,6 @@ Vk_RenderLightmappedPoly(msurface_t *surf, const float *modelMatrix, float alpha
|
|||
{
|
||||
VkDeviceSize vboOffset;
|
||||
VkBuffer vbo;
|
||||
VkDescriptorSet descriptorSets[] = {
|
||||
image->vk_texture.descriptorSet,
|
||||
uboDescriptorSet,
|
||||
vk_state.lightmap_textures[lmtex].descriptorSet
|
||||
};
|
||||
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset);
|
||||
|
||||
for (p = surf->polys; p; p = p->chain)
|
||||
{
|
||||
|
@ -577,14 +572,7 @@ Vk_RenderLightmappedPoly(msurface_t *surf, const float *modelMatrix, float alpha
|
|||
vertData = QVk_GetVertexBuffer(sizeof(mvtx_t) * nv, &vbo, &vboOffset);
|
||||
memcpy(vertData, verts_buffer, sizeof(mvtx_t) * nv);
|
||||
|
||||
VkDescriptorSet descriptorSets[] = {
|
||||
image->vk_texture.descriptorSet,
|
||||
uboDescriptorSet,
|
||||
vk_state.lightmap_textures[lmtex].descriptorSet
|
||||
};
|
||||
|
||||
fan = QVk_GetTriangleFanIbo((nv - 2) * 3, &fanOffset);
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset);
|
||||
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
|
||||
vkCmdBindIndexBuffer(vk_activeCmdbuffer, fan, fanOffset, VK_INDEX_TYPE_UINT16);
|
||||
vkCmdDrawIndexed(vk_activeCmdbuffer, (nv - 2) * 3, 1, 0, 0, 0);
|
||||
|
@ -603,14 +591,7 @@ Vk_RenderLightmappedPoly(msurface_t *surf, const float *modelMatrix, float alpha
|
|||
vertData = QVk_GetVertexBuffer(sizeof(mvtx_t) * nv, &vbo, &vboOffset);
|
||||
memcpy(vertData, p->verts, sizeof(mvtx_t) * nv);
|
||||
|
||||
VkDescriptorSet descriptorSets[] = {
|
||||
image->vk_texture.descriptorSet,
|
||||
uboDescriptorSet,
|
||||
vk_state.lightmap_textures[lmtex].descriptorSet
|
||||
};
|
||||
|
||||
fan = QVk_GetTriangleFanIbo((nv - 2) * 3, &fanOffset);
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset);
|
||||
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
|
||||
vkCmdBindIndexBuffer(vk_activeCmdbuffer, fan, fanOffset, VK_INDEX_TYPE_UINT16);
|
||||
vkCmdDrawIndexed(vk_activeCmdbuffer, (nv - 2) * 3, 1, 0, 0, 0);
|
||||
|
|
Loading…
Reference in a new issue