Commit 80177879 by Jamie Madill

Move D3D9 vertex format tables to formatutils9.

Vertex format information is useful for querying format properties with the new vertex translation logic with dynamic shaders. Change-Id: I1935c75f1e3920dc1d4a364a2d6968c82692e476 Reviewed-on: https://chromium-review.googlesource.com/184520Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarNicolas Capens <nicolascapens@chromium.org>
parent 7ab02faf
...@@ -33,7 +33,6 @@ typedef void (*ColorCopyFunction)(const void *source, void *dest); ...@@ -33,7 +33,6 @@ typedef void (*ColorCopyFunction)(const void *source, void *dest);
typedef void (*VertexCopyFunction)(const void *input, size_t stride, size_t count, void *output); typedef void (*VertexCopyFunction)(const void *input, size_t stride, size_t count, void *output);
namespace rx namespace rx
{ {
......
...@@ -490,6 +490,8 @@ EGLint Renderer9::initialize() ...@@ -490,6 +490,8 @@ EGLint Renderer9::initialize()
initializeDevice(); initializeDevice();
d3d9::InitializeVertexTranslations(this);
return EGL_SUCCESS; return EGL_SUCCESS;
} }
......
...@@ -33,8 +33,6 @@ class VertexBuffer9 : public VertexBuffer ...@@ -33,8 +33,6 @@ class VertexBuffer9 : public VertexBuffer
virtual bool requiresConversion(const gl::VertexAttribute &attrib) const; virtual bool requiresConversion(const gl::VertexAttribute &attrib) const;
virtual bool requiresConversion(const gl::VertexAttribCurrentValueData &currentValue) const; virtual bool requiresConversion(const gl::VertexAttribCurrentValueData &currentValue) const;
D3DDECLTYPE getDeclType(const gl::VertexAttribute &attrib) const;
virtual unsigned int getBufferSize() const; virtual unsigned int getBufferSize() const;
virtual bool setBufferSize(unsigned int size); virtual bool setBufferSize(unsigned int size);
virtual bool discard(); virtual bool discard();
...@@ -50,38 +48,6 @@ class VertexBuffer9 : public VertexBuffer ...@@ -50,38 +48,6 @@ class VertexBuffer9 : public VertexBuffer
unsigned int mBufferSize; unsigned int mBufferSize;
bool mDynamicUsage; bool mDynamicUsage;
// Attribute format conversion
enum { NUM_GL_VERTEX_ATTRIB_TYPES = 6 };
struct FormatConverter
{
bool identity;
std::size_t outputElementSize;
void (*convertArray)(const void *in, std::size_t stride, std::size_t n, void *out);
D3DDECLTYPE d3dDeclType;
};
static bool mTranslationsInitialized;
static void initializeTranslations(DWORD declTypes);
// [GL types as enumerated by typeIndex()][normalized][size - 1]
static FormatConverter mFormatConverters[NUM_GL_VERTEX_ATTRIB_TYPES][2][4];
struct TranslationDescription
{
DWORD capsFlag;
FormatConverter preferredConversion;
FormatConverter fallbackConversion;
};
// This table is used to generate mFormatConverters.
// [GL types as enumerated by typeIndex()][normalized][size - 1]
static const TranslationDescription mPossibleTranslations[NUM_GL_VERTEX_ATTRIB_TYPES][2][4];
static unsigned int typeIndex(GLenum type);
static const FormatConverter &formatConverter(const gl::VertexAttribute &attribute);
static const FormatConverter &getCurrentValueFormatConverter();
static bool spaceRequired(const gl::VertexAttribute &attrib, std::size_t count, GLsizei instances, static bool spaceRequired(const gl::VertexAttribute &attrib, std::size_t count, GLsizei instances,
unsigned int *outSpaceRequired); unsigned int *outSpaceRequired);
}; };
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "libGLESv2/VertexAttribute.h" #include "libGLESv2/VertexAttribute.h"
#include "libGLESv2/renderer/d3d9/VertexBuffer9.h" #include "libGLESv2/renderer/d3d9/VertexBuffer9.h"
#include "libGLESv2/renderer/d3d9/VertexDeclarationCache.h" #include "libGLESv2/renderer/d3d9/VertexDeclarationCache.h"
#include "libGLESv2/renderer/d3d9/formatutils9.h"
namespace rx namespace rx
{ {
...@@ -131,9 +132,11 @@ GLenum VertexDeclarationCache::applyDeclaration(IDirect3DDevice9 *device, Transl ...@@ -131,9 +132,11 @@ GLenum VertexDeclarationCache::applyDeclaration(IDirect3DDevice9 *device, Transl
mAppliedVBs[stream].offset = attributes[i].offset; mAppliedVBs[stream].offset = attributes[i].offset;
} }
gl::VertexFormat vertexFormat(*attributes[i].attribute, GL_FLOAT);
element->Stream = stream; element->Stream = stream;
element->Offset = 0; element->Offset = 0;
element->Type = vertexBuffer->getDeclType(*attributes[i].attribute); element->Type = d3d9::GetNativeVertexFormat(vertexFormat);
element->Method = D3DDECLMETHOD_DEFAULT; element->Method = D3DDECLMETHOD_DEFAULT;
element->Usage = D3DDECLUSAGE_TEXCOORD; element->Usage = D3DDECLUSAGE_TEXCOORD;
element->UsageIndex = programBinary->getSemanticIndex(i); element->UsageIndex = programBinary->getSemanticIndex(i);
......
...@@ -37,6 +37,17 @@ const D3DFormatSet &GetAllUsedD3DFormats(); ...@@ -37,6 +37,17 @@ const D3DFormatSet &GetAllUsedD3DFormats();
ColorReadFunction GetColorReadFunction(D3DFORMAT format); ColorReadFunction GetColorReadFunction(D3DFORMAT format);
ColorCopyFunction GetFastCopyFunction(D3DFORMAT sourceFormat, GLenum destFormat, GLenum destType, GLuint clientVersion); ColorCopyFunction GetFastCopyFunction(D3DFORMAT sourceFormat, GLenum destFormat, GLenum destType, GLuint clientVersion);
VertexCopyFunction GetVertexCopyFunction(const gl::VertexFormat &vertexFormat);
size_t GetVertexElementSize(const gl::VertexFormat &vertexFormat);
VertexConversionType GetVertexConversionType(const gl::VertexFormat &vertexFormat);
D3DDECLTYPE GetNativeVertexFormat(const gl::VertexFormat &vertexFormat);
GLenum GetDeclTypeComponentType(D3DDECLTYPE declType);
int GetDeclTypeComponentCount(D3DDECLTYPE declType);
bool IsDeclTypeNormalized(D3DDECLTYPE declType);
void InitializeVertexTranslations(const rx::Renderer9 *renderer);
} }
namespace gl_d3d9 namespace gl_d3d9
......
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