Renamed and reorganized the vertex conversion tables in VertexBuffer9.

TRAC #22552 Signed-off-by: Jamie Madill Signed-off-by: Nicolas Capens Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1909 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 5b2d855f
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
namespace rx namespace rx
{ {
bool VertexBuffer9::mAttributeTypesInitialized = false; bool VertexBuffer9::mTranslationsInitialized = false;
VertexBuffer9::FormatConverter VertexBuffer9::mAttributeTypes[NUM_GL_VERTEX_ATTRIB_TYPES][2][4]; VertexBuffer9::FormatConverter VertexBuffer9::mFormatConverters[NUM_GL_VERTEX_ATTRIB_TYPES][2][4];
VertexBuffer9::VertexBuffer9(rx::Renderer9 *const renderer) : mRenderer(renderer) VertexBuffer9::VertexBuffer9(rx::Renderer9 *const renderer) : mRenderer(renderer)
{ {
...@@ -26,10 +26,10 @@ VertexBuffer9::VertexBuffer9(rx::Renderer9 *const renderer) : mRenderer(renderer ...@@ -26,10 +26,10 @@ VertexBuffer9::VertexBuffer9(rx::Renderer9 *const renderer) : mRenderer(renderer
mBufferSize = 0; mBufferSize = 0;
mDynamicUsage = false; mDynamicUsage = false;
if (!mAttributeTypesInitialized) if (!mTranslationsInitialized)
{ {
initializeTranslations(renderer->getCapsDeclTypes()); initializeTranslations(renderer->getCapsDeclTypes());
mAttributeTypesInitialized = true; mTranslationsInitialized = true;
} }
} }
...@@ -437,11 +437,11 @@ void VertexBuffer9::initializeTranslations(DWORD declTypes) ...@@ -437,11 +437,11 @@ void VertexBuffer9::initializeTranslations(DWORD declTypes)
{ {
if (mPossibleTranslations[i][j][k].capsFlag == 0 || (declTypes & mPossibleTranslations[i][j][k].capsFlag) != 0) if (mPossibleTranslations[i][j][k].capsFlag == 0 || (declTypes & mPossibleTranslations[i][j][k].capsFlag) != 0)
{ {
mAttributeTypes[i][j][k] = mPossibleTranslations[i][j][k].preferredConversion; mFormatConverters[i][j][k] = mPossibleTranslations[i][j][k].preferredConversion;
} }
else else
{ {
mAttributeTypes[i][j][k] = mPossibleTranslations[i][j][k].fallbackConversion; mFormatConverters[i][j][k] = mPossibleTranslations[i][j][k].fallbackConversion;
} }
} }
} }
...@@ -465,7 +465,7 @@ unsigned int VertexBuffer9::typeIndex(GLenum type) ...@@ -465,7 +465,7 @@ unsigned int VertexBuffer9::typeIndex(GLenum type)
const VertexBuffer9::FormatConverter &VertexBuffer9::formatConverter(const gl::VertexAttribute &attribute) const VertexBuffer9::FormatConverter &VertexBuffer9::formatConverter(const gl::VertexAttribute &attribute)
{ {
return mAttributeTypes[typeIndex(attribute.mType)][attribute.mNormalized][attribute.mSize - 1]; return mFormatConverters[typeIndex(attribute.mType)][attribute.mNormalized][attribute.mSize - 1];
} }
unsigned int VertexBuffer9::spaceRequired(const gl::VertexAttribute &attrib, std::size_t count, GLsizei instances) unsigned int VertexBuffer9::spaceRequired(const gl::VertexAttribute &attrib, std::size_t count, GLsizei instances)
......
...@@ -54,6 +54,8 @@ class VertexBuffer9 : public VertexBuffer ...@@ -54,6 +54,8 @@ class VertexBuffer9 : public VertexBuffer
bool mDynamicUsage; bool mDynamicUsage;
// Attribute format conversion // Attribute format conversion
enum { NUM_GL_VERTEX_ATTRIB_TYPES = 6 };
struct FormatConverter struct FormatConverter
{ {
bool identity; bool identity;
...@@ -62,10 +64,11 @@ class VertexBuffer9 : public VertexBuffer ...@@ -62,10 +64,11 @@ class VertexBuffer9 : public VertexBuffer
D3DDECLTYPE d3dDeclType; D3DDECLTYPE d3dDeclType;
}; };
enum { NUM_GL_VERTEX_ATTRIB_TYPES = 6 }; static bool mTranslationsInitialized;
static void initializeTranslations(DWORD declTypes);
static bool mAttributeTypesInitialized; // [GL types as enumerated by typeIndex()][normalized][size - 1]
static FormatConverter mAttributeTypes[NUM_GL_VERTEX_ATTRIB_TYPES][2][4]; // [GL types as enumerated by typeIndex()][normalized][size - 1] static FormatConverter mFormatConverters[NUM_GL_VERTEX_ATTRIB_TYPES][2][4];
struct TranslationDescription struct TranslationDescription
{ {
...@@ -74,10 +77,9 @@ class VertexBuffer9 : public VertexBuffer ...@@ -74,10 +77,9 @@ class VertexBuffer9 : public VertexBuffer
FormatConverter fallbackConversion; FormatConverter fallbackConversion;
}; };
// This table is used to generate mAttributeTypes. // This table is used to generate mFormatConverters.
static const TranslationDescription mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4]; // [GL types as enumerated by typeIndex()][normalized][size - 1] // [GL types as enumerated by typeIndex()][normalized][size - 1]
static const TranslationDescription mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4];
static void initializeTranslations(DWORD declTypes);
static unsigned int typeIndex(GLenum type); static unsigned int typeIndex(GLenum type);
static const FormatConverter &formatConverter(const gl::VertexAttribute &attribute); static const FormatConverter &formatConverter(const gl::VertexAttribute &attribute);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment