Commit 1a965480 by Shannon Woods

Vertex management functions can take a State reference instead of pointers to attrib data.

BUG=angle:685 Change-Id: I0bfc26c53eb1358a023ac5d4ec20be06f9c90f4a Reviewed-on: https://chromium-review.googlesource.com/219352Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarShannon Woods <shannonwoods@chromium.org>
parent 2df6a601
......@@ -1396,10 +1396,8 @@ Error Context::applyState(GLenum drawMode)
// Applies the shaders and shader constants to the Direct3D 9 device
Error Context::applyShaders(ProgramBinary *programBinary, bool transformFeedbackActive)
{
const VertexAttribute *vertexAttributes = mState.getVertexArray()->getVertexAttributes();
VertexFormat inputLayout[MAX_VERTEX_ATTRIBS];
VertexFormat::GetInputLayout(inputLayout, programBinary, vertexAttributes, mState.getVertexAttribCurrentValues());
VertexFormat::GetInputLayout(inputLayout, programBinary, mState);
const Framebuffer *fbo = mState.getDrawFramebuffer();
......@@ -1769,7 +1767,7 @@ Error Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei insta
return error;
}
error = mRenderer->applyVertexBuffer(programBinary, mState.getVertexArray()->getVertexAttributes(), mState.getVertexAttribCurrentValues(), first, count, instances);
error = mRenderer->applyVertexBuffer(mState, first, count, instances);
if (error.isError())
{
return error;
......@@ -1854,9 +1852,7 @@ Error Context::drawElements(GLenum mode, GLsizei count, GLenum type,
}
GLsizei vertexCount = indexInfo.indexRange.length() + 1;
error = mRenderer->applyVertexBuffer(programBinary, vao->getVertexAttributes(),
mState.getVertexAttribCurrentValues(),
indexInfo.indexRange.start, vertexCount, instances);
error = mRenderer->applyVertexBuffer(mState, indexInfo.indexRange.start, vertexCount, instances);
if (error.isError())
{
return error;
......
......@@ -1069,11 +1069,6 @@ const VertexAttribCurrentValueData &State::getVertexAttribCurrentValue(unsigned
return mVertexAttribCurrentValues[attribNum];
}
const VertexAttribCurrentValueData *State::getVertexAttribCurrentValues() const
{
return mVertexAttribCurrentValues;
}
const void *State::getVertexAttribPointer(unsigned int attribNum) const
{
return getVertexArray()->getVertexAttribute(attribNum).pointer;
......
......@@ -218,7 +218,6 @@ class State
bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
const VertexAttribute &getVertexAttribState(unsigned int attribNum) const;
const VertexAttribCurrentValueData &getVertexAttribCurrentValue(unsigned int attribNum) const;
const VertexAttribCurrentValueData *getVertexAttribCurrentValues() const;
const void *getVertexAttribPointer(unsigned int attribNum) const;
// Pixel pack state manipulation
......
......@@ -9,6 +9,8 @@
#include "libGLESv2/angletypes.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/VertexAttribute.h"
#include "libGLESv2/State.h"
#include "libGLESv2/VertexArray.h"
namespace gl
{
......@@ -148,16 +150,16 @@ VertexFormat::VertexFormat(const VertexAttribute &attrib, GLenum currentValueTyp
void VertexFormat::GetInputLayout(VertexFormat *inputLayout,
ProgramBinary *programBinary,
const VertexAttribute *attributes,
const gl::VertexAttribCurrentValueData *currentValues)
const State &state)
{
const VertexAttribute *vertexAttributes = state.getVertexArray()->getVertexAttributes();
for (unsigned int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{
int semanticIndex = programBinary->getSemanticIndex(attributeIndex);
if (semanticIndex != -1)
{
inputLayout[semanticIndex] = VertexFormat(attributes[attributeIndex], currentValues[attributeIndex].Type);
inputLayout[semanticIndex] = VertexFormat(vertexAttributes[attributeIndex], state.getVertexAttribCurrentValue(attributeIndex).Type);
}
}
}
......
......@@ -15,6 +15,7 @@
namespace gl
{
class Buffer;
class State;
class ProgramBinary;
struct VertexAttribute;
struct VertexAttribCurrentValueData;
......@@ -229,8 +230,7 @@ struct VertexFormat
static void GetInputLayout(VertexFormat *inputLayout,
ProgramBinary *programBinary,
const VertexAttribute *attributes,
const gl::VertexAttribCurrentValueData *currentValues);
const State& currentValues);
bool operator==(const VertexFormat &other) const;
bool operator!=(const VertexFormat &other) const;
......
......@@ -132,8 +132,7 @@ class Renderer
bool rasterizerDiscard, bool transformFeedbackActive) = 0;
virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray) = 0;
virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount) = 0;
virtual gl::Error applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances) = 0;
virtual gl::Error applyVertexBuffer(const gl::State &state, GLint first, GLsizei count, GLsizei instances) = 0;
virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo) = 0;
virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]) = 0;
......
......@@ -14,6 +14,7 @@
#include "libGLESv2/Buffer.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/VertexAttribute.h"
#include "libGLESv2/State.h"
namespace
{
......@@ -82,8 +83,8 @@ VertexDataManager::~VertexDataManager()
}
}
gl::Error VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[], const gl::VertexAttribCurrentValueData currentValues[],
gl::ProgramBinary *programBinary, GLint start, GLsizei count, TranslatedAttribute *translated, GLsizei instances)
gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint start, GLsizei count,
TranslatedAttribute *translated, GLsizei instances)
{
if (!mStreamingBuffer)
{
......@@ -93,20 +94,22 @@ gl::Error VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs
// Invalidate static buffers that don't contain matching attributes
for (int attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
{
translated[attributeIndex].active = (programBinary->getSemanticIndex(attributeIndex) != -1);
translated[attributeIndex].active = (state.getCurrentProgramBinary()->getSemanticIndex(attributeIndex) != -1);
const gl::VertexAttribute &curAttrib = state.getVertexAttribState(attributeIndex);
if (translated[attributeIndex].active && attribs[attributeIndex].enabled)
if (translated[attributeIndex].active && curAttrib.enabled)
{
invalidateMatchingStaticData(attribs[attributeIndex], currentValues[attributeIndex]);
invalidateMatchingStaticData(curAttrib, state.getVertexAttribCurrentValue(attributeIndex));
}
}
// Reserve the required space in the buffers
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
if (translated[i].active && attribs[i].enabled)
const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
if (translated[i].active && curAttrib.enabled)
{
gl::Error error = reserveSpaceForAttrib(attribs[i], currentValues[i], count, instances);
gl::Error error = reserveSpaceForAttrib(curAttrib, state.getVertexAttribCurrentValue(i), count, instances);
if (error.isError())
{
return error;
......@@ -117,12 +120,14 @@ gl::Error VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs
// Perform the vertex data translations
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
if (translated[i].active)
{
if (attribs[i].enabled)
if (curAttrib.enabled)
{
gl::Error error = storeAttribute(attribs[i], currentValues[i], &translated[i],
start, count, instances);
gl::Error error = storeAttribute(curAttrib, state.getVertexAttribCurrentValue(i),
&translated[i], start, count, instances);
if (error.isError())
{
return error;
......@@ -135,7 +140,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs
mCurrentValueBuffer[i] = new StreamingVertexBufferInterface(mRenderer, CONSTANT_VERTEX_BUFFER_SIZE);
}
gl::Error error = storeCurrentValue(attribs[i], currentValues[i], &translated[i],
gl::Error error = storeCurrentValue(curAttrib, state.getVertexAttribCurrentValue(i), &translated[i],
&mCurrentValue[i], &mCurrentValueOffsets[i],
mCurrentValueBuffer[i]);
if (error.isError())
......@@ -148,14 +153,15 @@ gl::Error VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
if (translated[i].active && attribs[i].enabled)
const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
if (translated[i].active && curAttrib.enabled)
{
gl::Buffer *buffer = attribs[i].buffer.get();
gl::Buffer *buffer = curAttrib.buffer.get();
if (buffer)
{
BufferD3D *bufferImpl = BufferD3D::makeBufferD3D(buffer->getImplementation());
bufferImpl->promoteStaticUsage(count * ComputeVertexAttributeTypeSize(attribs[i]));
bufferImpl->promoteStaticUsage(count * ComputeVertexAttributeTypeSize(curAttrib));
}
}
}
......
......@@ -16,8 +16,9 @@
namespace gl
{
struct VertexAttribute;
class ProgramBinary;
class State;
struct VertexAttribute;
struct VertexAttribCurrentValueData;
}
......@@ -52,8 +53,8 @@ class VertexDataManager
VertexDataManager(rx::Renderer *renderer);
virtual ~VertexDataManager();
gl::Error prepareVertexData(const gl::VertexAttribute attribs[], const gl::VertexAttribCurrentValueData currentValues[],
gl::ProgramBinary *programBinary, GLint start, GLsizei count, TranslatedAttribute *outAttribs, GLsizei instances);
gl::Error prepareVertexData(const gl::State &state, GLint start, GLsizei count,
TranslatedAttribute *outAttribs, GLsizei instances);
private:
DISALLOW_COPY_AND_ASSIGN(VertexDataManager);
......
......@@ -11,6 +11,7 @@
#include "libGLESv2/FramebufferAttachment.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/Framebuffer.h"
#include "libGLESv2/State.h"
#include "libGLESv2/renderer/d3d/ProgramD3D.h"
#include "libGLESv2/renderer/d3d/ShaderD3D.h"
#include "libGLESv2/renderer/d3d/TextureD3D.h"
......@@ -939,17 +940,16 @@ gl::Error Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
return gl::Error(GL_NO_ERROR);
}
gl::Error Renderer11::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances)
gl::Error Renderer11::applyVertexBuffer(const gl::State &state, GLint first, GLsizei count, GLsizei instances)
{
TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS];
gl::Error error = mVertexDataManager->prepareVertexData(vertexAttributes, currentValues, programBinary, first, count, attributes, instances);
gl::Error error = mVertexDataManager->prepareVertexData(state, first, count, attributes, instances);
if (error.isError())
{
return error;
}
return mInputLayoutCache.applyVertexBuffers(attributes, programBinary);
return mInputLayoutCache.applyVertexBuffers(attributes, state.getCurrentProgramBinary());
}
gl::Error Renderer11::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo)
......
......@@ -80,9 +80,9 @@ class Renderer11 : public Renderer
virtual gl::Error applyRenderTarget(gl::Framebuffer *frameBuffer);
virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive);
virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray);
virtual gl::Error applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances);
virtual gl::Error applyVertexBuffer(const gl::State &state, GLint first, GLsizei count, GLsizei instances);
virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]);
......
......@@ -33,6 +33,7 @@
#include "libGLESv2/FramebufferAttachment.h"
#include "libGLESv2/Renderbuffer.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/State.h"
#include "libGLESv2/angletypes.h"
#include "libEGL/Display.h"
......@@ -1268,17 +1269,16 @@ gl::Error Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer)
return gl::Error(GL_NO_ERROR);
}
gl::Error Renderer9::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances)
gl::Error Renderer9::applyVertexBuffer(const gl::State &state, GLint first, GLsizei count, GLsizei instances)
{
TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS];
gl::Error error = mVertexDataManager->prepareVertexData(vertexAttributes, currentValues, programBinary, first, count, attributes, instances);
gl::Error error = mVertexDataManager->prepareVertexData(state, first, count, attributes, instances);
if (error.isError())
{
return error;
}
return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, programBinary, instances, &mRepeatDraw);
return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, state.getCurrentProgramBinary(), instances, &mRepeatDraw);
}
// Applies the indices and element array bindings to the Direct3D 9 device
......
......@@ -81,8 +81,7 @@ class Renderer9 : public Renderer
bool rasterizerDiscard, bool transformFeedbackActive);
virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray);
virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount);
virtual gl::Error applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[],
GLint first, GLsizei count, GLsizei instances);
virtual gl::Error applyVertexBuffer(const gl::State &state, GLint first, GLsizei count, GLsizei instances);
virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]);
......
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