Преглед изворни кода

vertex buffer: added some accessors to inspect a VertexDeclaration/Stream/Buffer

legacy
Benlitz benlitz пре 11 година
родитељ
комит
9a38b27bd8
2 измењених фајлова са 84 додато и 1 уклоњено
  1. +45
    -0
      src/gpu/vertexbuffer.cpp
  2. +39
    -1
      src/lol/gpu/vertexbuffer.h

+ 45
- 0
src/gpu/vertexbuffer.cpp Прегледај датотеку

@@ -598,6 +598,46 @@ void VertexDeclaration::AddStream(VertexStreamBase const &s)
}
}

int VertexDeclaration::GetStreamCount() const
{
return m_count ? m_streams[m_count - 1].index + 1 : 0;
}

VertexStreamBase VertexDeclaration::GetStream(int index) const
{
VertexStreamBase stream;
int n = 0;

for (int i = 0; i < m_count; ++i)
{
if (m_streams[i].index != index)
continue;

switch (m_streams[i].stream_type)
{
#define LOL_TYPE(T) \
case VertexStreamBase::Type##T: stream.AddStream<T>(n++, m_streams[i].usage); break;

LOL_TYPE(void)
LOL_TYPE(half) LOL_TYPE(f16vec2) LOL_TYPE(f16vec3) LOL_TYPE(f16vec4)
LOL_TYPE(float) LOL_TYPE(vec2) LOL_TYPE(vec3) LOL_TYPE(vec4)
LOL_TYPE(double) LOL_TYPE(dvec2) LOL_TYPE(dvec3) LOL_TYPE(dvec4)
LOL_TYPE(int8_t) LOL_TYPE(i8vec2) LOL_TYPE(i8vec3) LOL_TYPE(i8vec4)
LOL_TYPE(uint8_t) LOL_TYPE(u8vec2) LOL_TYPE(u8vec3) LOL_TYPE(u8vec4)
LOL_TYPE(int16_t) LOL_TYPE(i16vec2) LOL_TYPE(i16vec3) LOL_TYPE(i16vec4)
LOL_TYPE(uint16_t) LOL_TYPE(u16vec2) LOL_TYPE(u16vec3) LOL_TYPE(u16vec4)
LOL_TYPE(int32_t) LOL_TYPE(ivec2) LOL_TYPE(ivec3) LOL_TYPE(ivec4)
LOL_TYPE(uint32_t) LOL_TYPE(uvec2) LOL_TYPE(uvec3) LOL_TYPE(uvec4)
#undef LOL_TYPE
}
}

for (int i = m_count; i < 12; ++i)
stream.AddStream<void>(i, VertexStreamBase::Typevoid);

return stream;
}

//
// The VertexBuffer class
// ----------------------
@@ -634,6 +674,11 @@ VertexBuffer::~VertexBuffer()
delete m_data;
}

size_t VertexBuffer::GetSize()
{
return m_data->m_size;
}

void *VertexBuffer::Lock(size_t offset, size_t size)
{
if (!m_data->m_size)


+ 39
- 1
src/lol/gpu/vertexbuffer.h Прегледај датотеку

@@ -29,6 +29,8 @@ public:
VertexBuffer(size_t size);
~VertexBuffer();

size_t GetSize();

void *Lock(size_t offset, size_t size);
void Unlock();

@@ -142,7 +144,7 @@ class VertexStreamBase
{
friend class VertexDeclaration;

protected:
public:
enum
{
Typevoid = 0,
@@ -157,6 +159,38 @@ protected:
Typeuint32_t, Typeuvec2, Typeuvec3, Typeuvec4,
};

int GetSize() const
{
int size = 0, i = 0;
while (m_streams[i].size)
size += m_streams[i++].size;
return size;
}

int GetStreamCount() const
{
int i = 0;
while (m_streams[i].size) ++i;
return i;
}

VertexUsage GetUsage(int index) const
{
return m_streams[index].usage;
}

uint8_t GetType(int index) const
{
return m_streams[index].stream_type;
}

uint8_t GetSize(int index) const
{
return m_streams[index].size;
}

protected:

#define LOL_TYPE(T) \
static uint8_t GetType(T *x) { UNUSED(x); return Type##T; }

@@ -266,6 +300,10 @@ public:
ShaderAttrib attr11 = ShaderAttrib(),
ShaderAttrib attr12 = ShaderAttrib());

int GetStreamCount() const;

VertexStreamBase GetStream(int index) const;

private:
void Initialize();
void AddStream(VertexStreamBase const &);


Loading…
Откажи
Сачувај