Commit 772d2497 by Alexis Hetu Committed by Alexis Hétu

Transform Feedback buffer locking utility functions

Similarly to what had been done for uniform buffers, transform feedback buffers require locking/unlocking functions so that the Renderer can access these resources. Change-Id: I909ccda4f30534290ebd4a575c082b5475786080 Reviewed-on: https://swiftshader-review.googlesource.com/5041Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 13c70cda
...@@ -95,6 +95,8 @@ enum ...@@ -95,6 +95,8 @@ enum
MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 4, MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 4,
MAX_UNIFORM_BUFFER_BINDINGS = MAX_FRAGMENT_UNIFORM_BLOCKS + MAX_VERTEX_UNIFORM_BLOCKS, // Limited to 127 by SourceParameter.bufferIndex in Shader.hpp MAX_UNIFORM_BUFFER_BINDINGS = MAX_FRAGMENT_UNIFORM_BLOCKS + MAX_VERTEX_UNIFORM_BLOCKS, // Limited to 127 by SourceParameter.bufferIndex in Shader.hpp
MAX_CLIP_PLANES = 6, MAX_CLIP_PLANES = 6,
MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 64,
MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 64,
RENDERTARGETS = 4, RENDERTARGETS = 4,
}; };
......
...@@ -61,6 +61,21 @@ namespace sw ...@@ -61,6 +61,21 @@ namespace sw
return memcmp(static_cast<const States*>(this), static_cast<const States*>(&state), sizeof(States)) == 0; return memcmp(static_cast<const States*>(this), static_cast<const States*>(&state), sizeof(States)) == 0;
} }
VertexProcessor::TransformFeedbackInfo::TransformFeedbackInfo()
{
clear();
}
void VertexProcessor::TransformFeedbackInfo::clear()
{
buffer = nullptr;
offset = 0;
reg = 0;
row = 0;
col = 0;
stride = 0;
}
VertexProcessor::VertexProcessor(Context *context) : context(context) VertexProcessor::VertexProcessor(Context *context) : context(context)
{ {
for(int i = 0; i < 12; i++) for(int i = 0; i < 12; i++)
...@@ -188,6 +203,40 @@ namespace sw ...@@ -188,6 +203,40 @@ namespace sw
} }
} }
void VertexProcessor::setTransformFeedbackBuffer(int index, sw::Resource* buffer, int offset, unsigned int reg, unsigned int row, unsigned int col, size_t stride)
{
transformFeedbackInfo[index].buffer = buffer;
transformFeedbackInfo[index].offset = offset;
transformFeedbackInfo[index].reg = reg;
transformFeedbackInfo[index].row = row;
transformFeedbackInfo[index].col = col;
transformFeedbackInfo[index].stride = stride;
}
void VertexProcessor::lockTransformFeedbackBuffers(byte** t, unsigned int* v, unsigned int* r, unsigned int* c, unsigned int* s)
{
for(int i = 0; i < MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS; ++i)
{
t[i] = transformFeedbackInfo[i].buffer ? static_cast<byte*>(transformFeedbackInfo[i].buffer->lock(PUBLIC, PRIVATE)) + transformFeedbackInfo[i].offset : nullptr;
v[i] = transformFeedbackInfo[i].reg;
r[i] = transformFeedbackInfo[i].row;
c[i] = transformFeedbackInfo[i].col;
s[i] = transformFeedbackInfo[i].stride;
}
}
void VertexProcessor::unlockTransformFeedbackBuffers()
{
for(int i = 0; i < MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS; ++i)
{
if(transformFeedbackInfo[i].buffer)
{
transformFeedbackInfo[i].buffer->unlock();
}
transformFeedbackInfo[i].clear();
}
}
void VertexProcessor::setModelMatrix(const Matrix &M, int i) void VertexProcessor::setModelMatrix(const Matrix &M, int i)
{ {
if(i < 12) if(i < 12)
......
...@@ -191,6 +191,10 @@ namespace sw ...@@ -191,6 +191,10 @@ namespace sw
virtual void lockUniformBuffers(byte** u); virtual void lockUniformBuffers(byte** u);
virtual void unlockUniformBuffers(); virtual void unlockUniformBuffers();
virtual void setTransformFeedbackBuffer(int index, sw::Resource* transformFeedbackBuffer, int offset, unsigned int reg, unsigned int row, unsigned int col, size_t stride);
virtual void lockTransformFeedbackBuffers(byte** t, unsigned int* v, unsigned int* r, unsigned int* c, unsigned int* s);
virtual void unlockTransformFeedbackBuffers();
// Transformations // Transformations
virtual void setModelMatrix(const Matrix &M, int i = 0); virtual void setModelMatrix(const Matrix &M, int i = 0);
virtual void setViewMatrix(const Matrix &V); virtual void setViewMatrix(const Matrix &V);
...@@ -286,6 +290,19 @@ namespace sw ...@@ -286,6 +290,19 @@ namespace sw
private: private:
void updateTransform(); void updateTransform();
struct TransformFeedbackInfo
{
TransformFeedbackInfo();
void clear();
Resource* buffer;
int offset;
int reg;
int row;
int col;
size_t stride;
};
TransformFeedbackInfo transformFeedbackInfo[MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS];
void setTransform(const Matrix &M, int i); void setTransform(const Matrix &M, int i);
void setCameraTransform(const Matrix &M, int i); void setCameraTransform(const Matrix &M, int i);
......
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