Commit ee21a187 by Jamie Madill Committed by Commit Bot

Store angle::Format in gl::VertexAttribute.

Instead of storing type/size/normalized/pureInteger we instead store a pointer to the angle::Format. This makes some code logic simpler and will let us more easily check if a vertex attribute format changes in calls to VertexAttribPointer or VertexAttribFormat. This CL adds extra information to angle::Format to represent the vertex format info needed. It also caches the channel count so that it can be queried faster. Also renames "Int" -> "Sint" in UtilsVk for consistency. Bug: angleproject:3256 Change-Id: I5ef9b983dad8a58c341113c802500b89ce081566 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1684293 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent b00ecb9a
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"ANGLE format:src/libANGLE/renderer/FormatID_autogen.h": "ANGLE format:src/libANGLE/renderer/FormatID_autogen.h":
"083c08bb743bf72a900079890b14184f", "083c08bb743bf72a900079890b14184f",
"ANGLE format:src/libANGLE/renderer/Format_table_autogen.cpp": "ANGLE format:src/libANGLE/renderer/Format_table_autogen.cpp":
"a4cf00b75621bc058c4a1b341bdf6989", "24a7e010def51eb4342caa5392536ea9",
"ANGLE format:src/libANGLE/renderer/angle_format.py": "ANGLE format:src/libANGLE/renderer/angle_format.py":
"7ce0869650454e1eebc93658d4d96844", "7ce0869650454e1eebc93658d4d96844",
"ANGLE format:src/libANGLE/renderer/angle_format_data.json": "ANGLE format:src/libANGLE/renderer/angle_format_data.json":
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"ANGLE format:src/libANGLE/renderer/angle_format_map.json": "ANGLE format:src/libANGLE/renderer/angle_format_map.json":
"be9f9bdbdf785dda05920146e8c55dbb", "be9f9bdbdf785dda05920146e8c55dbb",
"ANGLE format:src/libANGLE/renderer/gen_angle_format_table.py": "ANGLE format:src/libANGLE/renderer/gen_angle_format_table.py":
"1443d23f2dc1e9d7dc86ae0d512e6814", "37f4654bca2bebc7fdec1fc7ca9bc622",
"ANGLE load functions table:src/libANGLE/renderer/gen_load_functions_table.py": "ANGLE load functions table:src/libANGLE/renderer/gen_load_functions_table.py":
"e65c50e84fc38ad34d0eb0bebb84aab6", "e65c50e84fc38ad34d0eb0bebb84aab6",
"ANGLE load functions table:src/libANGLE/renderer/load_functions_data.json": "ANGLE load functions table:src/libANGLE/renderer/load_functions_data.json":
...@@ -496,21 +496,21 @@ ...@@ -496,21 +496,21 @@
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/BlitResolveStencilNoExport.comp": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/BlitResolveStencilNoExport.comp":
"3080e264f932ce3a219bb63c79b86636", "3080e264f932ce3a219bb63c79b86636",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/BufferUtils.comp": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/BufferUtils.comp":
"0c8c050841543da0d7faca2559212aa8", "b7c20e019199f8328ef37b11c6fbcadd",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/ConvertIndex.comp": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/ConvertIndex.comp":
"ca35df77d258baa0636529d1f0f446a9", "ca35df77d258baa0636529d1f0f446a9",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/ConvertVertex.comp": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/ConvertVertex.comp":
"93649f61036c2fa4739988ad71f413df", "e1a64b49ac57bf7aa48913f818d6a522",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/FullScreenQuad.vert": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/FullScreenQuad.vert":
"805ec8b2f87d4bd4242dc5b1c58ba3b4", "805ec8b2f87d4bd4242dc5b1c58ba3b4",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/ImageClear.frag": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/ImageClear.frag":
"7f562c60e5df018b0087ecb8642ac821", "8889ae8014a657a0efd5607954126945",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/ImageCopy.frag": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/ImageCopy.frag":
"20c83ade1efb48a802dc34ca838a2be6", "f0f3cc82d78198f114b698e1aea31267",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/vk_internal_shaders_autogen.cpp": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/vk_internal_shaders_autogen.cpp":
"7891716bf0c429ddacfbb2823f166dc6", "7891716bf0c429ddacfbb2823f166dc6",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/vk_internal_shaders_autogen.h": "Vulkan internal shader programs:src/libANGLE/renderer/vulkan/vk_internal_shaders_autogen.h":
"63e63b37508787d66a0e4aab7e36ffd8", "545807c51af450c31eb3fdf6d784d753",
"Vulkan internal shader programs:tools/glslang/glslang_validator.exe.sha1": "Vulkan internal shader programs:tools/glslang/glslang_validator.exe.sha1":
"289f30598865a987a21b79ae525fc66f", "289f30598865a987a21b79ae525fc66f",
"Vulkan internal shader programs:tools/glslang/glslang_validator.sha1": "Vulkan internal shader programs:tools/glslang/glslang_validator.sha1":
......
...@@ -389,12 +389,12 @@ ANGLE_INLINE void VertexArray::setVertexAttribFormatImpl(VertexAttribute *attrib ...@@ -389,12 +389,12 @@ ANGLE_INLINE void VertexArray::setVertexAttribFormatImpl(VertexAttribute *attrib
GLint size, GLint size,
VertexAttribType type, VertexAttribType type,
bool normalized, bool normalized,
bool pureInteger,
GLuint relativeOffset) GLuint relativeOffset)
{ {
attrib->size = size; angle::FormatID formatID = gl::GetVertexFormatID(type, normalized, size, pureInteger);
attrib->type = type; attrib->format = &angle::Format::Get(formatID);
attrib->normalized = normalized; attrib->relativeOffset = relativeOffset;
attrib->relativeOffset = relativeOffset;
} }
void VertexArray::setVertexAttribFormat(size_t attribIndex, void VertexArray::setVertexAttribFormat(size_t attribIndex,
...@@ -405,12 +405,11 @@ void VertexArray::setVertexAttribFormat(size_t attribIndex, ...@@ -405,12 +405,11 @@ void VertexArray::setVertexAttribFormat(size_t attribIndex,
GLuint relativeOffset) GLuint relativeOffset)
{ {
VertexAttribute &attrib = mState.mVertexAttributes[attribIndex]; VertexAttribute &attrib = mState.mVertexAttributes[attribIndex];
attrib.pureInteger = pureInteger;
ComponentType componentType = GetVertexAttributeComponentType(pureInteger, type); ComponentType componentType = GetVertexAttributeComponentType(pureInteger, type);
SetComponentTypeMask(componentType, attribIndex, &mState.mVertexAttributesTypeMask); SetComponentTypeMask(componentType, attribIndex, &mState.mVertexAttributesTypeMask);
setVertexAttribFormatImpl(&attrib, size, type, normalized, relativeOffset); setVertexAttribFormatImpl(&attrib, size, type, normalized, pureInteger, relativeOffset);
setDirtyAttribBit(attribIndex, DIRTY_ATTRIB_FORMAT); setDirtyAttribBit(attribIndex, DIRTY_ATTRIB_FORMAT);
attrib.updateCachedElementLimit(mState.mVertexBindings[attrib.bindingIndex]); attrib.updateCachedElementLimit(mState.mVertexBindings[attrib.bindingIndex]);
...@@ -461,11 +460,10 @@ ANGLE_INLINE void VertexArray::setVertexAttribPointerImpl(const Context *context ...@@ -461,11 +460,10 @@ ANGLE_INLINE void VertexArray::setVertexAttribPointerImpl(const Context *context
GLintptr offset = boundBuffer ? reinterpret_cast<GLintptr>(pointer) : 0; GLintptr offset = boundBuffer ? reinterpret_cast<GLintptr>(pointer) : 0;
VertexAttribute &attrib = mState.mVertexAttributes[attribIndex]; VertexAttribute &attrib = mState.mVertexAttributes[attribIndex];
attrib.pureInteger = pureInteger;
SetComponentTypeMask(componentType, attribIndex, &mState.mVertexAttributesTypeMask); SetComponentTypeMask(componentType, attribIndex, &mState.mVertexAttributesTypeMask);
setVertexAttribFormatImpl(&attrib, size, type, normalized, 0); setVertexAttribFormatImpl(&attrib, size, type, normalized, pureInteger, 0);
setVertexAttribBinding(context, attribIndex, static_cast<GLuint>(attribIndex)); setVertexAttribBinding(context, attribIndex, static_cast<GLuint>(attribIndex));
GLsizei effectiveStride = GLsizei effectiveStride =
......
...@@ -156,6 +156,7 @@ class VertexArray final : public angle::ObserverInterface, ...@@ -156,6 +156,7 @@ class VertexArray final : public angle::ObserverInterface,
GLint size, GLint size,
VertexAttribType type, VertexAttribType type,
bool normalized, bool normalized,
bool pureInteger,
GLuint relativeOffset); GLuint relativeOffset);
void bindVertexBufferImpl(const Context *context, void bindVertexBufferImpl(const Context *context,
size_t bindingIndex, size_t bindingIndex,
......
...@@ -48,10 +48,7 @@ void VertexBinding::onContainerBindingChanged(const Context *context, int incr) ...@@ -48,10 +48,7 @@ void VertexBinding::onContainerBindingChanged(const Context *context, int incr)
VertexAttribute::VertexAttribute(GLuint bindingIndex) VertexAttribute::VertexAttribute(GLuint bindingIndex)
: enabled(false), : enabled(false),
type(VertexAttribType::Float), format(&angle::Format::Get(angle::FormatID::R32G32B32A32_FLOAT)),
size(4u),
normalized(false),
pureInteger(false),
pointer(nullptr), pointer(nullptr),
relativeOffset(0), relativeOffset(0),
vertexAttribArrayStride(0), vertexAttribArrayStride(0),
...@@ -61,10 +58,7 @@ VertexAttribute::VertexAttribute(GLuint bindingIndex) ...@@ -61,10 +58,7 @@ VertexAttribute::VertexAttribute(GLuint bindingIndex)
VertexAttribute::VertexAttribute(VertexAttribute &&attrib) VertexAttribute::VertexAttribute(VertexAttribute &&attrib)
: enabled(attrib.enabled), : enabled(attrib.enabled),
type(attrib.type), format(attrib.format),
size(attrib.size),
normalized(attrib.normalized),
pureInteger(attrib.pureInteger),
pointer(attrib.pointer), pointer(attrib.pointer),
relativeOffset(attrib.relativeOffset), relativeOffset(attrib.relativeOffset),
vertexAttribArrayStride(attrib.vertexAttribArrayStride), vertexAttribArrayStride(attrib.vertexAttribArrayStride),
...@@ -77,10 +71,7 @@ VertexAttribute &VertexAttribute::operator=(VertexAttribute &&attrib) ...@@ -77,10 +71,7 @@ VertexAttribute &VertexAttribute::operator=(VertexAttribute &&attrib)
if (this != &attrib) if (this != &attrib)
{ {
enabled = attrib.enabled; enabled = attrib.enabled;
type = attrib.type; format = attrib.format;
size = attrib.size;
normalized = attrib.normalized;
pureInteger = attrib.pureInteger;
pointer = attrib.pointer; pointer = attrib.pointer;
relativeOffset = attrib.relativeOffset; relativeOffset = attrib.relativeOffset;
vertexAttribArrayStride = attrib.vertexAttribArrayStride; vertexAttribArrayStride = attrib.vertexAttribArrayStride;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "libANGLE/Buffer.h" #include "libANGLE/Buffer.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/renderer/Format.h"
namespace gl namespace gl
{ {
...@@ -81,10 +82,7 @@ struct VertexAttribute final : private angle::NonCopyable ...@@ -81,10 +82,7 @@ struct VertexAttribute final : private angle::NonCopyable
GLint64 getCachedElementLimit() const { return mCachedElementLimit; } GLint64 getCachedElementLimit() const { return mCachedElementLimit; }
bool enabled; // For glEnable/DisableVertexAttribArray bool enabled; // For glEnable/DisableVertexAttribArray
VertexAttribType type; const angle::Format *format;
GLuint size;
bool normalized;
bool pureInteger;
const void *pointer; const void *pointer;
GLuint relativeOffset; GLuint relativeOffset;
...@@ -102,36 +100,8 @@ struct VertexAttribute final : private angle::NonCopyable ...@@ -102,36 +100,8 @@ struct VertexAttribute final : private angle::NonCopyable
ANGLE_INLINE size_t ComputeVertexAttributeTypeSize(const VertexAttribute &attrib) ANGLE_INLINE size_t ComputeVertexAttributeTypeSize(const VertexAttribute &attrib)
{ {
switch (attrib.type) ASSERT(attrib.format);
{ return attrib.format->pixelBytes;
case VertexAttribType::Byte:
return attrib.size * sizeof(GLbyte);
case VertexAttribType::UnsignedByte:
return attrib.size * sizeof(GLubyte);
case VertexAttribType::Short:
return attrib.size * sizeof(GLshort);
case VertexAttribType::UnsignedShort:
return attrib.size * sizeof(GLushort);
case VertexAttribType::Int:
return attrib.size * sizeof(GLint);
case VertexAttribType::UnsignedInt:
return attrib.size * sizeof(GLuint);
case VertexAttribType::Float:
return attrib.size * sizeof(GLfloat);
case VertexAttribType::HalfFloat:
return attrib.size * sizeof(GLhalf);
case VertexAttribType::Fixed:
return attrib.size * sizeof(GLfixed);
case VertexAttribType::Int2101010:
// Packed attribute types don't scale by their component size.
return 4;
case VertexAttribType::UnsignedInt2101010:
// Packed attribute types don't scale by their component size.
return 4;
default:
UNREACHABLE();
return 0;
}
} }
// Warning: you should ensure binding really matches attrib.bindingIndex before using this function. // Warning: you should ensure binding really matches attrib.bindingIndex before using this function.
......
...@@ -1631,10 +1631,9 @@ angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribTyp ...@@ -1631,10 +1631,9 @@ angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribTyp
{ {
if (!attrib.enabled) if (!attrib.enabled)
{ {
return GetVertexFormatID(currentValueType, GL_FALSE, 4, return angle::FormatID::R32G32B32A32_FLOAT;
(currentValueType != VertexAttribType::Float));
} }
return GetVertexFormatID(attrib); return attrib.format->id;
} }
const VertexFormat &GetVertexFormatFromID(angle::FormatID vertexFormatID) const VertexFormat &GetVertexFormatFromID(angle::FormatID vertexFormatID)
......
...@@ -252,11 +252,6 @@ angle::FormatID GetVertexFormatID(VertexAttribType type, ...@@ -252,11 +252,6 @@ angle::FormatID GetVertexFormatID(VertexAttribType type,
GLuint components, GLuint components,
bool pureInteger); bool pureInteger);
ANGLE_INLINE angle::FormatID GetVertexFormatID(const VertexAttribute &attrib)
{
return GetVertexFormatID(attrib.type, attrib.normalized, attrib.size, attrib.pureInteger);
}
angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribType currentValueType); angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribType currentValueType);
const VertexFormat &GetVertexFormatFromID(angle::FormatID vertexFormatID); const VertexFormat &GetVertexFormatFromID(angle::FormatID vertexFormatID);
size_t GetVertexFormatSize(angle::FormatID vertexFormatID); size_t GetVertexFormatSize(angle::FormatID vertexFormatID);
......
...@@ -520,16 +520,18 @@ void QueryVertexAttribBase(const VertexAttribute &attrib, ...@@ -520,16 +520,18 @@ void QueryVertexAttribBase(const VertexAttribute &attrib,
*params = CastFromStateValue<ParamType>(pname, static_cast<GLint>(attrib.enabled)); *params = CastFromStateValue<ParamType>(pname, static_cast<GLint>(attrib.enabled));
break; break;
case GL_VERTEX_ATTRIB_ARRAY_SIZE: case GL_VERTEX_ATTRIB_ARRAY_SIZE:
*params = CastFromGLintStateValue<ParamType>(pname, attrib.size); *params = CastFromGLintStateValue<ParamType>(pname, attrib.format->channelCount);
break; break;
case GL_VERTEX_ATTRIB_ARRAY_STRIDE: case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
*params = CastFromGLintStateValue<ParamType>(pname, attrib.vertexAttribArrayStride); *params = CastFromGLintStateValue<ParamType>(pname, attrib.vertexAttribArrayStride);
break; break;
case GL_VERTEX_ATTRIB_ARRAY_TYPE: case GL_VERTEX_ATTRIB_ARRAY_TYPE:
*params = CastFromGLintStateValue<ParamType>(pname, ToGLenum(attrib.type)); *params = CastFromGLintStateValue<ParamType>(
pname, gl::ToGLenum(attrib.format->vertexAttribType));
break; break;
case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
*params = CastFromStateValue<ParamType>(pname, static_cast<GLint>(attrib.normalized)); *params =
CastFromStateValue<ParamType>(pname, static_cast<GLint>(attrib.format->isNorm()));
break; break;
case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
*params = CastFromGLintStateValue<ParamType>(pname, binding.getBuffer().id()); *params = CastFromGLintStateValue<ParamType>(pname, binding.getBuffer().id());
...@@ -538,7 +540,7 @@ void QueryVertexAttribBase(const VertexAttribute &attrib, ...@@ -538,7 +540,7 @@ void QueryVertexAttribBase(const VertexAttribute &attrib,
*params = CastFromStateValue<ParamType>(pname, binding.getDivisor()); *params = CastFromStateValue<ParamType>(pname, binding.getDivisor());
break; break;
case GL_VERTEX_ATTRIB_ARRAY_INTEGER: case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
*params = CastFromGLintStateValue<ParamType>(pname, attrib.pureInteger); *params = CastFromGLintStateValue<ParamType>(pname, attrib.format->isPureInt());
break; break;
case GL_VERTEX_ATTRIB_BINDING: case GL_VERTEX_ATTRIB_BINDING:
*params = CastFromGLintStateValue<ParamType>(pname, attrib.bindingIndex); *params = CastFromGLintStateValue<ParamType>(pname, attrib.bindingIndex);
......
...@@ -41,7 +41,9 @@ struct Format final : private angle::NonCopyable ...@@ -41,7 +41,9 @@ struct Format final : private angle::NonCopyable
GLuint pixelBytes, GLuint pixelBytes,
GLuint componentAlignmentMask, GLuint componentAlignmentMask,
bool isBlock, bool isBlock,
bool isFixed); bool isFixed,
bool isScaled,
gl::VertexAttribType vertexAttribType);
static const Format &Get(FormatID id) { return gFormatInfoTable[static_cast<int>(id)]; } static const Format &Get(FormatID id) { return gFormatInfoTable[static_cast<int>(id)]; }
...@@ -49,14 +51,17 @@ struct Format final : private angle::NonCopyable ...@@ -49,14 +51,17 @@ struct Format final : private angle::NonCopyable
constexpr bool hasDepthOrStencilBits() const; constexpr bool hasDepthOrStencilBits() const;
constexpr bool isLUMA() const; constexpr bool isLUMA() const;
constexpr GLuint channelCount() const;
constexpr bool isInt() const; constexpr bool isSint() const;
constexpr bool isUint() const; constexpr bool isUint() const;
constexpr bool isSnorm() const; constexpr bool isSnorm() const;
constexpr bool isUnorm() const; constexpr bool isUnorm() const;
constexpr bool isFloat() const; constexpr bool isFloat() const;
constexpr bool isInt() const { return isSint() || isUint(); }
constexpr bool isNorm() const { return isSnorm() || isUnorm(); }
constexpr bool isPureInt() const { return isInt() && !isScaled; }
bool operator==(const Format &other) const { return this->id == other.id; } bool operator==(const Format &other) const { return this->id == other.id; }
FormatID id; FormatID id;
...@@ -93,10 +98,29 @@ struct Format final : private angle::NonCopyable ...@@ -93,10 +98,29 @@ struct Format final : private angle::NonCopyable
// 0x0. // 0x0.
GLuint componentAlignmentMask; GLuint componentAlignmentMask;
GLuint channelCount;
bool isBlock; bool isBlock;
bool isFixed; bool isFixed;
bool isScaled;
// For vertex formats only. Returns the "type" value for glVertexAttribPointer etc.
gl::VertexAttribType vertexAttribType;
}; };
constexpr GLuint GetChannelCount(GLuint redBits,
GLuint greenBits,
GLuint blueBits,
GLuint alphaBits,
GLuint luminanceBits,
GLuint depthBits,
GLuint stencilBits)
{
return (redBits > 0 ? 1 : 0) + (greenBits > 0 ? 1 : 0) + (blueBits > 0 ? 1 : 0) +
(alphaBits > 0 ? 1 : 0) + (luminanceBits > 0 ? 1 : 0) + (depthBits > 0 ? 1 : 0) +
(stencilBits > 0 ? 1 : 0);
}
constexpr Format::Format(FormatID id, constexpr Format::Format(FormatID id,
GLenum glFormat, GLenum glFormat,
GLenum fboFormat, GLenum fboFormat,
...@@ -115,7 +139,9 @@ constexpr Format::Format(FormatID id, ...@@ -115,7 +139,9 @@ constexpr Format::Format(FormatID id,
GLuint pixelBytes, GLuint pixelBytes,
GLuint componentAlignmentMask, GLuint componentAlignmentMask,
bool isBlock, bool isBlock,
bool isFixed) bool isFixed,
bool isScaled,
gl::VertexAttribType vertexAttribType)
: id(id), : id(id),
glInternalFormat(glFormat), glInternalFormat(glFormat),
fboImplementationInternalFormat(fboFormat), fboImplementationInternalFormat(fboFormat),
...@@ -133,8 +159,17 @@ constexpr Format::Format(FormatID id, ...@@ -133,8 +159,17 @@ constexpr Format::Format(FormatID id,
stencilBits(stencilBits), stencilBits(stencilBits),
pixelBytes(pixelBytes), pixelBytes(pixelBytes),
componentAlignmentMask(componentAlignmentMask), componentAlignmentMask(componentAlignmentMask),
channelCount(GetChannelCount(redBits,
greenBits,
blueBits,
alphaBits,
luminanceBits,
depthBits,
stencilBits)),
isBlock(isBlock), isBlock(isBlock),
isFixed(isFixed) isFixed(isFixed),
isScaled(isScaled),
vertexAttribType(vertexAttribType)
{} {}
constexpr bool Format::hasDepthOrStencilBits() const constexpr bool Format::hasDepthOrStencilBits() const
...@@ -149,13 +184,7 @@ constexpr bool Format::isLUMA() const ...@@ -149,13 +184,7 @@ constexpr bool Format::isLUMA() const
return redBits == 0 && (luminanceBits > 0 || alphaBits > 0); return redBits == 0 && (luminanceBits > 0 || alphaBits > 0);
} }
constexpr GLuint Format::channelCount() const constexpr bool Format::isSint() const
{
return (redBits > 0) + (greenBits > 0) + (blueBits > 0) + (alphaBits > 0) +
(luminanceBits > 0) + (depthBits > 0) + (stencilBits > 0);
}
constexpr bool Format::isInt() const
{ {
return componentType == GL_INT; return componentType == GL_INT;
} }
......
...@@ -222,12 +222,7 @@ angle::Result StreamingVertexBufferInterface::reserveVertexSpace(const gl::Conte ...@@ -222,12 +222,7 @@ angle::Result StreamingVertexBufferInterface::reserveVertexSpace(const gl::Conte
// StaticVertexBufferInterface Implementation // StaticVertexBufferInterface Implementation
StaticVertexBufferInterface::AttributeSignature::AttributeSignature() StaticVertexBufferInterface::AttributeSignature::AttributeSignature()
: type(gl::VertexAttribType::InvalidEnum), : formatID(angle::FormatID::NONE), stride(0), offset(0)
size(0),
stride(0),
normalized(false),
pureInteger(false),
offset(0)
{} {}
bool StaticVertexBufferInterface::AttributeSignature::matchesAttribute( bool StaticVertexBufferInterface::AttributeSignature::matchesAttribute(
...@@ -236,8 +231,7 @@ bool StaticVertexBufferInterface::AttributeSignature::matchesAttribute( ...@@ -236,8 +231,7 @@ bool StaticVertexBufferInterface::AttributeSignature::matchesAttribute(
{ {
size_t attribStride = ComputeVertexAttributeStride(attrib, binding); size_t attribStride = ComputeVertexAttributeStride(attrib, binding);
if (type != attrib.type || size != attrib.size || static_cast<GLuint>(stride) != attribStride || if (formatID != attrib.format->id || static_cast<GLuint>(stride) != attribStride)
normalized != attrib.normalized || pureInteger != attrib.pureInteger)
{ {
return false; return false;
} }
...@@ -250,10 +244,7 @@ bool StaticVertexBufferInterface::AttributeSignature::matchesAttribute( ...@@ -250,10 +244,7 @@ bool StaticVertexBufferInterface::AttributeSignature::matchesAttribute(
void StaticVertexBufferInterface::AttributeSignature::set(const gl::VertexAttribute &attrib, void StaticVertexBufferInterface::AttributeSignature::set(const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding) const gl::VertexBinding &binding)
{ {
type = attrib.type; formatID = attrib.format->id;
size = attrib.size;
normalized = attrib.normalized;
pureInteger = attrib.pureInteger;
offset = stride = static_cast<GLuint>(ComputeVertexAttributeStride(attrib, binding)); offset = stride = static_cast<GLuint>(ComputeVertexAttributeStride(attrib, binding));
offset = static_cast<size_t>(ComputeVertexAttributeOffset(attrib, binding)) % offset = static_cast<size_t>(ComputeVertexAttributeOffset(attrib, binding)) %
ComputeVertexAttributeStride(attrib, binding); ComputeVertexAttributeStride(attrib, binding);
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "common/PackedEnums.h" #include "common/PackedEnums.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/renderer/Format.h"
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
...@@ -172,11 +173,8 @@ class StaticVertexBufferInterface : public VertexBufferInterface ...@@ -172,11 +173,8 @@ class StaticVertexBufferInterface : public VertexBufferInterface
void set(const gl::VertexAttribute &attrib, const gl::VertexBinding &binding); void set(const gl::VertexAttribute &attrib, const gl::VertexBinding &binding);
private: private:
gl::VertexAttribType type; angle::FormatID formatID;
GLuint size;
GLuint stride; GLuint stride;
bool normalized;
bool pureInteger;
size_t offset; size_t offset;
}; };
......
...@@ -102,7 +102,7 @@ bool DirectStoragePossible(const gl::Context *context, ...@@ -102,7 +102,7 @@ bool DirectStoragePossible(const gl::Context *context,
// TODO(jmadill): add VertexFormatCaps // TODO(jmadill): add VertexFormatCaps
BufferFactoryD3D *factory = bufferD3D->getFactory(); BufferFactoryD3D *factory = bufferD3D->getFactory();
angle::FormatID vertexFormatID = gl::GetVertexFormatID(attrib); angle::FormatID vertexFormatID = attrib.format->id;
// CPU-converted vertex data must be converted (naturally). // CPU-converted vertex data must be converted (naturally).
if ((factory->getVertexConversionType(vertexFormatID) & VERTEX_CONVERT_CPU) != 0) if ((factory->getVertexConversionType(vertexFormatID) & VERTEX_CONVERT_CPU) != 0)
...@@ -110,7 +110,7 @@ bool DirectStoragePossible(const gl::Context *context, ...@@ -110,7 +110,7 @@ bool DirectStoragePossible(const gl::Context *context,
return false; return false;
} }
if (attrib.type != gl::VertexAttribType::Float) if (attrib.format->vertexAttribType != gl::VertexAttribType::Float)
{ {
unsigned int elementSize = 0; unsigned int elementSize = 0;
angle::Result error = angle::Result error =
...@@ -207,7 +207,7 @@ VertexDataManager::CurrentValueState::CurrentValueState(BufferFactoryD3D *factor ...@@ -207,7 +207,7 @@ VertexDataManager::CurrentValueState::CurrentValueState(BufferFactoryD3D *factor
data.Values.FloatValues[1] = std::numeric_limits<float>::quiet_NaN(); data.Values.FloatValues[1] = std::numeric_limits<float>::quiet_NaN();
data.Values.FloatValues[2] = std::numeric_limits<float>::quiet_NaN(); data.Values.FloatValues[2] = std::numeric_limits<float>::quiet_NaN();
data.Values.FloatValues[3] = std::numeric_limits<float>::quiet_NaN(); data.Values.FloatValues[3] = std::numeric_limits<float>::quiet_NaN();
data.Type = gl::VertexAttribType::Float; data.Type = gl::VertexAttribType::Float;
} }
VertexDataManager::CurrentValueState::CurrentValueState(CurrentValueState &&other) VertexDataManager::CurrentValueState::CurrentValueState(CurrentValueState &&other)
......
...@@ -3648,10 +3648,9 @@ angle::Result Renderer11::getVertexSpaceRequired(const gl::Context *context, ...@@ -3648,10 +3648,9 @@ angle::Result Renderer11::getVertexSpaceRequired(const gl::Context *context,
ASSERT(elementCount > 0); ASSERT(elementCount > 0);
angle::FormatID formatID = gl::GetVertexFormatID(attrib);
const D3D_FEATURE_LEVEL featureLevel = mRenderer11DeviceCaps.featureLevel; const D3D_FEATURE_LEVEL featureLevel = mRenderer11DeviceCaps.featureLevel;
const d3d11::VertexFormat &vertexFormatInfo = const d3d11::VertexFormat &vertexFormatInfo =
d3d11::GetVertexFormatInfo(formatID, featureLevel); d3d11::GetVertexFormatInfo(attrib.format->id, featureLevel);
const d3d11::DXGIFormatSize &dxgiFormatInfo = const d3d11::DXGIFormatSize &dxgiFormatInfo =
d3d11::GetDXGIFormatSizeInfo(vertexFormatInfo.nativeFormat); d3d11::GetDXGIFormatSizeInfo(vertexFormatInfo.nativeFormat);
unsigned int elementSize = dxgiFormatInfo.pixelBytes; unsigned int elementSize = dxgiFormatInfo.pixelBytes;
......
...@@ -71,7 +71,7 @@ static constexpr rx::FastCopyFunctionMap NoCopyFunctions; ...@@ -71,7 +71,7 @@ static constexpr rx::FastCopyFunctionMap NoCopyFunctions;
const Format gFormatInfoTable[] = {{ const Format gFormatInfoTable[] = {{
// clang-format off // clang-format off
{{ FormatID::NONE, GL_NONE, GL_NONE, nullptr, NoCopyFunctions, nullptr, nullptr, GL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, false }}, {{ FormatID::NONE, GL_NONE, GL_NONE, nullptr, NoCopyFunctions, nullptr, nullptr, GL_NONE, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, false, false, gl::VertexAttribType::InvalidEnum }},
{angle_format_info_cases} // clang-format on {angle_format_info_cases} // clang-format on
}}; }};
...@@ -183,7 +183,7 @@ def get_color_write_function(angle_format): ...@@ -183,7 +183,7 @@ def get_color_write_function(angle_format):
return 'WriteColor<' + channel_struct + ', ' + write_component_type + '>' return 'WriteColor<' + channel_struct + ', ' + write_component_type + '>'
format_entry_template = """ {{ FormatID::{id}, {glInternalFormat}, {fboImplementationInternalFormat}, {mipGenerationFunction}, {fastCopyFunctions}, {colorReadFunction}, {colorWriteFunction}, {namedComponentType}, {R}, {G}, {B}, {A}, {L}, {D}, {S}, {pixelBytes}, {componentAlignmentMask}, {isBlock}, {isFixed} }}, format_entry_template = """ {{ FormatID::{id}, {glInternalFormat}, {fboImplementationInternalFormat}, {mipGenerationFunction}, {fastCopyFunctions}, {colorReadFunction}, {colorWriteFunction}, {namedComponentType}, {R}, {G}, {B}, {A}, {L}, {D}, {S}, {pixelBytes}, {componentAlignmentMask}, {isBlock}, {isFixed}, {isScaled}, {vertexAttribType} }},
""" """
...@@ -227,6 +227,39 @@ def get_component_alignment_mask(channels, bits): ...@@ -227,6 +227,39 @@ def get_component_alignment_mask(channels, bits):
return "std::numeric_limits<GLuint>::max()" return "std::numeric_limits<GLuint>::max()"
def get_vertex_attrib_type(format_id):
has_u = "_U" in format_id
has_s = "_S" in format_id
has_float = "_FLOAT" in format_id
has_fixed = "_FIXED" in format_id
has_r8 = "R8" in format_id
has_r16 = "R16" in format_id
has_r32 = "R32" in format_id
has_r10 = "R10" in format_id
if has_fixed:
return "Fixed"
if has_float:
return "HalfFloat" if has_r16 else "Float"
if has_r8:
return "Byte" if has_s else "UnsignedByte"
if has_r10:
return "Int2101010" if has_s else "UnsignedInt2101010"
if has_r16:
return "Short" if has_s else "UnsignedShort"
if has_r32:
return "Int" if has_s else "UnsignedInt"
# Many ANGLE formats don't correspond with vertex formats.
return "InvalidEnum"
def json_to_table_data(format_id, json, angle_to_gl): def json_to_table_data(format_id, json, angle_to_gl):
table_data = "" table_data = ""
...@@ -288,6 +321,9 @@ def json_to_table_data(format_id, json, angle_to_gl): ...@@ -288,6 +321,9 @@ def json_to_table_data(format_id, json, angle_to_gl):
parsed["bits"]) parsed["bits"])
parsed["isBlock"] = "true" if is_block else "false" parsed["isBlock"] = "true" if is_block else "false"
parsed["isFixed"] = "true" if "FIXED" in format_id else "false" parsed["isFixed"] = "true" if "FIXED" in format_id else "false"
parsed["isScaled"] = "true" if "SCALED" in format_id else "false"
parsed["vertexAttribType"] = "gl::VertexAttribType::" + get_vertex_attrib_type(format_id)
return format_entry_template.format(**parsed) return format_entry_template.format(**parsed)
......
...@@ -30,8 +30,7 @@ namespace ...@@ -30,8 +30,7 @@ namespace
{ {
bool SameVertexAttribFormat(const VertexAttribute &a, const VertexAttribute &b) bool SameVertexAttribFormat(const VertexAttribute &a, const VertexAttribute &b)
{ {
return a.size == b.size && a.type == b.type && a.normalized == b.normalized && return a.format == b.format && a.relativeOffset == b.relativeOffset;
a.pureInteger == b.pureInteger && a.relativeOffset == b.relativeOffset;
} }
bool SameVertexBuffer(const VertexBinding &a, const VertexBinding &b) bool SameVertexBuffer(const VertexBinding &a, const VertexBinding &b)
...@@ -460,10 +459,7 @@ void VertexArrayGL::updateAttribPointer(const gl::Context *context, size_t attri ...@@ -460,10 +459,7 @@ void VertexArrayGL::updateAttribPointer(const gl::Context *context, size_t attri
callVertexAttribPointer(static_cast<GLuint>(attribIndex), attrib, binding.getStride(), callVertexAttribPointer(static_cast<GLuint>(attribIndex), attrib, binding.getStride(),
binding.getOffset()); binding.getOffset());
mAppliedAttributes[attribIndex].size = attrib.size; mAppliedAttributes[attribIndex].format = attrib.format;
mAppliedAttributes[attribIndex].type = attrib.type;
mAppliedAttributes[attribIndex].normalized = attrib.normalized;
mAppliedAttributes[attribIndex].pureInteger = attrib.pureInteger;
// After VertexAttribPointer, attrib.relativeOffset is set to 0 and attrib.bindingIndex is set // After VertexAttribPointer, attrib.relativeOffset is set to 0 and attrib.bindingIndex is set
// to attribIndex in driver. If attrib.relativeOffset != 0 or attrib.bindingIndex != // to attribIndex in driver. If attrib.relativeOffset != 0 or attrib.bindingIndex !=
...@@ -482,17 +478,19 @@ void VertexArrayGL::callVertexAttribPointer(GLuint attribIndex, ...@@ -482,17 +478,19 @@ void VertexArrayGL::callVertexAttribPointer(GLuint attribIndex,
GLsizei stride, GLsizei stride,
GLintptr offset) const GLintptr offset) const
{ {
const GLvoid *pointer = reinterpret_cast<const GLvoid *>(offset); const GLvoid *pointer = reinterpret_cast<const GLvoid *>(offset);
if (attrib.pureInteger) const angle::Format &format = *attrib.format;
if (format.isPureInt())
{ {
ASSERT(!attrib.normalized); ASSERT(!format.isNorm());
mFunctions->vertexAttribIPointer(attribIndex, attrib.size, gl::ToGLenum(attrib.type), mFunctions->vertexAttribIPointer(attribIndex, format.channelCount,
stride, pointer); gl::ToGLenum(format.vertexAttribType), stride, pointer);
} }
else else
{ {
mFunctions->vertexAttribPointer(attribIndex, attrib.size, gl::ToGLenum(attrib.type), mFunctions->vertexAttribPointer(attribIndex, format.channelCount,
attrib.normalized, stride, pointer); gl::ToGLenum(format.vertexAttribType), format.isNorm(),
stride, pointer);
} }
} }
...@@ -512,23 +510,22 @@ void VertexArrayGL::updateAttribFormat(size_t attribIndex) ...@@ -512,23 +510,22 @@ void VertexArrayGL::updateAttribFormat(size_t attribIndex)
return; return;
} }
if (attrib.pureInteger) const angle::Format &format = *attrib.format;
if (format.isPureInt())
{ {
ASSERT(!attrib.normalized); ASSERT(!format.isNorm());
mFunctions->vertexAttribIFormat(static_cast<GLuint>(attribIndex), attrib.size, mFunctions->vertexAttribIFormat(static_cast<GLuint>(attribIndex), format.channelCount,
gl::ToGLenum(attrib.type), attrib.relativeOffset); gl::ToGLenum(format.vertexAttribType),
attrib.relativeOffset);
} }
else else
{ {
mFunctions->vertexAttribFormat(static_cast<GLuint>(attribIndex), attrib.size, mFunctions->vertexAttribFormat(static_cast<GLuint>(attribIndex), format.channelCount,
gl::ToGLenum(attrib.type), attrib.normalized, gl::ToGLenum(format.vertexAttribType), format.isNorm(),
attrib.relativeOffset); attrib.relativeOffset);
} }
mAppliedAttributes[attribIndex].size = attrib.size; mAppliedAttributes[attribIndex].format = attrib.format;
mAppliedAttributes[attribIndex].type = attrib.type;
mAppliedAttributes[attribIndex].normalized = attrib.normalized;
mAppliedAttributes[attribIndex].pureInteger = attrib.pureInteger;
mAppliedAttributes[attribIndex].relativeOffset = attrib.relativeOffset; mAppliedAttributes[attribIndex].relativeOffset = attrib.relativeOffset;
} }
......
...@@ -46,34 +46,43 @@ uint32_t GetBufferUtilsFlags(size_t dispatchSize, const vk::Format &format) ...@@ -46,34 +46,43 @@ uint32_t GetBufferUtilsFlags(size_t dispatchSize, const vk::Format &format)
uint32_t flags = dispatchSize % 64 == 0 ? BufferUtils_comp::kIsAligned : 0; uint32_t flags = dispatchSize % 64 == 0 ? BufferUtils_comp::kIsAligned : 0;
const angle::Format &bufferFormat = format.bufferFormat(); const angle::Format &bufferFormat = format.bufferFormat();
flags |= bufferFormat.isInt() if (bufferFormat.isSint())
? BufferUtils_comp::kIsInt {
: bufferFormat.isUint() ? BufferUtils_comp::kIsUint : BufferUtils_comp::kIsFloat; flags |= BufferUtils_comp::kIsSint;
}
else if (bufferFormat.isUint())
{
flags |= BufferUtils_comp::kIsUint;
}
else
{
flags |= BufferUtils_comp::kIsFloat;
}
return flags; return flags;
} }
uint32_t GetConvertVertexFlags(const UtilsVk::ConvertVertexParameters &params) uint32_t GetConvertVertexFlags(const UtilsVk::ConvertVertexParameters &params)
{ {
bool srcIsInt = params.srcFormat->isInt(); bool srcIsSint = params.srcFormat->isSint();
bool srcIsUint = params.srcFormat->isUint(); bool srcIsUint = params.srcFormat->isUint();
bool srcIsSnorm = params.srcFormat->isSnorm(); bool srcIsSnorm = params.srcFormat->isSnorm();
bool srcIsUnorm = params.srcFormat->isUnorm(); bool srcIsUnorm = params.srcFormat->isUnorm();
bool srcIsFixed = params.srcFormat->isFixed; bool srcIsFixed = params.srcFormat->isFixed;
bool srcIsFloat = params.srcFormat->isFloat(); bool srcIsFloat = params.srcFormat->isFloat();
bool destIsInt = params.destFormat->isInt(); bool destIsSint = params.destFormat->isSint();
bool destIsUint = params.destFormat->isUint(); bool destIsUint = params.destFormat->isUint();
bool destIsFloat = params.destFormat->isFloat(); bool destIsFloat = params.destFormat->isFloat();
// Assert on the types to make sure the shader supports its. These are based on // Assert on the types to make sure the shader supports its. These are based on
// ConvertVertex_comp::Conversion values. // ConvertVertex_comp::Conversion values.
ASSERT(!destIsInt || srcIsInt); // If destination is int, src must be int too ASSERT(!destIsSint || srcIsSint); // If destination is sint, src must be sint too
ASSERT(!destIsUint || srcIsUint); // If destination is uint, src must be uint too ASSERT(!destIsUint || srcIsUint); // If destination is uint, src must be uint too
ASSERT(!srcIsFixed || destIsFloat); // If source is fixed, dest must be float ASSERT(!srcIsFixed || destIsFloat); // If source is fixed, dest must be float
// One of each bool set must be true // One of each bool set must be true
ASSERT(srcIsInt || srcIsUint || srcIsSnorm || srcIsUnorm || srcIsFixed || srcIsFloat); ASSERT(srcIsSint || srcIsUint || srcIsSnorm || srcIsUnorm || srcIsFixed || srcIsFloat);
ASSERT(destIsInt || destIsUint || destIsFloat); ASSERT(destIsSint || destIsUint || destIsFloat);
// We currently don't have any big-endian devices in the list of supported platforms. The // We currently don't have any big-endian devices in the list of supported platforms. The
// shader is capable of supporting big-endian architectures, but the relevant flag (IsBigEndian) // shader is capable of supporting big-endian architectures, but the relevant flag (IsBigEndian)
...@@ -86,17 +95,17 @@ uint32_t GetConvertVertexFlags(const UtilsVk::ConvertVertexParameters &params) ...@@ -86,17 +95,17 @@ uint32_t GetConvertVertexFlags(const UtilsVk::ConvertVertexParameters &params)
uint32_t flags = 0; uint32_t flags = 0;
if (srcIsInt && destIsInt) if (srcIsSint && destIsSint)
{ {
flags |= ConvertVertex_comp::kIntToInt; flags |= ConvertVertex_comp::kSintToSint;
} }
else if (srcIsUint && destIsUint) else if (srcIsUint && destIsUint)
{ {
flags |= ConvertVertex_comp::kUintToUint; flags |= ConvertVertex_comp::kUintToUint;
} }
else if (srcIsInt) else if (srcIsSint)
{ {
flags |= ConvertVertex_comp::kIntToFloat; flags |= ConvertVertex_comp::kSintToFloat;
} }
else if (srcIsUint) else if (srcIsUint)
{ {
...@@ -139,9 +148,18 @@ uint32_t GetImageClearFlags(const angle::Format &format, uint32_t attachmentInde ...@@ -139,9 +148,18 @@ uint32_t GetImageClearFlags(const angle::Format &format, uint32_t attachmentInde
uint32_t flags = ImageClear_frag::kAttachment0 + attachmentIndex * kAttachmentFlagStep; uint32_t flags = ImageClear_frag::kAttachment0 + attachmentIndex * kAttachmentFlagStep;
flags |= format.isInt() if (format.isSint())
? ImageClear_frag::kIsInt {
: format.isUint() ? ImageClear_frag::kIsUint : ImageClear_frag::kIsFloat; flags |= ImageClear_frag::kIsSint;
}
else if (format.isUint())
{
flags |= ImageClear_frag::kIsUint;
}
else
{
flags |= ImageClear_frag::kIsFloat;
}
return flags; return flags;
} }
...@@ -151,7 +169,7 @@ uint32_t GetFormatFlags(const angle::Format &format, ...@@ -151,7 +169,7 @@ uint32_t GetFormatFlags(const angle::Format &format,
uint32_t uintFlag, uint32_t uintFlag,
uint32_t floatFlag) uint32_t floatFlag)
{ {
if (format.isInt()) if (format.isSint())
{ {
return intFlag; return intFlag;
} }
...@@ -169,9 +187,9 @@ uint32_t GetImageCopyFlags(const vk::Format &srcFormat, const vk::Format &destFo ...@@ -169,9 +187,9 @@ uint32_t GetImageCopyFlags(const vk::Format &srcFormat, const vk::Format &destFo
uint32_t flags = 0; uint32_t flags = 0;
flags |= GetFormatFlags(srcAngleFormat, ImageCopy_frag::kSrcIsInt, ImageCopy_frag::kSrcIsUint, flags |= GetFormatFlags(srcAngleFormat, ImageCopy_frag::kSrcIsSint, ImageCopy_frag::kSrcIsUint,
ImageCopy_frag::kSrcIsFloat); ImageCopy_frag::kSrcIsFloat);
flags |= GetFormatFlags(destAngleFormat, ImageCopy_frag::kDestIsInt, flags |= GetFormatFlags(destAngleFormat, ImageCopy_frag::kDestIsSint,
ImageCopy_frag::kDestIsUint, ImageCopy_frag::kDestIsFloat); ImageCopy_frag::kDestIsUint, ImageCopy_frag::kDestIsFloat);
return flags; return flags;
...@@ -688,11 +706,11 @@ angle::Result UtilsVk::convertVertexBuffer(ContextVk *contextVk, ...@@ -688,11 +706,11 @@ angle::Result UtilsVk::convertVertexBuffer(ContextVk *contextVk,
dest->onWrite(contextVk, VK_ACCESS_SHADER_WRITE_BIT); dest->onWrite(contextVk, VK_ACCESS_SHADER_WRITE_BIT);
ConvertVertexShaderParams shaderParams; ConvertVertexShaderParams shaderParams;
shaderParams.Ns = params.srcFormat->channelCount(); shaderParams.Ns = params.srcFormat->channelCount;
shaderParams.Bs = params.srcFormat->pixelBytes / params.srcFormat->channelCount(); shaderParams.Bs = params.srcFormat->pixelBytes / params.srcFormat->channelCount;
shaderParams.Ss = params.srcStride; shaderParams.Ss = params.srcStride;
shaderParams.Nd = params.destFormat->channelCount(); shaderParams.Nd = params.destFormat->channelCount;
shaderParams.Bd = params.destFormat->pixelBytes / params.destFormat->channelCount(); shaderParams.Bd = params.destFormat->pixelBytes / params.destFormat->channelCount;
shaderParams.Sd = shaderParams.Nd * shaderParams.Bd; shaderParams.Sd = shaderParams.Nd * shaderParams.Bd;
// The component size is expected to either be 1, 2 or 4 bytes. // The component size is expected to either be 1, 2 or 4 bytes.
ASSERT(4 % shaderParams.Bs == 0); ASSERT(4 % shaderParams.Bs == 0);
......
...@@ -238,7 +238,7 @@ angle::Result VertexArrayVk::convertVertexBufferGPU(ContextVk *contextVk, ...@@ -238,7 +238,7 @@ angle::Result VertexArrayVk::convertVertexBufferGPU(ContextVk *contextVk,
const angle::Format &srcFormat = vertexFormat.angleFormat(); const angle::Format &srcFormat = vertexFormat.angleFormat();
const angle::Format &destFormat = vertexFormat.bufferFormat(); const angle::Format &destFormat = vertexFormat.bufferFormat();
ASSERT(binding.getStride() % (srcFormat.pixelBytes / srcFormat.channelCount()) == 0); ASSERT(binding.getStride() % (srcFormat.pixelBytes / srcFormat.channelCount) == 0);
unsigned srcFormatSize = srcFormat.pixelBytes; unsigned srcFormatSize = srcFormat.pixelBytes;
unsigned destFormatSize = destFormat.pixelBytes; unsigned destFormatSize = destFormat.pixelBytes;
...@@ -438,14 +438,15 @@ angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk, ...@@ -438,14 +438,15 @@ angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk,
if (attrib.enabled) if (attrib.enabled)
{ {
gl::Buffer *bufferGL = binding.getBuffer().get(); gl::Buffer *bufferGL = binding.getBuffer().get();
const vk::Format &vertexFormat = renderer->getFormat(GetVertexFormatID(attrib)); const vk::Format &vertexFormat = renderer->getFormat(attrib.format->id);
GLuint stride; GLuint stride;
if (bufferGL) if (bufferGL)
{ {
BufferVk *bufferVk = vk::GetImpl(bufferGL); BufferVk *bufferVk = vk::GetImpl(bufferGL);
const angle::Format &angleFormat = vertexFormat.angleFormat(); const angle::Format &angleFormat = vertexFormat.angleFormat();
bool bindingIsAligned = BindingIsAligned(binding, angleFormat, attrib.size); bool bindingIsAligned =
BindingIsAligned(binding, angleFormat, angleFormat.channelCount);
if (vertexFormat.vertexLoadRequiresConversion || !bindingIsAligned) if (vertexFormat.vertexLoadRequiresConversion || !bindingIsAligned)
{ {
...@@ -556,7 +557,7 @@ angle::Result VertexArrayVk::updateClientAttribs(const gl::Context *context, ...@@ -556,7 +557,7 @@ angle::Result VertexArrayVk::updateClientAttribs(const gl::Context *context,
const gl::VertexBinding &binding = bindings[attrib.bindingIndex]; const gl::VertexBinding &binding = bindings[attrib.bindingIndex];
ASSERT(attrib.enabled && binding.getBuffer().get() == nullptr); ASSERT(attrib.enabled && binding.getBuffer().get() == nullptr);
const vk::Format &vertexFormat = renderer->getFormat(GetVertexFormatID(attrib)); const vk::Format &vertexFormat = renderer->getFormat(attrib.format->id);
GLuint stride = vertexFormat.bufferFormat().pixelBytes; GLuint stride = vertexFormat.bufferFormat().pixelBytes;
ASSERT(GetVertexInputAlignment(vertexFormat) <= vk::kVertexBufferAlignment); ASSERT(GetVertexInputAlignment(vertexFormat) <= vk::kVertexBufferAlignment);
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// need for bound checking // need for bound checking
// - Format: // - Format:
// * IsFloat // * IsFloat
// * IsInt // * IsSint
// * IsUint // * IsUint
// - Function: // - Function:
// * IsClear: the buffer will be cleared // * IsClear: the buffer will be cleared
...@@ -27,7 +27,7 @@ layout (local_size_x = 64, local_size_y = 1, local_size_z = 1) in; ...@@ -27,7 +27,7 @@ layout (local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
#define ADD_TYPE_PREFIX(type) type #define ADD_TYPE_PREFIX(type) type
#define BUFFER_FORMAT rgba32f #define BUFFER_FORMAT rgba32f
#define GVEC4 vec4 #define GVEC4 vec4
#elif IsInt #elif IsSint
#define ADD_TYPE_PREFIX(type) i ## type #define ADD_TYPE_PREFIX(type) i ## type
#define BUFFER_FORMAT rgba32i #define BUFFER_FORMAT rgba32i
#define GVEC4 ivec4 #define GVEC4 ivec4
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
], ],
"Format": [ "Format": [
"IsFloat", "IsFloat",
"IsInt", "IsSint",
"IsUint" "IsUint"
], ],
"Function": [ "Function": [
......
...@@ -37,18 +37,18 @@ ...@@ -37,18 +37,18 @@
// need for bound checking. // need for bound checking.
// * IsBigEndian // * IsBigEndian
// - Conversion: // - Conversion:
// * IntToInt: covers byte, short and int types (distinguished by Bs and Bd). // * SintToSint: covers byte, short and int types (distinguished by Bs and Bd).
// * UintToUint: covers ubyte, ushort and uint types (distinguished by Bs and Bd). // * UintToUint: covers ubyte, ushort and uint types (distinguished by Bs and Bd).
// * IntToFloat: Same types as IntToInt for source (including scaled). Converts to float. // * SintToFloat: Same types as SintToSint for source (including scaled). Converts to float.
// * UintToFloat: Same types as UintToUint for source (including uscaled). Converst to float. // * UintToFloat: Same types as UintToUint for source (including uscaled). Converst to float.
// * SnormToFloat: Similar to IntToFloat, but normalized. // * SnormToFloat: Similar to IntToFloat, but normalized.
// * UnormToFloat: Similar to UintToFloat, but normalized. // * UnormToFloat: Similar to UintToFloat, but normalized.
// * FixedToFloat: 16.16 signed fixed-point to floating point. // * FixedToFloat: 16.16 signed fixed-point to floating point.
// * FloatToFloat: float. // * FloatToFloat: float.
// //
// IntToInt, UintToUint and FloatToFloat correspond to CopyNativeVertexData() and // SintToSint, UintToUint and FloatToFloat correspond to CopyNativeVertexData() and
// Copy8SintTo16SintVertexData() in renderer/copyvertex.inc, FixedToFloat corresponds to // Copy8SintTo16SintVertexData() in renderer/copyvertex.inc, FixedToFloat corresponds to
// Copy32FixedTo32FVertexData, IntToFloat and UintToFloat correspond to CopyTo32FVertexData with // Copy32FixedTo32FVertexData, SintToFloat and UintToFloat correspond to CopyTo32FVertexData with
// normalized=false and SnormToFloat and UnormToFloat correspond to CopyTo32FVertexData with // normalized=false and SnormToFloat and UnormToFloat correspond to CopyTo32FVertexData with
// normalized=true. // normalized=true.
// //
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#version 450 core #version 450 core
// Source type // Source type
#if IntToInt || IntToFloat #if SintToSint || SintToFloat
#define SrcType int #define SrcType int
#elif UintToUint || UintToFloat #elif UintToUint || UintToFloat
#define SrcType uint #define SrcType uint
...@@ -67,13 +67,13 @@ ...@@ -67,13 +67,13 @@
#endif #endif
// Destination type // Destination type
#if IntToInt #if SintToSint
#define DestType int #define DestType int
#define IsDestFloat 0 #define IsDestFloat 0
#elif UintToUint #elif UintToUint
#define DestType uint #define DestType uint
#define IsDestFloat 0 #define IsDestFloat 0
#elif IntToFloat || UintToFloat || SnormToFloat || UnormToFloat || FixedToFloat || FloatToFloat #elif SintToFloat || UintToFloat || SnormToFloat || UnormToFloat || FixedToFloat || FloatToFloat
#define DestType float #define DestType float
#define IsDestFloat 1 #define IsDestFloat 1
#else #else
...@@ -206,7 +206,7 @@ SrcType loadSourceComponent(uint cd) ...@@ -206,7 +206,7 @@ SrcType loadSourceComponent(uint cd)
uint valueAsUint = (block >> shiftBits) & valueMask; uint valueAsUint = (block >> shiftBits) & valueMask;
// Convert to SrcType // Convert to SrcType
#if IntToInt || IntToFloat #if SintToSint || SintToFloat
bool isNegative = (valueAsUint & (1 << (valueBits - 1))) != 0; bool isNegative = (valueAsUint & (1 << (valueBits - 1))) != 0;
// Sign extend // Sign extend
SrcType value = SrcType(valueAsUint | (isNegative ? 0xFFFFFFFF << valueBits : 0)); SrcType value = SrcType(valueAsUint | (isNegative ? 0xFFFFFFFF << valueBits : 0));
...@@ -244,7 +244,7 @@ uint makeDestinationComponent(uint cd, DestType value) ...@@ -244,7 +244,7 @@ uint makeDestinationComponent(uint cd, DestType value)
// Return valueAsUint, shifted to the right spot. Multiple calls to this function should be |ed // Return valueAsUint, shifted to the right spot. Multiple calls to this function should be |ed
// and eventually written to the destination. // and eventually written to the destination.
#if IntToInt || UintToUint #if SintToSint || UintToUint
uint vertex = cd / Nd; uint vertex = cd / Nd;
uint component = cd % Nd; uint component = cd % Nd;
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
"IsAligned" "IsAligned"
], ],
"Conversion": [ "Conversion": [
"IntToInt", "SintToSint",
"UintToUint", "UintToUint",
"IntToFloat", "SintToFloat",
"UintToFloat", "UintToFloat",
"SnormToFloat", "SnormToFloat",
"UnormToFloat", "UnormToFloat",
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#if IsFloat #if IsFloat
#define Type vec4 #define Type vec4
#elif IsInt #elif IsSint
#define Type ivec4 #define Type ivec4
#elif IsUint #elif IsUint
#define Type uvec4 #define Type uvec4
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
], ],
"Format": [ "Format": [
"IsFloat", "IsFloat",
"IsInt", "IsSint",
"IsUint" "IsUint"
] ]
} }
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#if SrcIsFloat #if SrcIsFloat
#define SRC_RESOURCE(type) type #define SRC_RESOURCE(type) type
#define SrcType vec4 #define SrcType vec4
#elif SrcIsInt #elif SrcIsSint
#define SRC_RESOURCE(type) MAKE_SRC_RESOURCE(i, type) #define SRC_RESOURCE(type) MAKE_SRC_RESOURCE(i, type)
#define SrcType ivec4 #define SrcType ivec4
#elif SrcIsUint #elif SrcIsUint
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#if DestIsFloat #if DestIsFloat
#define DestType vec4 #define DestType vec4
#elif DestIsInt #elif DestIsSint
#define DestType ivec4 #define DestType ivec4
#elif DestIsUint #elif DestIsUint
#define DestType uvec4 #define DestType uvec4
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
], ],
"SrcFormat": [ "SrcFormat": [
"SrcIsFloat", "SrcIsFloat",
"SrcIsInt", "SrcIsSint",
"SrcIsUint" "SrcIsUint"
], ],
"DestFormat": [ "DestFormat": [
"DestIsFloat", "DestIsFloat",
"DestIsInt", "DestIsSint",
"DestIsUint" "DestIsUint"
] ]
} }
......
...@@ -108,7 +108,7 @@ void Format::initImageFallback(RendererVk *renderer, const ImageFormatInitInfo * ...@@ -108,7 +108,7 @@ void Format::initImageFallback(RendererVk *renderer, const ImageFormatInitInfo *
size_t skip = renderer->getFeatures().forceFallbackFormat.enabled ? 1 : 0; size_t skip = renderer->getFeatures().forceFallbackFormat.enabled ? 1 : 0;
SupportTest testFunction = HasFullTextureFormatSupport; SupportTest testFunction = HasFullTextureFormatSupport;
const angle::Format &format = angle::Format::Get(info[0].format); const angle::Format &format = angle::Format::Get(info[0].format);
if (format.isInt() || format.isUint() || (format.isFloat() && format.redBits >= 32)) if (format.isInt() || (format.isFloat() && format.redBits >= 32))
{ {
// Integer formats don't support filtering in GL, so don't test for it. // Integer formats don't support filtering in GL, so don't test for it.
// Filtering of 32-bit float textures is not supported on Android, and // Filtering of 32-bit float textures is not supported on Android, and
...@@ -303,7 +303,7 @@ size_t GetVertexInputAlignment(const vk::Format &format) ...@@ -303,7 +303,7 @@ size_t GetVertexInputAlignment(const vk::Format &format)
{ {
const angle::Format &bufferFormat = format.bufferFormat(); const angle::Format &bufferFormat = format.bufferFormat();
size_t pixelBytes = bufferFormat.pixelBytes; size_t pixelBytes = bufferFormat.pixelBytes;
return format.vkBufferFormatIsPacked ? pixelBytes : (pixelBytes / bufferFormat.channelCount()); return format.vkBufferFormatIsPacked ? pixelBytes : (pixelBytes / bufferFormat.channelCount);
} }
GLenum GetSwizzleStateComponent(const gl::SwizzleState &swizzleState, GLenum component) GLenum GetSwizzleStateComponent(const gl::SwizzleState &swizzleState, GLenum component)
......
...@@ -62,7 +62,7 @@ enum Function ...@@ -62,7 +62,7 @@ enum Function
enum Format enum Format
{ {
kIsFloat = 0x00000000, kIsFloat = 0x00000000,
kIsInt = 0x00000004, kIsSint = 0x00000004,
kIsUint = 0x00000008, kIsUint = 0x00000008,
}; };
constexpr size_t kArrayLen = 0x0000000C; constexpr size_t kArrayLen = 0x0000000C;
...@@ -85,9 +85,9 @@ enum flags ...@@ -85,9 +85,9 @@ enum flags
}; };
enum Conversion enum Conversion
{ {
kIntToInt = 0x00000000, kSintToSint = 0x00000000,
kUintToUint = 0x00000002, kUintToUint = 0x00000002,
kIntToFloat = 0x00000004, kSintToFloat = 0x00000004,
kUintToFloat = 0x00000006, kUintToFloat = 0x00000006,
kSnormToFloat = 0x00000008, kSnormToFloat = 0x00000008,
kUnormToFloat = 0x0000000A, kUnormToFloat = 0x0000000A,
...@@ -118,7 +118,7 @@ enum AttachmentIndex ...@@ -118,7 +118,7 @@ enum AttachmentIndex
enum Format enum Format
{ {
kIsFloat = 0x00000000, kIsFloat = 0x00000000,
kIsInt = 0x00000008, kIsSint = 0x00000008,
kIsUint = 0x00000010, kIsUint = 0x00000010,
}; };
constexpr size_t kArrayLen = 0x00000018; constexpr size_t kArrayLen = 0x00000018;
...@@ -133,13 +133,13 @@ enum flags ...@@ -133,13 +133,13 @@ enum flags
enum SrcFormat enum SrcFormat
{ {
kSrcIsFloat = 0x00000000, kSrcIsFloat = 0x00000000,
kSrcIsInt = 0x00000002, kSrcIsSint = 0x00000002,
kSrcIsUint = 0x00000004, kSrcIsUint = 0x00000004,
}; };
enum DestFormat enum DestFormat
{ {
kDestIsFloat = 0x00000000, kDestIsFloat = 0x00000000,
kDestIsInt = 0x00000008, kDestIsSint = 0x00000008,
kDestIsUint = 0x00000010, kDestIsUint = 0x00000010,
}; };
constexpr size_t kArrayLen = 0x00000016; constexpr size_t kArrayLen = 0x00000016;
......
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