Lines Matching refs:glu
53 static bool isExtensionSupported (const glu::RenderContext& renderCtx, const std::string& extension)
71 static void checkExtension (const glu::RenderContext& renderCtx, const std::string& extension)
77 static void checkLimit (const glu::RenderContext& renderCtx, deUint32 pname, int required)
87 throw tcu::TestError("Failed to query " + de::toString(glu::getGettableStateStr(pname)) + " - got " + de::toString(glu::getErrorStr(error)));
89 throw tcu::NotSupportedError("Test requires " + de::toString(glu::getGettableStateStr(pname)) + " >= " + de::toString(required) + ", got " + de::toString(implementationLimit));
96 const bool usesInout = glu::glslVersionUsesInOutQualifiers(shaderSpec.version);
103 src << glu::getGLSLVersionDeclaration(shaderSpec.version) << "\n";
111 src << in << " " << glu::declare(input->varType, inputPrefix + input->name) << ";\n";
117 if (glu::isDataTypeBoolOrBVec(output->varType.getBasicType()))
119 const int vecSize = glu::getDataTypeScalarSize(output->varType.getBasicType());
120 const glu::DataType intBaseType = vecSize > 1 ? glu::getDataTypeIntVec(vecSize) : glu::TYPE_INT;
121 const glu::VarType intType (intBaseType, glu::PRECISION_HIGHP);
123 src << "flat " << out << " " << glu::declare(intType, outputPrefix + output->name) << ";\n";
126 src << "flat " << out << " " << glu::declare(output->varType, outputPrefix + output->name) << ";\n";
137 src << "\t" << glu::declare(input->varType, input->name) << " = " << inputPrefix << input->name << ";\n";
141 src << "\t" << glu::declare(output->varType, output->name) << ";\n";
155 if (glu::isDataTypeBoolOrBVec(output->varType.getBasicType()))
157 const int vecSize = glu::getDataTypeScalarSize(output->varType.getBasicType());
158 const glu::DataType intBaseType = vecSize > 1 ? glu::getDataTypeIntVec(vecSize) : glu::TYPE_INT;
160 src << "\t" << outputPrefix << output->name << " = " << glu::getDataTypeName(intBaseType) << "(" << output->name << ");\n";
173 DE_ASSERT(glu::glslVersionUsesInOutQualifiers(shaderSpec.version));
178 src << glu::getGLSLVersionDeclaration(shaderSpec.version) << "\n";
180 if (glu::glslVersionIsES(shaderSpec.version) && shaderSpec.version <= glu::GLSL_VERSION_310_ES)
190 src << "flat in " << glu::declare(input->varType, inputPrefix + input->name) << "[];\n";
196 if (glu::isDataTypeBoolOrBVec(output->varType.getBasicType()))
198 const int vecSize = glu::getDataTypeScalarSize(output->varType.getBasicType());
199 const glu::DataType intBaseType = vecSize > 1 ? glu::getDataTypeIntVec(vecSize) : glu::TYPE_INT;
200 const glu::VarType intType (intBaseType, glu::PRECISION_HIGHP);
202 src << "flat out " << glu::declare(intType, outputPrefix + output->name) << ";\n";
205 src << "flat out " << glu::declare(output->varType, outputPrefix + output->name) << ";\n";
215 src << "\t" << glu::declare(input->varType, input->name) << " = " << inputPrefix << input->name << "[0];\n";
219 src << "\t" << glu::declare(output->varType, output->name) << ";\n";
235 if (glu::isDataTypeBoolOrBVec(output->varType.getBasicType()))
237 const int vecSize = glu::getDataTypeScalarSize(output->varType.getBasicType());
238 const glu::DataType intBaseType = vecSize > 1 ? glu::getDataTypeIntVec(vecSize) : glu::TYPE_INT;
240 src << "\t" << outputPrefix << output->name << " = " << glu::getDataTypeName(intBaseType) << "(" << output->name << ");\n";
253 static std::string generateEmptyFragmentSource (glu::GLSLVersion version)
255 const bool customOut = glu::glslVersionUsesInOutQualifiers(version);
258 src << glu::getGLSLVersionDeclaration(version) << "\n";
273 DE_ASSERT(glu::glslVersionUsesInOutQualifiers(shaderSpec.version));
277 src << glu::getGLSLVersionDeclaration(shaderSpec.version) << "\n"
282 src << "in " << glu::declare(input->varType, inputPrefix + input->name) << ";\n"
283 << "flat out " << glu::declare(input->varType, outputPrefix + input->name) << ";\n";
300 DE_ASSERT(glu::glslVersionUsesInOutQualifiers(shaderSpec.version));
307 glu::VariableDeclaration decl (output.varType, outVarName, glu::STORAGE_OUT, glu::INTERPOLATION_LAST, glu::Layout(location));
311 if (useIntOutputs && glu::isDataTypeFloatOrVec(output.varType.getBasicType()))
313 const int vecSize = glu::getDataTypeScalarSize(output.varType.getBasicType());
314 const glu::DataType uintBasicType = vecSize > 1 ? glu::getDataTypeUintVec(vecSize) : glu::TYPE_UINT;
315 const glu::VarType uintType (uintBasicType, glu::PRECISION_HIGHP);
320 else if (glu::isDataTypeBoolOrBVec(output.varType.getBasicType()))
322 const int vecSize = glu::getDataTypeScalarSize(output.varType.getBasicType());
323 const glu::DataType intBasicType = vecSize > 1 ? glu::getDataTypeIntVec(vecSize) : glu::TYPE_INT;
324 const glu::VarType intType (intBasicType, glu::PRECISION_HIGHP);
329 else if (glu::isDataTypeMatrix(output.varType.getBasicType()))
331 const int vecSize = glu::getDataTypeMatrixNumRows(output.varType.getBasicType());
332 const int numVecs = glu::getDataTypeMatrixNumColumns(output.varType.getBasicType());
333 const glu::DataType uintBasicType = glu::getDataTypeUintVec(vecSize);
334 const glu::VarType uintType (uintBasicType, glu::PRECISION_HIGHP);
353 if (useIntOutputs && glu::isDataTypeFloatOrVec(output->varType.getBasicType()))
355 else if (glu::isDataTypeMatrix(output->varType.getBasicType()))
357 const int numVecs = glu::getDataTypeMatrixNumColumns(output->varType.getBasicType());
365 else if (glu::isDataTypeBoolOrBVec(output->varType.getBasicType()))
367 const int vecSize = glu::getDataTypeScalarSize(output->varType.getBasicType());
368 const glu::DataType intBaseType = vecSize > 1 ? glu::getDataTypeIntVec(vecSize) : glu::TYPE_INT;
370 src << "\t" << outputPrefix << output->name << " = " << glu::getDataTypeName(intBaseType) << "(" << valuePrefix << output->name << ");\n";
379 DE_ASSERT(glu::glslVersionUsesInOutQualifiers(shaderSpec.version));
383 src << glu::getGLSLVersionDeclaration(shaderSpec.version) << "\n";
389 src << "flat in " << glu::declare(input->varType, inputPrefix + input->name) << ";\n";
397 src << "\t" << glu::declare(input->varType, input->name) << " = " << inputPrefix << input->name << ";\n";
401 src << "\t" << glu::declare(output->varType, output->name) << ";\n";
421 DE_ASSERT(glu::glslVersionUsesInOutQualifiers(shaderSpec.version));
425 src << glu::getGLSLVersionDeclaration(shaderSpec.version) << "\n";
432 if (glu::isDataTypeBoolOrBVec(output->varType.getBasicType()))
434 const int vecSize = glu::getDataTypeScalarSize(output->varType.getBasicType());
435 const glu::DataType intBaseType = vecSize > 1 ? glu::getDataTypeIntVec(vecSize) : glu::TYPE_INT;
436 const glu::VarType intType (intBaseType, glu::PRECISION_HIGHP);
438 src << "flat in " << glu::declare(intType, inputPrefix + output->name) << ";\n";
441 src << "flat in " << glu::declare(output->varType, inputPrefix + output->name) << ";\n";
457 ShaderExecutor::ShaderExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec)
485 FragmentOutExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec);
501 const int numLocations = glu::getDataTypeNumLocations(it->varType.getBasicType());
514 inline bool hasFloatRenderTargets (const glu::RenderContext& renderCtx)
516 glu::ContextType type = renderCtx.getType();
517 return glu::isContextTypeGLCore(type);
520 FragmentOutExecutor::FragmentOutExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec)
537 static tcu::TextureFormat getRenderbufferFormatForOutput (const glu::VarType& outputType, bool useIntOutputs)
547 const glu::DataType basicType = outputType.getBasicType();
548 const int numComps = glu::getDataTypeNumComponents(basicType);
551 switch (glu::getDataTypeScalarType(basicType))
553 case glu::TYPE_UINT: channelType = tcu::TextureFormat::UNSIGNED_INT32; break;
554 case glu::TYPE_INT: channelType = tcu::TextureFormat::SIGNED_INT32; break;
555 case glu::TYPE_BOOL: channelType = tcu::TextureFormat::SIGNED_INT32; break;
556 case glu::TYPE_FLOAT: channelType = useIntOutputs ? tcu::TextureFormat::UNSIGNED_INT32 : tcu::TextureFormat::FLOAT; break;
574 glu::Framebuffer framebuffer (m_renderCtx);
575 glu::RenderbufferVector renderbuffers (m_renderCtx, m_outputLayout.locationSymbols.size());
577 vector<glu::VertexArrayBinding> vertexArrays;
595 vertexArrays.push_back(glu::va::Float("a_position", 2, numValues, 0, (const float*)&positions[0]));
602 const glu::DataType basicType = symbol.varType.getBasicType();
603 const int vecSize = glu::getDataTypeScalarSize(basicType);
605 if (glu::isDataTypeFloatOrVec(basicType))
606 vertexArrays.push_back(glu::va::Float(attribName, vecSize, numValues, 0, (const float*)ptr));
607 else if (glu::isDataTypeIntOrIVec(basicType))
608 vertexArrays.push_back(glu::va::Int32(attribName, vecSize, numValues, 0, (const deInt32*)ptr));
609 else if (glu::isDataTypeUintOrUVec(basicType))
610 vertexArrays.push_back(glu::va::Uint32(attribName, vecSize, numValues, 0, (const deUint32*)ptr));
611 else if (glu::isDataTypeMatrix(basicType))
613 int numRows = glu::getDataTypeMatrixNumRows(basicType);
614 int numCols = glu::getDataTypeMatrixNumColumns(basicType);
618 vertexArrays.push_back(glu::va::Float(attribName, colNdx, numRows, numValues, stride, ((const float*)ptr) + colNdx * numRows));
631 const deUint32 format = glu::getInternalFormat(getRenderbufferFormatForOutput(output.varType, useIntOutputs));
651 glu::draw(m_renderCtx, this->getProgram(), (int)vertexArrays.size(), &vertexArrays[0],
652 glu::pr::Points(numValues));
665 const int outVecSize = glu::getDataTypeNumComponents(output.varType.getBasicType());
666 const int outNumLocs = glu::getDataTypeNumLocations(output.varType.getBasicType());
677 glu::readPixels(m_renderCtx, 0, 0, tmpBuf.getAccess());
704 VertexShaderExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec);
712 const glu::ShaderProgram m_program;
715 VertexShaderExecutor::VertexShaderExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec)
718 glu::ProgramSources() << glu::VertexSource(generateVertexShader(shaderSpec, "a_", "vtx_out_"))
719 << glu::FragmentSource(generatePassthroughFragmentShader(shaderSpec, !hasFloatRenderTargets(renderCtx), m_outputLayout.locationMap, "vtx_out_", "o_")))
732 static GeometryShaderExecutor* create (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec);
741 const glu::ShaderProgram m_program;
744 GeometryShaderExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec);
747 GeometryShaderExecutor* GeometryShaderExecutor::create (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec)
749 if (glu::glslVersionIsES(shaderSpec.version) && shaderSpec.version <= glu::GLSL_VERSION_310_ES
750 && !contextSupports(renderCtx.getType(), glu::ApiType::core(4, 5)))
756 GeometryShaderExecutor::GeometryShaderExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec)
759 glu::ProgramSources() << glu::VertexSource(generatePassthroughVertexShader(shaderSpec, "a_", "vtx_out_"))
760 << glu::GeometrySource(generateGeometryShader(shaderSpec, "vtx_out_", "geom_out_"))
761 << glu::FragmentSource(generatePassthroughFragmentShader(shaderSpec, !hasFloatRenderTargets(renderCtx), m_outputLayout.locationMap, "geom_out_", "o_")))
774 FragmentShaderExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec);
782 const glu::ShaderProgram m_program;
785 FragmentShaderExecutor::FragmentShaderExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec)
788 glu::ProgramSources() << glu::VertexSource(generatePassthroughVertexShader(shaderSpec, "a_", "vtx_out_"))
789 << glu::FragmentSource(generateFragmentShader(shaderSpec, !hasFloatRenderTargets(renderCtx), m_outputLayout.locationMap, "vtx_out_", "o_")))
799 static deUint32 getVecStd430ByteAlignment (glu::DataType type)
801 switch (glu::getDataTypeScalarSize(type))
816 BufferIoExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec, const glu::ProgramSources& sources);
842 glu::ShaderProgram m_program;
860 static void copyToBuffer (const glu::VarType& varType, const VarLayout& layout, int numValues, const void* srcBasePtr, void* dstBasePtr);
861 static void copyFromBuffer (const glu::VarType& varType, const VarLayout& layout, int numValues, const void* srcBasePtr, void* dstBasePtr);
863 glu::Buffer m_inputBuffer;
864 glu::Buffer m_outputBuffer;
870 BufferIoExecutor::BufferIoExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec, const glu::ProgramSources& sources)
922 const glu::DataType basicType = symbol.varType.getBasicType();
925 if (glu::isDataTypeScalarOrVector(basicType))
928 const deUint32 size = (deUint32)glu::getDataTypeScalarSize(basicType)*(int)sizeof(deUint32);
938 else if (glu::isDataTypeMatrix(basicType))
940 const int numVecs = glu::getDataTypeMatrixNumColumns(basicType);
941 const glu::DataType vecType = glu::getDataTypeFloatVec(glu::getDataTypeMatrixNumRows(basicType));
969 void BufferIoExecutor::copyToBuffer (const glu::VarType& varType, const VarLayout& layout, int numValues, const void* srcBasePtr, void* dstBasePtr)
973 const glu::DataType basicType = varType.getBasicType();
974 const bool isMatrix = glu::isDataTypeMatrix(basicType);
975 const int scalarSize = glu::getDataTypeScalarSize(basicType);
976 const int numVecs = isMatrix ? glu::getDataTypeMatrixNumColumns(basicType) : 1;
996 void BufferIoExecutor::copyFromBuffer (const glu::VarType& varType, const VarLayout& layout, int numValues, const void* srcBasePtr, void* dstBasePtr)
1000 const glu::DataType basicType = varType.getBasicType();
1001 const bool isMatrix = glu::isDataTypeMatrix(basicType);
1002 const int scalarSize = glu::getDataTypeScalarSize(basicType);
1003 const int numVecs = isMatrix ? glu::getDataTypeMatrixNumColumns(basicType) : 1;
1043 const glu::VarType& varType = m_inputs[inputNdx].varType;
1079 const glu::VarType& varType = m_outputs[outputNdx].varType;
1100 glu::StructType inputStruct("Inputs");
1103 src << glu::declare(&inputStruct) << ";\n";
1108 glu::StructType outputStruct("Outputs");
1111 src << glu::declare(&outputStruct) << ";\n";
1134 src << "\t" << glu::declare(symIter->varType, symIter->name) << " = inputs[" << invocationNdxName << "]." << symIter->name << ";\n";
1137 src << "\t" << glu::declare(symIter->varType, symIter->name) << ";\n";
1159 ComputeShaderExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec);
1174 src << glu::getGLSLVersionDeclaration(spec.version) << "\n";
1196 ComputeShaderExecutor::ComputeShaderExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec)
1198 glu::ProgramSources() << glu::ComputeSource(generateComputeShader(shaderSpec)))
1245 static std::string generateVertexShaderForTess (glu::GLSLVersion version)
1249 src << glu::getGLSLVersionDeclaration(version) << "\n";
1258 void checkTessSupport (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec, glu::ShaderType stage)
1262 if (glu::glslVersionIsES(shaderSpec.version) && shaderSpec.version <= glu::GLSL_VERSION_310_ES
1263 && !contextSupports(renderCtx.getType(), glu::ApiType::core(4, 5)))
1266 if (stage == glu::SHADERTYPE_TESSELLATION_CONTROL)
1268 else if (stage == glu::SHADERTYPE_TESSELLATION_EVALUATION)
1279 static TessControlExecutor* create (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec);
1290 TessControlExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec);
1293 TessControlExecutor* TessControlExecutor::create (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec)
1295 checkTessSupport(renderCtx, shaderSpec, glu::SHADERTYPE_TESSELLATION_CONTROL);
1304 src << glu::getGLSLVersionDeclaration(shaderSpec.version) << "\n";
1306 if (glu::glslVersionIsES(shaderSpec.version) && shaderSpec.version <= glu::GLSL_VERSION_310_ES)
1334 static std::string generateEmptyTessEvalShader (glu::GLSLVersion version)
1338 src << glu::getGLSLVersionDeclaration(version) << "\n";
1340 if (glu::glslVersionIsES(version) && version <= glu::GLSL_VERSION_310_ES)
1352 TessControlExecutor::TessControlExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec)
1353 : BufferIoExecutor (renderCtx, shaderSpec, glu::ProgramSources()
1354 << glu::VertexSource(generateVertexShaderForTess(shaderSpec.version))
1355 << glu::TessellationControlSource(generateTessControlShader(shaderSpec))
1356 << glu::TessellationEvaluationSource(generateEmptyTessEvalShader(shaderSpec.version))
1357 << glu::FragmentSource(generateEmptyFragmentSource(shaderSpec.version)))
1399 static TessEvaluationExecutor* create (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec);
1410 TessEvaluationExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec);
1413 TessEvaluationExecutor* TessEvaluationExecutor::create (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec)
1415 checkTessSupport(renderCtx, shaderSpec, glu::SHADERTYPE_TESSELLATION_EVALUATION);
1420 static std::string generatePassthroughTessControlShader (glu::GLSLVersion version)
1424 src << glu::getGLSLVersionDeclaration(version) << "\n";
1426 if (glu::glslVersionIsES(version) && version <= glu::GLSL_VERSION_310_ES)
1448 src << glu::getGLSLVersionDeclaration(shaderSpec.version) << "\n";
1450 if (glu::glslVersionIsES(shaderSpec.version) && shaderSpec.version <= glu::GLSL_VERSION_310_ES)
1473 TessEvaluationExecutor::TessEvaluationExecutor (const glu::RenderContext& renderCtx, const ShaderSpec& shaderSpec)
1474 : BufferIoExecutor (renderCtx, shaderSpec, glu::ProgramSources()
1475 << glu::VertexSource(generateVertexShaderForTess(shaderSpec.version))
1476 << glu::TessellationControlSource(generatePassthroughTessControlShader(shaderSpec.version))
1477 << glu::TessellationEvaluationSource(generateTessEvalShader(shaderSpec))
1478 << glu::FragmentSource(generateEmptyFragmentSource(shaderSpec.version)))
1521 ShaderExecutor* createExecutor (const glu::RenderContext& renderCtx, glu::ShaderType shaderType, const ShaderSpec& shaderSpec)
1525 case glu::SHADERTYPE_VERTEX: return new VertexShaderExecutor (renderCtx, shaderSpec);
1526 case glu::SHADERTYPE_TESSELLATION_CONTROL: return TessControlExecutor::create (renderCtx, shaderSpec);
1527 case glu::SHADERTYPE_TESSELLATION_EVALUATION: return TessEvaluationExecutor::create (renderCtx, shaderSpec);
1528 case glu::SHADERTYPE_GEOMETRY: return GeometryShaderExecutor::create (renderCtx, shaderSpec);
1529 case glu::SHADERTYPE_FRAGMENT: return new FragmentShaderExecutor (renderCtx, shaderSpec);
1530 case glu::SHADERTYPE_COMPUTE: return new ComputeShaderExecutor (renderCtx, shaderSpec);
1536 bool executorSupported(glu::ShaderType shaderType)
1540 case glu::SHADERTYPE_VERTEX:
1541 case glu::SHADERTYPE_TESSELLATION_CONTROL:
1542 case glu::SHADERTYPE_TESSELLATION_EVALUATION:
1543 case glu::SHADERTYPE_GEOMETRY:
1544 case glu::SHADERTYPE_FRAGMENT:
1545 case glu::SHADERTYPE_COMPUTE: