mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Always use a 16 bit index array for quad indices, with multiple draws when necessary. See issue #1356.
This commit is contained in:
@@ -35,6 +35,7 @@ namespace graphics
|
||||
{
|
||||
|
||||
class Graphics;
|
||||
class Texture;
|
||||
|
||||
/**
|
||||
* A block of GPU-owned memory. Currently meant for internal use.
|
||||
@@ -52,25 +53,13 @@ public:
|
||||
Buffer(size_t size, BufferType type, vertex::Usage usage, uint32 mapflags);
|
||||
virtual ~Buffer();
|
||||
|
||||
size_t getSize() const
|
||||
{
|
||||
return size;
|
||||
}
|
||||
size_t getSize() const { return size; }
|
||||
|
||||
BufferType getType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
BufferType getType() const { return type; }
|
||||
|
||||
vertex::Usage getUsage() const
|
||||
{
|
||||
return usage;
|
||||
}
|
||||
vertex::Usage getUsage() const { return usage; }
|
||||
|
||||
bool isMapped() const
|
||||
{
|
||||
return is_mapped;
|
||||
}
|
||||
bool isMapped() const { return is_mapped; }
|
||||
|
||||
/**
|
||||
* Map the Buffer to client memory.
|
||||
@@ -106,10 +95,7 @@ public:
|
||||
**/
|
||||
virtual void copyTo(size_t offset, size_t size, Buffer *other, size_t otheroffset) = 0;
|
||||
|
||||
uint32 getMapFlags() const
|
||||
{
|
||||
return map_flags;
|
||||
}
|
||||
uint32 getMapFlags() const { return map_flags; }
|
||||
|
||||
class Mapper
|
||||
{
|
||||
@@ -119,7 +105,7 @@ public:
|
||||
* Memory-maps a Buffer.
|
||||
*/
|
||||
Mapper(Buffer &buffer)
|
||||
: buf(buffer)
|
||||
: buf(buffer)
|
||||
{
|
||||
elems = buf.map();
|
||||
}
|
||||
@@ -189,12 +175,13 @@ protected:
|
||||
class QuadIndices
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Adds an entry to the list of sizes and resizes the Buffer
|
||||
* if needed. A size of 1 allocates a group of 6 indices for 4 vertices
|
||||
* creating 1 face.
|
||||
*/
|
||||
QuadIndices(Graphics *gfx, size_t size);
|
||||
QuadIndices(Graphics *gfx);
|
||||
|
||||
QuadIndices(const QuadIndices &other);
|
||||
QuadIndices &operator = (const QuadIndices &other);
|
||||
@@ -205,81 +192,13 @@ public:
|
||||
*/
|
||||
~QuadIndices();
|
||||
|
||||
/**
|
||||
* Returns the number of index groups.
|
||||
* This can be used for getIndexCount to get the full count of indices.
|
||||
*/
|
||||
size_t getSize() const;
|
||||
|
||||
/**
|
||||
* Returns the number of indices that the passed element count will have.
|
||||
* Use QuadIndices::getSize to get the full index count for that
|
||||
* QuadIndices instance.
|
||||
*/
|
||||
size_t getIndexCount(size_t elements) const;
|
||||
|
||||
/**
|
||||
* Returns the integer type of the element array.
|
||||
* If an optional nonzero size argument is passed, the function returns
|
||||
* the integer type of the element array of that size.
|
||||
*/
|
||||
IndexDataType getType(size_t s) const;
|
||||
inline IndexDataType getType() const
|
||||
{
|
||||
return getType(maxSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size in bytes of an element in the element array.
|
||||
* Can be used with getPointer to calculate an offset into the array based
|
||||
* on a number of elements.
|
||||
**/
|
||||
size_t getElementSize() const;
|
||||
|
||||
/**
|
||||
* Returns the pointer to the Buffer.
|
||||
* The pointer will change if a new size request or removal causes a Buffer
|
||||
* resize. It is recommended to retrieve the pointer value directly before
|
||||
* the drawing call.
|
||||
*/
|
||||
void draw(Graphics *gfx, int quadstart, int quadcount, const vertex::Attributes &attributes, vertex::Buffers buffers, Texture *texture);
|
||||
Buffer *getBuffer() const;
|
||||
|
||||
/**
|
||||
* Returns a direct pointer to the index data.
|
||||
*
|
||||
* At least one graphics driver (the one for Kepler nvidia GPUs in OS X)
|
||||
* fails to render geometry if the vertex data was a direct CPU pointer but
|
||||
* the index data came from an Index Buffer.
|
||||
* So the direct pointer to the index buffer should be used instead of the
|
||||
* index buffer when rendering using client-side vertex arrays.
|
||||
**/
|
||||
const void *getIndices(size_t offset) const;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Adds all indices to the array with the type T.
|
||||
* There are no checks for the correct types or overflows. The calling
|
||||
* function should check for that.
|
||||
*/
|
||||
template <typename T> void fill();
|
||||
|
||||
// The size of the array requested by this instance.
|
||||
size_t size;
|
||||
|
||||
// The size in bytes of an element in the element array.
|
||||
static size_t elementSize;
|
||||
|
||||
// The current GLBuffer size. 0 means no Buffer.
|
||||
static size_t maxSize;
|
||||
|
||||
static size_t objectCount;
|
||||
|
||||
// The Buffer for the element array. Can be null.
|
||||
static Buffer *indexBuffer;
|
||||
|
||||
// The array of indices that will also be stored in the index buffer.
|
||||
static char *indices;
|
||||
|
||||
}; // QuadIndices
|
||||
|
||||
|
||||
Reference in New Issue
Block a user