Skip to content

Commit

Permalink
Draw all sprites even if they exceed the usual bucket size
Browse files Browse the repository at this point in the history
  • Loading branch information
SomaZ authored and MaceMadunusus committed Oct 24, 2023
1 parent e5cf8c6 commit c919bb2
Showing 1 changed file with 40 additions and 25 deletions.
65 changes: 40 additions & 25 deletions codemp/rd-rend2/tr_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2256,36 +2256,51 @@ static void RB_SurfaceSprites( srfSprites_t *surf )
{ currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS }
};

DrawItem item = {};
item.renderState.stateBits = firstStage->stateBits;
item.renderState.cullType = CT_TWO_SIDED;
item.renderState.depthRange = DepthRange{0.0f, 1.0f};
item.program = program;
item.ibo = surf->ibo;

item.uniformData = uniformDataWriter.Finish(frameAllocator);
uint32_t numBindings;
UniformData *spriteUniformData = uniformDataWriter.Finish(frameAllocator);
SamplerBinding *spriteSamplerBinding = samplerBindingsWriter.Finish(
frameAllocator, &numBindings);

int numDrawIndicesUndrawn = surf->numIndices;
int baseVertex = surf->baseVertex;
while (numDrawIndicesUndrawn > 5)
{
int drawIndices = numDrawIndicesUndrawn > 98298 ? 98298 : numDrawIndicesUndrawn;

DrawItem item = {};
item.renderState.stateBits = firstStage->stateBits;
item.renderState.cullType = CT_TWO_SIDED;
item.renderState.depthRange = DepthRange{ 0.0f, 1.0f };
item.program = program;
item.ibo = surf->ibo;

item.samplerBindings = samplerBindingsWriter.Finish(
frameAllocator, &item.numSamplerBindings);
item.uniformData = spriteUniformData;

DrawItemSetVertexAttributes(
item, surf->attributes, surf->numAttributes, frameAllocator);
DrawItemSetUniformBlockBindings(
item, uniformBlockBindings, frameAllocator);
item.samplerBindings = spriteSamplerBinding;
item.numSamplerBindings = numBindings;

item.draw.type = DRAW_COMMAND_INDEXED;
item.draw.primitiveType = GL_TRIANGLES;
item.draw.numInstances = 1;
item.draw.params.indexed.indexType = GL_UNSIGNED_SHORT;
item.draw.params.indexed.firstIndex = 0;
item.draw.params.indexed.numIndices = surf->numIndices;
item.draw.params.indexed.baseVertex = surf->baseVertex;
DrawItemSetVertexAttributes(
item, surf->attributes, surf->numAttributes, frameAllocator);
DrawItemSetUniformBlockBindings(
item, uniformBlockBindings, frameAllocator);

tess.externalIBO = surf->ibo;
item.draw.type = DRAW_COMMAND_INDEXED;
item.draw.primitiveType = GL_TRIANGLES;
item.draw.numInstances = 1;
item.draw.params.indexed.indexType = GL_UNSIGNED_SHORT;
item.draw.params.indexed.firstIndex = 0;
item.draw.params.indexed.numIndices = drawIndices;
item.draw.params.indexed.baseVertex = baseVertex;

uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer );
uint32_t key = RB_CreateSortKey(item, 0, surf->shader->sort);
RB_AddDrawItem(backEndData->currentPass, key, item);
tess.externalIBO = surf->ibo;

uint32_t RB_CreateSortKey(const DrawItem& item, int stage, int layer);
uint32_t key = RB_CreateSortKey(item, 0, surf->shader->sort);
RB_AddDrawItem(backEndData->currentPass, key, item);

numDrawIndicesUndrawn -= drawIndices;
baseVertex += ((98298 / 6) * 4);
}
}

void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = {
Expand Down

0 comments on commit c919bb2

Please sign in to comment.