2020-01-12 19:28:07 +00:00
|
|
|
|
|
|
|
#ifndef _HW__VERTEXBUFFER_H
|
|
|
|
#define _HW__VERTEXBUFFER_H
|
|
|
|
|
|
|
|
#include "tarray.h"
|
|
|
|
#include "hwrenderer/data/buffers.h"
|
|
|
|
#include <atomic>
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
class FRenderState;
|
|
|
|
struct secplane_t;
|
|
|
|
|
|
|
|
struct FFlatVertex
|
|
|
|
{
|
|
|
|
float x, z, y; // world position
|
|
|
|
float u, v; // texture coordinates
|
|
|
|
|
|
|
|
void Set(float xx, float zz, float yy, float uu, float vv)
|
|
|
|
{
|
|
|
|
x = xx;
|
|
|
|
z = zz;
|
|
|
|
y = yy;
|
|
|
|
u = uu;
|
|
|
|
v = vv;
|
|
|
|
}
|
2020-01-18 21:41:08 +00:00
|
|
|
|
|
|
|
void SetVertex(float _x, float _y, float _z = 0)
|
|
|
|
{
|
|
|
|
x = _x;
|
|
|
|
z = _y;
|
|
|
|
y = _z;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTexCoord(float _u = 0, float _v = 0)
|
|
|
|
{
|
|
|
|
u = _u;
|
|
|
|
v = _v;
|
|
|
|
}
|
|
|
|
|
2020-01-12 19:28:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class FFlatVertexBuffer
|
|
|
|
{
|
2020-04-26 21:17:54 +00:00
|
|
|
public:
|
2020-01-12 19:28:07 +00:00
|
|
|
TArray<FFlatVertex> vbo_shadowdata;
|
|
|
|
TArray<uint32_t> ibo_data;
|
|
|
|
|
|
|
|
IVertexBuffer *mVertexBuffer;
|
|
|
|
IIndexBuffer *mIndexBuffer;
|
|
|
|
|
|
|
|
unsigned int mIndex;
|
|
|
|
std::atomic<unsigned int> mCurIndex;
|
|
|
|
unsigned int mNumReserved;
|
|
|
|
|
|
|
|
|
2020-04-26 21:17:54 +00:00
|
|
|
static const unsigned int BUFFER_SIZE = 2000000;
|
2020-02-09 07:32:40 +00:00
|
|
|
static const unsigned int BUFFER_SIZE_TO_USE = BUFFER_SIZE-500;
|
2020-01-12 19:28:07 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
QUAD_INDEX = 0,
|
|
|
|
FULLSCREEN_INDEX = 4,
|
|
|
|
PRESENT_INDEX = 8,
|
|
|
|
STENCILTOP_INDEX = 12,
|
|
|
|
STENCILBOTTOM_INDEX = 16,
|
|
|
|
|
|
|
|
NUM_RESERVED = 20
|
|
|
|
};
|
|
|
|
|
|
|
|
FFlatVertexBuffer(int width, int height);
|
|
|
|
~FFlatVertexBuffer();
|
|
|
|
|
|
|
|
void OutputResized(int width, int height);
|
|
|
|
std::pair<IVertexBuffer *, IIndexBuffer *> GetBufferObjects() const
|
|
|
|
{
|
|
|
|
return std::make_pair(mVertexBuffer, mIndexBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Copy(int start, int count);
|
|
|
|
|
|
|
|
FFlatVertex *GetBuffer(int index) const
|
|
|
|
{
|
|
|
|
FFlatVertex *ff = (FFlatVertex*)mVertexBuffer->Memory();
|
|
|
|
return &ff[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
FFlatVertex *GetBuffer() const
|
|
|
|
{
|
|
|
|
return GetBuffer(mCurIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<FFlatVertex *, unsigned int> AllocVertices(unsigned int count);
|
|
|
|
|
|
|
|
void Reset()
|
|
|
|
{
|
|
|
|
mCurIndex = mIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Map()
|
|
|
|
{
|
|
|
|
mVertexBuffer->Map();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Unmap()
|
|
|
|
{
|
|
|
|
mVertexBuffer->Unmap();
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|