Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ static void drawFramerateBar();
#include "WW3D2/part_emt.h"
#include "WW3D2/part_ldr.h"
#include "WW3D2/dx8caps.h"
#include "WW3D2/dx8indexbuffer.h"
#include "WW3D2/dx8vertexbuffer.h"
#include "WW3D2/ww3dformat.h"
#include "WW3D2/agg_def.h"
#include "WW3D2/render2dsentence.h"
Expand Down Expand Up @@ -635,7 +637,10 @@ void W3DDisplay::setup2DRenderState(TextureClass *tex, DrawImageMode mode, Bool
{
if (m_isBatching)
{
if (!m_batchNeedsInit && m_batchTexture == tex && m_batchMode == mode && m_batchGrayscale == grayscale)
// TheSuperHackers @bugfix arcticdolphin 12/10/2026 Flush at half capacity so one draw call cannot overflow the renderer.
const Bool hasRoom = !m_2DRender || m_2DRender->Can_Add(DynamicVBAccessClass::MAX_VERTEX_COUNT / 2, DynamicIBAccessClass::MAX_INDEX_COUNT / 2);

if (!m_batchNeedsInit && hasRoom && m_batchTexture == tex && m_batchMode == mode && m_batchGrayscale == grayscale)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be !hasRoom?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the early return keeps batching only while there is room. Without room it falls through to onFlush().

{
return;
}
Expand Down
2 changes: 2 additions & 0 deletions Core/Libraries/Source/WWVegas/WW3D2/dx8indexbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class DynamicIBAccessClass
void Allocate_DX8_Dynamic_Buffer();

public:
enum { MAX_INDEX_COUNT = 0xffff }; ///< index_count is an unsigned short

DynamicIBAccessClass(unsigned short type, unsigned short index_count);
~DynamicIBAccessClass();

Expand Down
2 changes: 2 additions & 0 deletions Core/Libraries/Source/WWVegas/WW3D2/dx8vertexbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class DynamicVBAccessClass
void Allocate_Sorting_Dynamic_Buffer();
void Allocate_DX8_Dynamic_Buffer();
public:
enum { MAX_VERTEX_COUNT = 0xffff }; ///< vertex_count is an unsigned short

// Type parameter can be either BUFFER_TYPE_DYNAMIC_DX8 or BUFFER_TYPE_DYNAMIC_SORTING.

// Note: Even though the constructor takes fvf as a parameter, currently the
Expand Down
12 changes: 12 additions & 0 deletions Generals/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,24 @@ void Render2DClass::Add_Outline( const RectClass & rect, float width, const Rect
Add_Line (Vector2 (rect.Right, rect.Bottom), Vector2 (rect.Left + 1, rect.Bottom), width, color);
}

bool Render2DClass::Can_Add( int vertex_count, int index_count ) const
{
return Vertices.Count() + vertex_count <= DynamicVBAccessClass::MAX_VERTEX_COUNT
&& Indices.Count() + index_count <= DynamicIBAccessClass::MAX_INDEX_COUNT;
}

void Render2DClass::Render()
{
if ( !Indices.Count() || IsHidden) {
return;
}

const bool fits = Can_Add( 0, 0 );
WWASSERT( fits );
if ( !fits ) {
return;
}

// save the view and projection matrices since we're nuking them
Matrix4x4 view,proj;
Matrix4x4 identity(true);
Expand Down
2 changes: 2 additions & 0 deletions Generals/Code/Libraries/Source/WWVegas/WW3D2/render2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class Render2DClass
virtual void Reset();
void Render();

bool Can_Add( int vertex_count, int index_count ) const;

void Set_Coordinate_Range( const RectClass & range );

void Set_Texture(TextureClass* tex);
Expand Down
12 changes: 12 additions & 0 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,24 @@ void Render2DClass::Add_Outline( const RectClass & rect, float width, const Rect
Add_Line (Vector2 (rect.Right, rect.Bottom), Vector2 (rect.Left + 1, rect.Bottom), width, color);
}

bool Render2DClass::Can_Add( int vertex_count, int index_count ) const
{
return Vertices.Count() + vertex_count <= DynamicVBAccessClass::MAX_VERTEX_COUNT
&& Indices.Count() + index_count <= DynamicIBAccessClass::MAX_INDEX_COUNT;
}

void Render2DClass::Render()
{
if ( !Indices.Count() || IsHidden) {
return;
}

const bool fits = Can_Add( 0, 0 );
WWASSERT( fits );
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
if ( !fits ) {
return;
}

// save the view and projection matrices since we're nuking them
Matrix4x4 view,proj;
Matrix4x4 identity(true);
Expand Down
2 changes: 2 additions & 0 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class Render2DClass
virtual void Reset();
void Render();

bool Can_Add( int vertex_count, int index_count ) const;

void Set_Coordinate_Range( const RectClass & range );

void Set_Texture(TextureClass* tex);
Expand Down
Loading