Commit 7ab02faf by Jamie Madill

Add D3D11 vertex format tables to our format utils.

Moving the vertex format information to a globally accessible helper file makes them available for the dynamic shaders logic. Change-Id: I67d6280c0603d9c601ca504751c8905677c2426f Reviewed-on: https://chromium-review.googlesource.com/184399Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 3078d0f7
...@@ -129,10 +129,9 @@ inline bool supportsSSE2() ...@@ -129,10 +129,9 @@ inline bool supportsSSE2()
template <typename destType, typename sourceType> template <typename destType, typename sourceType>
destType bitCast(const sourceType &source) destType bitCast(const sourceType &source)
{ {
META_ASSERT(sizeof(destType) >= sizeof(sourceType)); size_t copySize = std::min(sizeof(destType), sizeof(sourceType));
destType output; destType output;
memcpy(&output, &source, sizeof(sourceType)); memcpy(&output, &source, copySize);
return output; return output;
} }
......
...@@ -240,4 +240,17 @@ struct VertexFormat ...@@ -240,4 +240,17 @@ struct VertexFormat
} }
namespace rx
{
enum VertexConversionType
{
VERTEX_CONVERT_NONE = 0,
VERTEX_CONVERT_CPU = 1,
VERTEX_CONVERT_GPU = 2,
VERTEX_CONVERT_BOTH = 3
};
}
#endif // LIBGLESV2_ANGLETYPES_H_ #endif // LIBGLESV2_ANGLETYPES_H_
...@@ -31,6 +31,9 @@ typedef void (*ColorReadFunction)(const void *source, void *dest); ...@@ -31,6 +31,9 @@ typedef void (*ColorReadFunction)(const void *source, void *dest);
typedef void (*ColorWriteFunction)(const void *source, void *dest); typedef void (*ColorWriteFunction)(const void *source, void *dest);
typedef void (*ColorCopyFunction)(const void *source, void *dest); typedef void (*ColorCopyFunction)(const void *source, void *dest);
typedef void (*VertexCopyFunction)(const void *input, size_t stride, size_t count, void *output);
namespace rx namespace rx
{ {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "libGLESv2/ProgramBinary.h" #include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/VertexAttribute.h" #include "libGLESv2/VertexAttribute.h"
#include "libGLESv2/renderer/VertexDataManager.h" #include "libGLESv2/renderer/VertexDataManager.h"
#include "libGLESv2/renderer/d3d11/formatutils11.h"
#include "third_party/murmurhash/MurmurHash3.h" #include "third_party/murmurhash/MurmurHash3.h"
...@@ -99,9 +100,9 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M ...@@ -99,9 +100,9 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
BufferStorage11 *bufferStorage = attributes[i].storage ? BufferStorage11::makeBufferStorage11(attributes[i].storage) : NULL; BufferStorage11 *bufferStorage = attributes[i].storage ? BufferStorage11::makeBufferStorage11(attributes[i].storage) : NULL;
D3D11_INPUT_CLASSIFICATION inputClass = attributes[i].divisor > 0 ? D3D11_INPUT_PER_INSTANCE_DATA : D3D11_INPUT_PER_VERTEX_DATA; D3D11_INPUT_CLASSIFICATION inputClass = attributes[i].divisor > 0 ? D3D11_INPUT_PER_INSTANCE_DATA : D3D11_INPUT_PER_VERTEX_DATA;
DXGI_FORMAT dxgiFormat = attributes[i].attribute->mArrayEnabled ?
VertexBuffer11::getAttributeDXGIFormat(*attributes[i].attribute) : gl::VertexFormat vertexFormat(*attributes[i].attribute, attributes[i].currentValueType);
VertexBuffer11::getCurrentValueDXGIFormat(attributes[i].currentValueType); DXGI_FORMAT dxgiFormat = gl_d3d11::GetNativeVertexFormat(vertexFormat);
// Record the type of the associated vertex shader vector in our key // Record the type of the associated vertex shader vector in our key
// This will prevent mismatched vertex shaders from using the same input layout // This will prevent mismatched vertex shaders from using the same input layout
......
...@@ -38,9 +38,6 @@ class VertexBuffer11 : public VertexBuffer ...@@ -38,9 +38,6 @@ class VertexBuffer11 : public VertexBuffer
virtual bool setBufferSize(unsigned int size); virtual bool setBufferSize(unsigned int size);
virtual bool discard(); virtual bool discard();
static DXGI_FORMAT getAttributeDXGIFormat(const gl::VertexAttribute &attrib);
static DXGI_FORMAT getCurrentValueDXGIFormat(GLenum currentValueType);
ID3D11Buffer *getBuffer() const; ID3D11Buffer *getBuffer() const;
private: private:
...@@ -51,24 +48,6 @@ class VertexBuffer11 : public VertexBuffer ...@@ -51,24 +48,6 @@ class VertexBuffer11 : public VertexBuffer
ID3D11Buffer *mBuffer; ID3D11Buffer *mBuffer;
unsigned int mBufferSize; unsigned int mBufferSize;
bool mDynamicUsage; bool mDynamicUsage;
typedef void (*VertexConversionFunction)(const void *, unsigned int, unsigned int, void *);
struct VertexConverter
{
VertexConversionFunction conversionFunc;
bool identity;
DXGI_FORMAT dxgiFormat;
unsigned int outputElementSize;
};
static const unsigned int NUM_GL_FLOAT_VERTEX_ATTRIB_TYPES = 11;
static const VertexConverter mFloatVertexTranslations[NUM_GL_FLOAT_VERTEX_ATTRIB_TYPES][2][4]; // [GL types as enumerated by typeIndex()][normalized][size - 1]
static const unsigned int NUM_GL_INTEGER_VERTEX_ATTRIB_TYPES = 8;
static const VertexConverter mIntegerVertexTranslations[NUM_GL_INTEGER_VERTEX_ATTRIB_TYPES][4]; // [GL types as enumerated by typeIndex()][size - 1]
static const VertexConverter &getVertexConversion(const gl::VertexAttribute &attribute);
static const VertexConverter &getVertexConversion(GLenum type, bool pureInteger, bool normalized, int size);
}; };
} }
......
...@@ -60,6 +60,11 @@ DXGI_FORMAT GetSwizzleRTVFormat(GLint internalFormat, const Renderer *renderer); ...@@ -60,6 +60,11 @@ DXGI_FORMAT GetSwizzleRTVFormat(GLint internalFormat, const Renderer *renderer);
bool RequiresTextureDataInitialization(GLint internalFormat); bool RequiresTextureDataInitialization(GLint internalFormat);
InitializeTextureDataFunction GetTextureDataInitializationFunction(GLint internalFormat); InitializeTextureDataFunction GetTextureDataInitializationFunction(GLint internalFormat);
VertexCopyFunction GetVertexCopyFunction(const gl::VertexFormat &vertexFormat);
size_t GetVertexElementSize(const gl::VertexFormat &vertexFormat);
VertexConversionType GetVertexConversionType(const gl::VertexFormat &vertexFormat);
DXGI_FORMAT GetNativeVertexFormat(const gl::VertexFormat &vertexFormat);
} }
namespace d3d11_gl namespace d3d11_gl
......
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