};
// TODO adapt input attribute locations!!!
- const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[1] =
+ const VkVertexInputAttributeDescription vertexInputAttributeDescriptions[2] =
{
{
0u, // deUint32 location;
VK_FORMAT_R32G32B32A32_SFLOAT, // VkFormat format;
0u // deUint32 offsetInBytes;
},
-/* {
+ {
1u, // deUint32 location;
0u, // deUint32 binding;
VK_FORMAT_R32G32B32A32_SFLOAT, // VkFormat format;
- DE_OFFSET_OF(Vertex4RGBA, color), // deUint32 offsetInBytes;
+ quadGrid.getNumVertices() * sizeof(Vec4), // deUint32 offsetInBytes;
}
-*/
};
const VkPipelineVertexInputStateCreateInfo vertexInputStateParams =
DE_NULL, // const void* pNext;
1u, // deUint32 bindingCount;
&vertexInputBindingDescription, // const VkVertexInputBindingDescription* pVertexBindingDescriptions;
- 1u, // deUint32 attributeCount;
+ 2u, // deUint32 attributeCount;
vertexInputAttributeDescriptions // const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
};
// Create vertex buffer
{
// TODO: upload all inputs
- const VkDeviceSize vertexBufferSize = quadGrid.getNumVertices() * sizeof(Vec4);
+ const VkDeviceSize vertexSize = quadGrid.getNumVertices() * sizeof(Vec4);
+ const VkDeviceSize coordSize = quadGrid.getNumVertices() * sizeof(Vec4);
+ const VkDeviceSize vertexBufferSize = vertexSize + coordSize;
const VkBufferCreateInfo vertexBufferParams =
{
// Load vertices into vertex buffer
void* bufferPtr;
VK_CHECK(vk.mapMemory(vkDevice, m_vertexBufferAlloc->getMemory(), 0, vertexBufferSize, 0, &bufferPtr));
- deMemcpy(bufferPtr, quadGrid.getPositions(), vertexBufferSize);
+ deMemcpy(bufferPtr, quadGrid.getPositions(), vertexSize);
+ deMemcpy(bufferPtr + vertexSize, quadGrid.getCoords(), coordSize);
VK_CHECK(vk.unmapMemory(vkDevice, m_vertexBufferAlloc->getMemory()));
}
int gridSize = quadGrid.getGridSize();
int stride = gridSize + 1;
//bool hasAlpha = m_context.getRenderTarget().getPixelFormat().alphaBits > 0;
- bool hasAlpha = true;
+ bool hasAlpha = false;
ShaderEvalContext evalCtx (quadGrid);
// Evaluate color for each vertex.
- vector<Vec4> colors((gridSize+1)*(gridSize+1));
+ vector<Vec4> colors((gridSize + 1) * (gridSize + 1));
for (int y = 0; y < gridSize+1; y++)
for (int x = 0; x < gridSize+1; x++)
{
const std::string& name,
const std::string& description,
bool isVertexCase,
- ShaderEvalFunc evalFunc)
+ ShaderEvalFunc evalFunc,
+ std::string vertexShader,
+ std::string fragmentShader)
: ShaderRenderCase(testCtx, name, description, isVertexCase, evalFunc)
{
- m_vertShaderSource = "#version 300 es\n"
- "layout(location = 0) in highp vec4 a_position;\n"
- "void main (void) { gl_Position = a_position; }\n";
- m_fragShaderSource = "#version 300 es\n"
- "layout(location = 0) out lowp vec4 o_color;\n"
- "void main (void) { o_color = vec4(1.0, 0.0, 1.0, 1.0); }\n";
+ m_vertShaderSource = vertexShader;
+ m_fragShaderSource = fragmentShader;
}
};
{
de::MovePtr<tcu::TestCaseGroup> shaderRenderCaseTests (new tcu::TestCaseGroup(testCtx, "shaderRenderCase", "ShaderRenderCase Tests"));
- shaderRenderCaseTests->addChild(new DummyTestRenderCase(testCtx, "testVertex", "testVertex", true, evalCoordsPassthrough));
- shaderRenderCaseTests->addChild(new DummyTestRenderCase(testCtx, "testFragment", "testFragment", false, eval_DEBUG));
+ std::string base_vertex = "#version 300 es\n"
+ "layout(location = 0) in highp vec4 a_position;\n"
+ "layout(location = 1) in highp vec4 a_coords;\n"
+ "out mediump vec4 v_color;\n"
+ "void main (void) { gl_Position = a_position; v_color = vec4(a_coords.xyz, 1.0); }\n";
+
+ std::string base_fragment = "#version 300 es\n"
+ "layout(location = 0) out lowp vec4 o_color;\n"
+ "in mediump vec4 v_color;\n"
+ "void main (void) { o_color = v_color; }\n";
+
+ std::string debug_fragment = "#version 300 es\n"
+ "layout(location = 0) out lowp vec4 o_color;\n"
+ "in mediump vec4 v_color;\n"
+ "void main (void) { o_color = vec4(1,0,1,1); }\n";
+
+
+ shaderRenderCaseTests->addChild(new DummyTestRenderCase(testCtx, "testVertex", "testVertex", true, evalCoordsPassthrough, base_vertex, base_fragment));
+ shaderRenderCaseTests->addChild(new DummyTestRenderCase(testCtx, "testFragment", "testFragment", false, eval_DEBUG, base_vertex, debug_fragment));
return shaderRenderCaseTests.release();
}