Lines Matching defs:optimized
21 * \brief Optimized vs unoptimized shader performance tests.
189 virtual ProgramData generateProgramData (bool optimized) const = 0;
205 ProgramData& programData (bool optimized) { return optimized ? m_optimizedData : m_unoptimizedData; }
206 SharedPtr<const ShaderProgram>& program (bool optimized) { return optimized ? m_optimizedProgram : m_unoptimizedProgram; }
207 ShaderPerformanceMeasurer::Result& result (bool optimized) { return optimized ? m_optimizedResult : m_unoptimizedResult; }
229 const bool optimized = ndx == 1;
231 programData(optimized) = generateProgramData(optimized);
233 for (int i = 0; i < (int)programData(optimized).attributes.size(); i++)
234 DE_ASSERT(programData(optimized).attributes[i].name != "a_position"); // \note Position attribute is set by m_measurer.
236 program(optimized) = SharedPtr<const ShaderProgram>(new ShaderProgram(renderCtx, programData(optimized).sources));
239 const tcu::ScopedLogSection section(log, optimized ? "OptimizedProgram" : "UnoptimizedProgram",
240 optimized ? "Hand-optimized program" : "Unoptimized program");
241 log << *program(optimized);
244 if (!program(optimized)->isOk())
257 const bool optimized = m_state == STATE_INIT_OPTIMIZED;
258 m_measurer.init(program(optimized)->getProgram(), programData(optimized).attributes, 1);
259 m_state = optimized ? STATE_MEASURE_OPTIMIZED : STATE_MEASURE_UNOPTIMIZED;
269 const bool optimized = m_state == STATE_MEASURE_OPTIMIZED;
270 const tcu::ScopedLogSection section (log, optimized ? "OptimizedResult" : "UnoptimizedResult",
271 optimized ? "Measurement results for hand-optimized program" : "Measurement result for unoptimized program");
273 result(optimized) = m_measurer.getResult();
275 m_state = optimized ? STATE_FINISHED : STATE_INIT_OPTIMIZED;
290 log << TestLog::Message << "Unoptimized / optimized " << relevantResultName << " performance ratio: " << ratio << TestLog::EndMessage;
293 log << TestLog::Message << "Note: " << handOptimizationGain << "% performance gain was achieved with hand-optimized version" << TestLog::EndMessage;
322 ProgramData generateProgramData (bool optimized) const
324 const string repetition = optimized ? repeatIndexedTemplate("\t" + expressionTemplate(m_caseType) + ";\n", m_numRepetitions)
362 ProgramData generateProgramData (bool optimized) const
370 const string statements = optimized ? " " + precision + " vec4 valueOrig = value;\n"
405 ProgramData generateProgramData (bool optimized) const
409 const string maybeFuncDefs = optimized ? "" : funcDefinitions(m_callNestingDepth, precision, expression);
410 const string mainValueStatement = (optimized ? "\tvalue = " + expression : "\tvalue = func" + toString(m_callNestingDepth-1) + "(value)") + ";\n";
449 ProgramData generateProgramData (bool optimized) const
453 const string statements = m_caseType == CASETYPE_BUILT_IN_FUNCTIONS ? builtinFunctionsCaseStatements (optimized, m_useConstantExpressionsOnly, precision, isVertexCase)
454 : m_caseType == CASETYPE_ARRAY ? arrayCaseStatements (optimized, m_useConstantExpressionsOnly, precision, isVertexCase)
455 : m_caseType == CASETYPE_STRUCT ? structCaseStatements (optimized, m_useConstantExpressionsOnly, precision, isVertexCase)
465 static inline string builtinFunctionsCaseStatements (bool optimized, bool constantExpressionsOnly, const string& precision, bool useHeavierWorkload)
470 return optimized
482 static inline string arrayCaseStatements (bool optimized, bool constantExpressionsOnly, const string& precision, bool useHeavierWorkload)
487 return optimized ? " value = vec4(0.4, 0.5, 0.6, 0.7) * value; // NOTE: factor doesn't necessarily match the one in unoptimized shader, but shouldn't make a difference performance-wise\n"
510 static inline string structCaseStatements (bool optimized, bool constantExpressionsOnly, const string& precision, bool useHeavierWorkload)
515 return optimized ? " value = vec4(0.4, 0.5, 0.6, 0.7) * value; // NOTE: factor doesn't necessarily match the one in unoptimized shader, but shouldn't make a difference performance-wise\n"
558 ProgramData generateProgramData (bool optimized) const
562 const string statements = m_caseType == CASETYPE_SINGLE_STATEMENT ? singleStatementCaseStatements (optimized, precision, isVertexCase)
563 : m_caseType == CASETYPE_MULTIPLE_STATEMENTS ? multipleStatementsCaseStatements (optimized, precision, isVertexCase)
564 : m_caseType == CASETYPE_STATIC_BRANCH ? staticBranchCaseStatements (optimized, precision, isVertexCase)
565 : m_caseType == CASETYPE_LOOP ? loopCaseStatements (optimized, precision, isVertexCase)
574 static inline string singleStatementCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
578 return optimized ? " " + precision + " vec4 s = sin(value);\n"
586 static inline string multipleStatementsCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
591 return optimized ? " " + precision + " vec4 a = sin(value) + cos(exp(value));\n"
606 static inline string staticBranchCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
611 if (optimized)
650 static inline string loopCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
654 return optimized ? " " + precision + " vec4 acc = value;\n"
699 ProgramData generateProgramData (bool optimized) const
703 const string funcDefs = m_caseType == CASETYPE_DEAD_BRANCH_FUNC_CALL ? deadBranchFuncCallCaseFuncDefs (optimized, precision)
704 : m_caseType == CASETYPE_UNUSED_VALUE_AFTER_RETURN ? unusedValueAfterReturnCaseFuncDefs (optimized, precision, isVertexCase)
707 const string statements = m_caseType == CASETYPE_DEAD_BRANCH_SIMPLE ? deadBranchSimpleCaseStatements (optimized, isVertexCase)
708 : m_caseType == CASETYPE_DEAD_BRANCH_COMPLEX ? deadBranchComplexCaseStatements (optimized, precision, true, isVertexCase)
709 : m_caseType == CASETYPE_DEAD_BRANCH_COMPLEX_NO_CONST ? deadBranchComplexCaseStatements (optimized, precision, false, isVertexCase)
710 : m_caseType == CASETYPE_DEAD_BRANCH_FUNC_CALL ? deadBranchFuncCallCaseStatements (optimized, isVertexCase)
711 : m_caseType == CASETYPE_UNUSED_VALUE_BASIC ? unusedValueBasicCaseStatements (optimized, precision, isVertexCase)
712 : m_caseType == CASETYPE_UNUSED_VALUE_LOOP ? unusedValueLoopCaseStatements (optimized, precision, isVertexCase)
713 : m_caseType == CASETYPE_UNUSED_VALUE_DEAD_BRANCH ? unusedValueDeadBranchCaseStatements (optimized, precision, isVertexCase)
715 : m_caseType == CASETYPE_UNUSED_VALUE_MUL_ZERO ? unusedValueMulZeroCaseStatements (optimized, precision, isVertexCase)
724 static inline string deadBranchSimpleCaseStatements (bool optimized, bool useHeavierWorkload)
728 return optimized ? " value = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
739 static inline string deadBranchComplexCaseStatements (bool optimized, const string& precision, bool useConst, bool useHeavierWorkload)
744 return optimized ? " value = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
760 static inline string deadBranchFuncCallCaseFuncDefs (bool optimized, const string& precision)
762 return optimized ? "" : precision + " float func (" + precision + " float x) { return 2.0*x; }\n";
765 static inline string deadBranchFuncCallCaseStatements (bool optimized, bool useHeavierWorkload)
769 return optimized ? " value = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
780 static inline string unusedValueBasicCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
784 return optimized ? " " + precision + " vec4 used = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
793 static inline string unusedValueLoopCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
797 return optimized ? " " + precision + " vec4 used = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
807 static inline string unusedValueAfterReturnCaseFuncDefs (bool optimized, const string& precision, bool useHeavierWorkload)
811 return optimized ? precision + " vec4 func (" + precision + " vec4 v)\n"
833 static inline string unusedValueDeadBranchCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
837 return optimized ? " " + precision + " vec4 used = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
848 static inline string unusedValueMulZeroCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
852 return optimized ? " " + precision + " vec4 used = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"