mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-26 06:20:48 +00:00
vk: combine DrawVkFlowingPoly and DrawVkPoly
This commit is contained in:
parent
5d082ab2d9
commit
52a6de3b1e
2 changed files with 30 additions and 83 deletions
|
@ -37,49 +37,7 @@ msurface_t *r_alpha_surfaces;
|
|||
vklightmapstate_t vk_lms;
|
||||
|
||||
static void
|
||||
DrawVkPoly(mpoly_t *p, image_t *texture, const float *color)
|
||||
{
|
||||
QVk_BindPipeline(&vk_drawPolyPipeline);
|
||||
|
||||
VkBuffer vbo, *buffer;
|
||||
VkDeviceSize vboOffset, dstOffset;
|
||||
uint32_t uboOffset;
|
||||
VkDescriptorSet uboDescriptorSet;
|
||||
uint8_t *vertData = QVk_GetVertexBuffer(sizeof(mvtx_t) * p->numverts, &vbo, &vboOffset);
|
||||
uint8_t *uboData = QVk_GetUniformBuffer(sizeof(float) * 4, &uboOffset, &uboDescriptorSet);
|
||||
memcpy(vertData, p->verts, sizeof(mvtx_t) * p->numverts);
|
||||
memcpy(uboData, color, sizeof(float) * 4);
|
||||
|
||||
VkDescriptorSet descriptorSets[] = {
|
||||
texture->vk_texture.descriptorSet,
|
||||
uboDescriptorSet
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
Mesh_VertsRealloc((p->numverts - 2) * 3);
|
||||
GenFanIndexes(vertIdxData, 0, p->numverts - 2);
|
||||
buffer = UpdateIndexBuffer(vertIdxData, (p->numverts - 2) * 3 * sizeof(uint16_t), &dstOffset);
|
||||
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
vk_drawPolyPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);
|
||||
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
|
||||
vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16);
|
||||
vkCmdDrawIndexed(vk_activeCmdbuffer, (p->numverts - 2) * 3, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
//============
|
||||
//PGM
|
||||
/*
|
||||
================
|
||||
DrawVkFlowingPoly -- version of DrawVkPoly that handles scrolling texture
|
||||
================
|
||||
*/
|
||||
static void
|
||||
DrawVkFlowingPoly(msurface_t *fa, image_t *texture, const float *color)
|
||||
DrawVkPoly(msurface_t *fa, image_t *texture, const float *color)
|
||||
{
|
||||
float sscroll, tscroll;
|
||||
mpoly_t *p;
|
||||
|
@ -126,7 +84,8 @@ DrawVkFlowingPoly(msurface_t *fa, image_t *texture, const float *color)
|
|||
GenFanIndexes(vertIdxData, 0, p->numverts - 2);
|
||||
buffer = UpdateIndexBuffer(vertIdxData, (p->numverts - 2) * 3 * sizeof(uint16_t), &dstOffset);
|
||||
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);
|
||||
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
vk_drawPolyPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);
|
||||
vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
|
||||
vkCmdBindIndexBuffer(vk_activeCmdbuffer, *buffer, dstOffset, VK_INDEX_TYPE_UINT16);
|
||||
vkCmdDrawIndexed(vk_activeCmdbuffer, (p->numverts - 2) * 3, 1, 0, 0, 0);
|
||||
|
@ -215,33 +174,29 @@ R_RenderBrushPoly(msurface_t *fa, const float *modelMatrix, float alpha,
|
|||
|
||||
//======
|
||||
//PGM
|
||||
if (fa->texinfo->flags & SURF_SCROLL)
|
||||
{
|
||||
DrawVkFlowingPoly(fa, image, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawVkPoly(fa->polys, image, color);
|
||||
}
|
||||
DrawVkPoly(fa, image, color);
|
||||
//PGM
|
||||
//======
|
||||
|
||||
/*
|
||||
** check for lightmap modification
|
||||
*/
|
||||
/* check for lightmap modification */
|
||||
for (maps = 0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++)
|
||||
{
|
||||
if (r_newrefdef.lightstyles[fa->styles[maps]].white != fa->cached_light[maps])
|
||||
if (r_newrefdef.lightstyles[fa->styles[maps]].white !=
|
||||
fa->cached_light[maps])
|
||||
{
|
||||
goto dynamic;
|
||||
}
|
||||
}
|
||||
|
||||
// dynamic this frame or dynamic previously
|
||||
/* dynamic this frame or dynamic previously */
|
||||
if (fa->dlightframe == r_framecount)
|
||||
{
|
||||
dynamic:
|
||||
|
||||
if (r_dynamic->value)
|
||||
{
|
||||
if (!(fa->texinfo->flags & (SURF_SKY | SURF_TRANSPARENT | SURF_WARP)))
|
||||
if (!(fa->texinfo->flags &
|
||||
(SURF_SKY | SURF_TRANSPARENT | SURF_WARP)))
|
||||
{
|
||||
is_dynamic = true;
|
||||
}
|
||||
|
@ -250,7 +205,10 @@ R_RenderBrushPoly(msurface_t *fa, const float *modelMatrix, float alpha,
|
|||
|
||||
if (is_dynamic)
|
||||
{
|
||||
if ((fa->styles[maps] >= 32 || fa->styles[maps] == 0) && (fa->dlightframe != r_framecount))
|
||||
if (maps < MAXLIGHTMAPS &&
|
||||
((fa->styles[maps] >= 32) ||
|
||||
(fa->styles[maps] == 0)) &&
|
||||
(fa->dlightframe != r_framecount))
|
||||
{
|
||||
int smax, tmax, size;
|
||||
byte *temp;
|
||||
|
@ -284,21 +242,16 @@ R_RenderBrushPoly(msurface_t *fa, const float *modelMatrix, float alpha,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
R_DrawAlphaSurfaces
|
||||
|
||||
Draw water surfaces and windows.
|
||||
The BSP tree is waled front to back, so unwinding the chain
|
||||
of alpha_surfaces will draw back to front, giving proper ordering.
|
||||
================
|
||||
*/
|
||||
* Draw water surfaces and windows.
|
||||
* The BSP tree is waled front to back, so unwinding the chain
|
||||
* of alpha_surfaces will draw back to front, giving proper ordering.
|
||||
*/
|
||||
void
|
||||
R_DrawAlphaSurfaces(void)
|
||||
{
|
||||
msurface_t *s;
|
||||
float intens;
|
||||
msurface_t *s;
|
||||
float intens;
|
||||
|
||||
// the textures are prescaled up for a better lighting range,
|
||||
// so scale it back down
|
||||
|
@ -308,6 +261,7 @@ R_DrawAlphaSurfaces(void)
|
|||
for (s = r_alpha_surfaces; s; s = s->texturechain)
|
||||
{
|
||||
c_brush_polys++;
|
||||
|
||||
if (s->texinfo->flags & SURF_TRANS33)
|
||||
{
|
||||
color[3] = 0.33f;
|
||||
|
@ -321,13 +275,9 @@ R_DrawAlphaSurfaces(void)
|
|||
{
|
||||
EmitWaterPolys(s, s->texinfo->image, NULL, color, false);
|
||||
}
|
||||
else if (s->texinfo->flags & SURF_SCROLL) // PGM 9/16/98
|
||||
{
|
||||
DrawVkFlowingPoly(s, s->texinfo->image, color); // PGM
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawVkPoly(s->polys, s->texinfo->image, color);
|
||||
DrawVkPoly(s, s->texinfo->image, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -467,17 +417,14 @@ Vk_RenderLightmappedPoly(msurface_t *surf, float alpha,
|
|||
VkDeviceSize vboOffset, dstOffset;
|
||||
VkBuffer vbo, *buffer;
|
||||
uint8_t *vertData;
|
||||
float sscroll = 0, tscroll = 0;
|
||||
float sscroll, tscroll;
|
||||
int pos_vect = 0, index_pos = 0;
|
||||
|
||||
c_brush_polys++;
|
||||
|
||||
//==========
|
||||
//PGM
|
||||
if (surf->texinfo->flags & SURF_SCROLL)
|
||||
{
|
||||
R_FlowingScroll(&r_newrefdef, surf->texinfo->flags, &sscroll, &tscroll);
|
||||
}
|
||||
R_FlowingScroll(&r_newrefdef, surf->texinfo->flags, &sscroll, &tscroll);
|
||||
|
||||
for (p = surf->polys; p; p = p->chain)
|
||||
{
|
||||
|
@ -527,7 +474,7 @@ R_DrawInlineBModel(entity_t *currententity, const model_t *currentmodel, float *
|
|||
{
|
||||
int i;
|
||||
msurface_t *psurf;
|
||||
float alpha = 1.f;
|
||||
float alpha = 1.f;
|
||||
|
||||
/* calculate dynamic lighting for bmodel */
|
||||
if (!r_flashblend->value)
|
||||
|
@ -650,10 +597,10 @@ R_DrawBrushModel(entity_t *currententity, const model_t *currentmodel)
|
|||
modelorg[2] = DotProduct(temp, up);
|
||||
}
|
||||
|
||||
Mat_Identity(model);
|
||||
|
||||
currententity->angles[0] = -currententity->angles[0]; // stupid quake bug
|
||||
currententity->angles[2] = -currententity->angles[2]; // stupid quake bug
|
||||
|
||||
Mat_Identity(model);
|
||||
R_RotateForEntity(currententity, model);
|
||||
currententity->angles[0] = -currententity->angles[0]; // stupid quake bug
|
||||
currententity->angles[2] = -currententity->angles[2]; // stupid quake bug
|
||||
|
|
0
value
Normal file
0
value
Normal file
Loading…
Reference in a new issue