Revert "Compute packed varyings in ProgramD3D only."
Likely the cause of Windows bot failures.
BUG=angleproject:1123
This reverts commit 532061bbfb160586a06f0e47b6bbb5350e735203.
Change-Id: Ia4f0161b97bfbf2adb4cafaa5fa5484f04fad245
Reviewed-on: https://chromium-review.googlesource.com/296710
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/DynamicHLSL.cpp b/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
index 9684320..942efa4 100644
--- a/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
+++ b/src/libANGLE/renderer/d3d/DynamicHLSL.cpp
@@ -236,7 +236,8 @@
// Packs varyings into generic varying registers, using the algorithm from [OpenGL ES Shading Language 1.00 rev. 17] appendix A section 7 page 111
// Returns the number of used varying registers, or -1 if unsuccesful
int DynamicHLSL::packVaryings(InfoLog &infoLog,
- std::vector<PackedVarying> *packedVaryings,
+ ShaderD3D *fragmentShader,
+ ShaderD3D *vertexShader,
const std::vector<std::string> &transformFeedbackVaryings)
{
// TODO (geofflang): Use context's caps
@@ -244,11 +245,17 @@
VaryingPacking packing = {};
- std::set<std::string> uniqueVaryingNames;
+ vertexShader->resetVaryingsRegisterAssignment();
+ fragmentShader->resetVaryingsRegisterAssignment();
- for (PackedVarying &packedVarying : *packedVaryings)
+ std::set<std::string> packedVaryings;
+
+ std::vector<PackedVarying> &vertexVaryings = vertexShader->getPackedVaryings();
+ std::vector<PackedVarying> &fragmentVaryings = fragmentShader->getPackedVaryings();
+ for (unsigned int varyingIndex = 0; varyingIndex < fragmentVaryings.size(); varyingIndex++)
{
- const sh::Varying &varying = *packedVarying.varying;
+ PackedVarying *packedVarying = &fragmentVaryings[varyingIndex];
+ const sh::Varying &varying = *packedVarying->varying;
// Do not assign registers to built-in or unreferenced varyings
if (varying.isBuiltIn() || !varying.staticUse)
@@ -256,11 +263,9 @@
continue;
}
- ASSERT(uniqueVaryingNames.count(varying.name) == 0);
-
- if (PackVarying(&packedVarying, maxVaryingVectors, packing))
+ if (PackVarying(packedVarying, maxVaryingVectors, packing))
{
- uniqueVaryingNames.insert(varying.name);
+ packedVaryings.insert(varying.name);
}
else
{
@@ -269,24 +274,26 @@
}
}
- for (const std::string &transformFeedbackVaryingName : transformFeedbackVaryings)
+ for (unsigned int feedbackVaryingIndex = 0; feedbackVaryingIndex < transformFeedbackVaryings.size(); feedbackVaryingIndex++)
{
- if (transformFeedbackVaryingName == "gl_Position" ||
- transformFeedbackVaryingName == "gl_PointSize")
+ const std::string &transformFeedbackVarying = transformFeedbackVaryings[feedbackVaryingIndex];
+
+ if (transformFeedbackVarying == "gl_Position" || transformFeedbackVarying == "gl_PointSize")
{
// do not pack builtin XFB varyings
continue;
}
- if (uniqueVaryingNames.count(transformFeedbackVaryingName) == 0)
+ if (packedVaryings.find(transformFeedbackVarying) == packedVaryings.end())
{
bool found = false;
- for (PackedVarying &packedVarying : *packedVaryings)
+ for (unsigned int varyingIndex = 0; varyingIndex < vertexVaryings.size(); varyingIndex++)
{
- const sh::Varying &varying = *packedVarying.varying;
- if (transformFeedbackVaryingName == varying.name)
+ PackedVarying *packedVarying = &vertexVaryings[varyingIndex];
+ const sh::Varying &varying = *packedVarying->varying;
+ if (transformFeedbackVarying == varying.name)
{
- if (!PackVarying(&packedVarying, maxVaryingVectors, packing))
+ if (!PackVarying(packedVarying, maxVaryingVectors, packing))
{
infoLog << "Could not pack varying " << varying.name;
return -1;
@@ -299,7 +306,8 @@
if (!found)
{
- infoLog << "Transform feedback varying " << transformFeedbackVaryingName
+ infoLog << "Transform feedback varying "
+ << transformFeedbackVarying
<< " does not exist in the vertex shader.";
return -1;
}
@@ -320,12 +328,13 @@
return registers;
}
-std::string DynamicHLSL::generateVaryingHLSL(const std::vector<PackedVarying> &varyings,
- bool shaderUsesPointSize) const
+std::string DynamicHLSL::generateVaryingHLSL(const ShaderD3D *shader) const
{
- std::string varyingSemantic = getVaryingSemantic(shaderUsesPointSize);
+ std::string varyingSemantic = getVaryingSemantic(shader->mUsesPointSize);
std::string varyingHLSL;
+ const std::vector<PackedVarying> &varyings = shader->getPackedVaryings();
+
for (const PackedVarying &packedVarying : varyings)
{
if (!packedVarying.registerAssigned())
@@ -726,13 +735,12 @@
}
}
-void DynamicHLSL::storeUserLinkedVaryings(const std::vector<PackedVarying> &packedVaryings,
- bool shaderUsesPointSize,
+void DynamicHLSL::storeUserLinkedVaryings(const ShaderD3D *vertexShader,
std::vector<LinkedVarying> *linkedVaryings) const
{
- const std::string &varyingSemantic = getVaryingSemantic(shaderUsesPointSize);
+ const std::string &varyingSemantic = getVaryingSemantic(vertexShader->mUsesPointSize);
- for (const PackedVarying &packedVarying : packedVaryings)
+ for (const PackedVarying &packedVarying : vertexShader->getPackedVaryings())
{
if (packedVarying.registerAssigned())
{
@@ -755,7 +763,6 @@
int registers,
std::string &pixelHLSL,
std::string &vertexHLSL,
- const std::vector<PackedVarying> &packedVaryings,
std::vector<LinkedVarying> *linkedVaryings,
std::vector<PixelShaderOutputVariable> *outPixelShaderKey,
bool *outUsesFragDepth) const
@@ -800,7 +807,7 @@
return false;
}
- const std::string &varyingHLSL = generateVaryingHLSL(packedVaryings, usesPointSize);
+ const std::string &varyingHLSL = generateVaryingHLSL(vertexShader);
// Instanced PointSprite emulation requires that gl_PointCoord is present in the vertex shader VS_OUTPUT
// structure to ensure compatibility with the generated PS_INPUT of the pixel shader.
@@ -813,7 +820,7 @@
usesFragCoord, (useInstancedPointSpriteEmulation && usesPointCoord),
(!useInstancedPointSpriteEmulation && usesPointSize), false);
- storeUserLinkedVaryings(packedVaryings, usesPointSize, linkedVaryings);
+ storeUserLinkedVaryings(vertexShader, linkedVaryings);
storeBuiltinLinkedVaryings(vertexSemantics, linkedVaryings);
// Instanced PointSprite emulation requires additional entries originally generated in the
@@ -874,7 +881,8 @@
vertexHLSL += " output.gl_FragCoord = gl_Position;\n";
}
- for (const PackedVarying &packedVarying : packedVaryings)
+ const std::vector<PackedVarying> &vertexVaryings = vertexShader->getPackedVaryings();
+ for (const PackedVarying &packedVarying : vertexVaryings)
{
if (!packedVarying.registerAssigned())
{
@@ -1043,7 +1051,8 @@
}
}
- for (const PackedVarying &packedVarying : packedVaryings)
+ const std::vector<PackedVarying> &fragmentVaryings = fragmentShader->getPackedVaryings();
+ for (const PackedVarying &packedVarying : fragmentVaryings)
{
const sh::Varying &varying = *packedVarying.varying;
@@ -1053,10 +1062,6 @@
continue;
}
- // Don't reference VS-only transform feedback varyings in the PS.
- if (packedVarying.vertexOnly)
- continue;
-
ASSERT(!varying.isBuiltIn());
for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++)
{
@@ -1123,22 +1128,21 @@
return true;
}
-std::string DynamicHLSL::generateGeometryShaderHLSL(
- int registers,
- const ShaderD3D *fragmentShader,
- const std::vector<PackedVarying> &packedVaryings) const
+std::string DynamicHLSL::generateGeometryShaderHLSL(int registers,
+ const ShaderD3D *fragmentShader,
+ const ShaderD3D *vertexShader) const
{
// for now we only handle point sprite emulation
- ASSERT(mRenderer->getMajorShaderModel() >= 4);
- return generatePointSpriteHLSL(registers, fragmentShader, packedVaryings);
+ ASSERT(vertexShader->mUsesPointSize && mRenderer->getMajorShaderModel() >= 4);
+ return generatePointSpriteHLSL(registers, fragmentShader, vertexShader);
}
-std::string DynamicHLSL::generatePointSpriteHLSL(
- int registers,
- const ShaderD3D *fragmentShader,
- const std::vector<PackedVarying> &packedVaryings) const
+std::string DynamicHLSL::generatePointSpriteHLSL(int registers,
+ const ShaderD3D *fragmentShader,
+ const ShaderD3D *vertexShader) const
{
ASSERT(registers >= 0);
+ ASSERT(vertexShader->mUsesPointSize);
ASSERT(mRenderer->getMajorShaderModel() >= 4);
std::string geomHLSL;
@@ -1148,8 +1152,7 @@
const SemanticInfo &outSemantics = getSemanticInfo(registers, true, fragmentShader->mUsesFragCoord,
fragmentShader->mUsesPointCoord, true, false);
- // If we're generating the geometry shader, we assume the vertex shader uses point size.
- std::string varyingHLSL = generateVaryingHLSL(packedVaryings, true);
+ std::string varyingHLSL = generateVaryingHLSL(vertexShader);
std::string inLinkHLSL = generateVaryingLinkHLSL(inSemantics, varyingHLSL);
std::string outLinkHLSL = generateVaryingLinkHLSL(outSemantics, varyingHLSL);
diff --git a/src/libANGLE/renderer/d3d/DynamicHLSL.h b/src/libANGLE/renderer/d3d/DynamicHLSL.h
index 28256ce..9c91083 100644
--- a/src/libANGLE/renderer/d3d/DynamicHLSL.h
+++ b/src/libANGLE/renderer/d3d/DynamicHLSL.h
@@ -46,36 +46,14 @@
size_t outputIndex;
};
-struct PackedVarying
-{
- PackedVarying(const sh::Varying &varyingIn)
- : varying(&varyingIn), registerIndex(GL_INVALID_INDEX), columnIndex(0)
- {
- }
-
- bool registerAssigned() const { return registerIndex != GL_INVALID_INDEX; }
-
- void resetRegisterAssignment() { registerIndex = GL_INVALID_INDEX; }
-
- const sh::Varying *varying;
-
- // Assigned during link
- unsigned int registerIndex;
-
- // Assigned during link, Defaults to 0
- unsigned int columnIndex;
-
- // Transform feedback varyings can be only referenced in the VS.
- bool vertexOnly;
-};
-
class DynamicHLSL : angle::NonCopyable
{
public:
explicit DynamicHLSL(RendererD3D *const renderer);
int packVaryings(gl::InfoLog &infoLog,
- std::vector<PackedVarying> *packedVaryings,
+ ShaderD3D *fragmentShader,
+ ShaderD3D *vertexShader,
const std::vector<std::string> &transformFeedbackVaryings);
std::string generateVertexShaderForInputLayout(const std::string &sourceShader,
const gl::InputLayout &inputLayout,
@@ -88,14 +66,13 @@
int registers,
std::string &pixelHLSL,
std::string &vertexHLSL,
- const std::vector<PackedVarying> &packedVaryings,
std::vector<gl::LinkedVarying> *linkedVaryings,
std::vector<PixelShaderOutputVariable> *outPixelShaderKey,
bool *outUsesFragDepth) const;
std::string generateGeometryShaderHLSL(int registers,
const ShaderD3D *fragmentShader,
- const std::vector<PackedVarying> &packedVaryings) const;
+ const ShaderD3D *vertexShader) const;
private:
RendererD3D *const mRenderer;
@@ -106,15 +83,12 @@
SemanticInfo getSemanticInfo(int startRegisters, bool position, bool fragCoord, bool pointCoord,
bool pointSize, bool pixelShader) const;
std::string generateVaryingLinkHLSL(const SemanticInfo &info, const std::string &varyingHLSL) const;
- std::string generateVaryingHLSL(const std::vector<PackedVarying> &varyings,
- bool shaderUsesPointSize) const;
- void storeUserLinkedVaryings(const std::vector<PackedVarying> &packedVaryings,
- bool shaderUsesPointSize,
- std::vector<gl::LinkedVarying> *linkedVaryings) const;
+ std::string generateVaryingHLSL(const ShaderD3D *shader) const;
+ void storeUserLinkedVaryings(const ShaderD3D *vertexShader, std::vector<gl::LinkedVarying> *linkedVaryings) const;
void storeBuiltinLinkedVaryings(const SemanticInfo &info, std::vector<gl::LinkedVarying> *linkedVaryings) const;
std::string generatePointSpriteHLSL(int registers,
const ShaderD3D *fragmentShader,
- const std::vector<PackedVarying> &packedVaryings) const;
+ const ShaderD3D *vertexShader) const;
// Prepend an underscore
static std::string decorateVariable(const std::string &name);
diff --git a/src/libANGLE/renderer/d3d/ProgramD3D.cpp b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
index 179186a..daa7779 100644
--- a/src/libANGLE/renderer/d3d/ProgramD3D.cpp
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
@@ -127,52 +127,37 @@
const ProgramD3D::SemanticIndexArray *originalIndices;
};
-std::vector<PackedVarying> MergeVaryings(const gl::Shader &vertexShader,
- const gl::Shader &fragmentShader,
- const std::vector<std::string> &tfVaryings)
+bool LinkVaryingRegisters(gl::InfoLog &infoLog,
+ ShaderD3D *vertexShaderD3D,
+ ShaderD3D *fragmentShaderD3D)
{
- std::vector<PackedVarying> packedVaryings;
-
- for (const sh::Varying &output : vertexShader.getVaryings())
+ for (PackedVarying &input : fragmentShaderD3D->getPackedVaryings())
{
- bool packed = false;
+ bool matched = false;
// Built-in varyings obey special rules
- if (output.isBuiltIn())
+ if (input.varying->isBuiltIn())
{
continue;
}
- for (const sh::Varying &input : fragmentShader.getVaryings())
+ for (PackedVarying &output : vertexShaderD3D->getPackedVaryings())
{
- if (output.name == input.name)
+ if (output.varying->name == input.varying->name)
{
- packedVaryings.push_back(PackedVarying(input));
- packed = true;
+ output.registerIndex = input.registerIndex;
+ output.columnIndex = input.columnIndex;
+
+ matched = true;
break;
}
}
- // Keep Transform FB varyings in the merged list always.
- if (!packed)
- {
- for (const std::string &tfVarying : tfVaryings)
- {
- if (tfVarying == output.name)
- {
- packedVaryings.push_back(PackedVarying(output));
- packedVaryings.back().vertexOnly = true;
- packed = true;
- break;
- }
- }
- }
-
- // We permit unreferenced varyings
- ASSERT(packed || !output.staticUse);
+ // We permit unmatched, unreferenced varyings
+ ASSERT(matched || !input.varying->staticUse);
}
- return packedVaryings;
+ return true;
}
} // anonymous namespace
@@ -1063,10 +1048,9 @@
return gl::Error(GL_NO_ERROR);
}
-LinkResult ProgramD3D::compileProgramExecutables(gl::InfoLog &infoLog,
- int registers,
- const std::vector<PackedVarying> &packedVaryings)
+LinkResult ProgramD3D::compileProgramExecutables(gl::InfoLog &infoLog, int registers)
{
+ const ShaderD3D *vertexShaderD3D = GetImplAs<ShaderD3D>(mData.getAttachedVertexShader());
const ShaderD3D *fragmentShaderD3D = GetImplAs<ShaderD3D>(mData.getAttachedFragmentShader());
const gl::InputLayout &defaultInputLayout =
@@ -1088,8 +1072,7 @@
if (usesGeometryShader())
{
- std::string geometryHLSL =
- mDynamicHLSL->generateGeometryShaderHLSL(registers, fragmentShaderD3D, packedVaryings);
+ std::string geometryHLSL = mDynamicHLSL->generateGeometryShaderHLSL(registers, fragmentShaderD3D, vertexShaderD3D);
error = mRenderer->compileToExecutable(
infoLog, geometryHLSL, SHADER_GEOMETRY, mTransformFeedbackLinkedVaryings,
@@ -1102,8 +1085,6 @@
}
#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
- const ShaderD3D *vertexShaderD3D = GetImplAs<ShaderD3D>(mData.getAttachedVertexShader());
-
if (usesGeometryShader() && mGeometryExecutable)
{
// Geometry shaders are currently only used internally, so there is no corresponding shader object at the interface level
@@ -1155,11 +1136,8 @@
}
}
- std::vector<PackedVarying> packedVaryings =
- MergeVaryings(*vertexShader, *fragmentShader, mData.getTransformFeedbackVaryingNames());
-
// Map the varyings to the register file
- int registers = mDynamicHLSL->packVaryings(infoLog, &packedVaryings,
+ int registers = mDynamicHLSL->packVaryings(infoLog, fragmentShaderD3D, vertexShaderD3D,
mData.getTransformFeedbackVaryingNames());
if (registers < 0)
@@ -1167,10 +1145,12 @@
return LinkResult(false, gl::Error(GL_NO_ERROR));
}
+ LinkVaryingRegisters(infoLog, vertexShaderD3D, fragmentShaderD3D);
+
std::vector<gl::LinkedVarying> linkedVaryings;
if (!mDynamicHLSL->generateShaderLinkHLSL(data, mData, infoLog, registers, mPixelHLSL,
- mVertexHLSL, packedVaryings, &linkedVaryings,
- &mPixelShaderKey, &mUsesFragDepth))
+ mVertexHLSL, &linkedVaryings, &mPixelShaderKey,
+ &mUsesFragDepth))
{
return LinkResult(false, gl::Error(GL_NO_ERROR));
}
@@ -1188,7 +1168,7 @@
gatherTransformFeedbackVaryings(linkedVaryings);
- LinkResult result = compileProgramExecutables(infoLog, registers, packedVaryings);
+ LinkResult result = compileProgramExecutables(infoLog, registers);
if (result.error.isError() || !result.linkSuccess)
{
infoLog << "Failed to create D3D shaders.";
diff --git a/src/libANGLE/renderer/d3d/ProgramD3D.h b/src/libANGLE/renderer/d3d/ProgramD3D.h
index 9ce3b0d..37a476f 100644
--- a/src/libANGLE/renderer/d3d/ProgramD3D.h
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.h
@@ -207,9 +207,7 @@
sh::BlockLayoutEncoder *encoder, std::vector<unsigned int> *blockUniformIndexes,
bool inRowMajorLayout);
- LinkResult compileProgramExecutables(gl::InfoLog &infoLog,
- int registers,
- const std::vector<PackedVarying> &packedVaryings);
+ LinkResult compileProgramExecutables(gl::InfoLog &infoLog, int registers);
void gatherTransformFeedbackVaryings(const std::vector<gl::LinkedVarying> &varyings);
diff --git a/src/libANGLE/renderer/d3d/ShaderD3D.cpp b/src/libANGLE/renderer/d3d/ShaderD3D.cpp
index 0a3e8e5..f71250e 100644
--- a/src/libANGLE/renderer/d3d/ShaderD3D.cpp
+++ b/src/libANGLE/renderer/d3d/ShaderD3D.cpp
@@ -110,6 +110,11 @@
mVaryings = *varyings;
+ for (size_t varyingIndex = 0; varyingIndex < varyings->size(); varyingIndex++)
+ {
+ mPackedVaryings.push_back(PackedVarying(mVaryings[varyingIndex]));
+ }
+
mUsesMultipleRenderTargets = mTranslatedSource.find("GL_USES_MRT") != std::string::npos;
mUsesFragColor = mTranslatedSource.find("GL_USES_FRAG_COLOR") != std::string::npos;
mUsesFragData = mTranslatedSource.find("GL_USES_FRAG_DATA") != std::string::npos;
@@ -126,6 +131,14 @@
}
}
+void ShaderD3D::resetVaryingsRegisterAssignment()
+{
+ for (size_t varyingIndex = 0; varyingIndex < mVaryings.size(); varyingIndex++)
+ {
+ mPackedVaryings[varyingIndex].resetRegisterAssignment();
+ }
+}
+
// initialize/clean up previous state
void ShaderD3D::uncompile()
{
diff --git a/src/libANGLE/renderer/d3d/ShaderD3D.h b/src/libANGLE/renderer/d3d/ShaderD3D.h
index b6630f2..9cdd541 100644
--- a/src/libANGLE/renderer/d3d/ShaderD3D.h
+++ b/src/libANGLE/renderer/d3d/ShaderD3D.h
@@ -20,6 +20,24 @@
class DynamicHLSL;
class RendererD3D;
+struct PackedVarying
+{
+ PackedVarying(const sh::Varying &varyingIn)
+ : varying(&varyingIn), registerIndex(GL_INVALID_INDEX), columnIndex(0)
+ {
+ }
+
+ bool registerAssigned() const { return registerIndex != GL_INVALID_INDEX; }
+
+ void resetRegisterAssignment() { registerIndex = GL_INVALID_INDEX; }
+
+ const sh::Varying *varying;
+
+ // TODO(jmadill): Make these D3D-only or otherwise clearly separate from GL.
+ unsigned int registerIndex; // Assigned during link
+ unsigned int columnIndex; // Assigned during link, defaults to 0
+};
+
class ShaderD3D : public ShaderImpl
{
friend class DynamicHLSL;
@@ -33,6 +51,7 @@
// D3D-specific methods
virtual void uncompile();
+ void resetVaryingsRegisterAssignment();
unsigned int getUniformRegister(const std::string &uniformName) const;
unsigned int getInterfaceBlockRegister(const std::string &blockName) const;
void appendDebugInfo(const std::string &info) { mDebugInfo += info; }
@@ -49,6 +68,11 @@
virtual bool compile(gl::Compiler *compiler, const std::string &source);
+ const std::vector<PackedVarying> &getPackedVaryings() const { return mPackedVaryings; }
+
+ // TODO(jmadill): remove this
+ std::vector<PackedVarying> &getPackedVaryings() { return mPackedVaryings; }
+
private:
void compileToHLSL(ShHandle compiler, const std::string &source);
void parseVaryings(ShHandle compiler);
@@ -76,6 +100,7 @@
std::map<std::string, unsigned int> mUniformRegisterMap;
std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
RendererD3D *mRenderer;
+ std::vector<PackedVarying> mPackedVaryings;
};
}
diff --git a/src/tests/gl_tests/TransformFeedbackTest.cpp b/src/tests/gl_tests/TransformFeedbackTest.cpp
index 23b5bf5..5b9cdd5 100644
--- a/src/tests/gl_tests/TransformFeedbackTest.cpp
+++ b/src/tests/gl_tests/TransformFeedbackTest.cpp
@@ -264,71 +264,6 @@
glDeleteBuffers(1, &scratchBuffer);
}
-// Test that we can capture varyings only used in the vertex shader.
-TEST_P(TransformFeedbackTest, VertexOnly)
-{
- const std::string &vertexShaderSource =
- "#version 300 es\n"
- "in vec2 position;\n"
- "in float attrib;\n"
- "out float varyingAttrib;\n"
- "void main() {\n"
- " gl_Position = vec4(position, 0, 1);\n"
- " varyingAttrib = attrib;\n"
- "}";
-
- const std::string &fragmentShaderSource =
- "#version 300 es\n"
- "out mediump vec4 color;\n"
- "void main() {\n"
- " color = vec4(0.0, 1.0, 0.0, 1.0);\n"
- "}";
-
- std::vector<std::string> tfVaryings;
- tfVaryings.push_back("varyingAttrib");
-
- GLuint program = CompileProgramWithTransformFeedback(vertexShaderSource, fragmentShaderSource,
- tfVaryings, GL_INTERLEAVED_ATTRIBS);
- ASSERT_NE(0u, program);
-
- GLuint transformFeedback;
- glGenTransformFeedbacks(1, &transformFeedback);
- glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformFeedback);
- glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, mTransformFeedbackBuffer);
-
- std::vector<float> attribData;
- for (unsigned int cnt = 0; cnt < 100; ++cnt)
- {
- attribData.push_back(static_cast<float>(cnt));
- }
-
- GLint attribLocation = glGetAttribLocation(program, "attrib");
- ASSERT_NE(-1, attribLocation);
-
- glVertexAttribPointer(attribLocation, 1, GL_FLOAT, GL_FALSE, 4, &attribData[0]);
- glEnableVertexAttribArray(attribLocation);
-
- glBeginTransformFeedback(GL_TRIANGLES);
- drawQuad(program, "position", 0.5f);
- glEndTransformFeedback();
- ASSERT_GL_NO_ERROR();
-
- GLvoid *mappedBuffer =
- glMapBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, sizeof(float) * 6, GL_MAP_READ_BIT);
- ASSERT_NE(nullptr, mappedBuffer);
-
- float *mappedFloats = static_cast<float *>(mappedBuffer);
- for (unsigned int cnt = 0; cnt < 6; ++cnt)
- {
- EXPECT_EQ(attribData[cnt], mappedFloats[cnt]);
- }
-
- glDeleteTransformFeedbacks(1, &transformFeedback);
- glDeleteProgram(program);
-
- EXPECT_GL_NO_ERROR();
-}
-
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(TransformFeedbackTest, ES3_D3D11());