Lines Matching defs:optimized
21 * \brief Optimized vs unoptimized shader performance tests.
186 virtual ProgramData generateProgramData (bool optimized) const = 0;
202 ProgramData& programData (bool optimized) { return optimized ? m_optimizedData : m_unoptimizedData; }
203 SharedPtr<const ShaderProgram>& program (bool optimized) { return optimized ? m_optimizedProgram : m_unoptimizedProgram; }
204 ShaderPerformanceMeasurer::Result& result (bool optimized) { return optimized ? m_optimizedResult : m_unoptimizedResult; }
226 const bool optimized = ndx == 1;
228 programData(optimized) = generateProgramData(optimized);
230 for (int i = 0; i < (int)programData(optimized).attributes.size(); i++)
231 DE_ASSERT(programData(optimized).attributes[i].name != "a_position"); // \note Position attribute is set by m_measurer.
233 program(optimized) = SharedPtr<const ShaderProgram>(new ShaderProgram(renderCtx, programData(optimized).sources));
236 const tcu::ScopedLogSection section(log, optimized ? "OptimizedProgram" : "UnoptimizedProgram",
237 optimized ? "Hand-optimized program" : "Unoptimized program");
238 log << *program(optimized);
241 if (!program(optimized)->isOk())
254 const bool optimized = m_state == STATE_INIT_OPTIMIZED;
255 m_measurer.init(program(optimized)->getProgram(), programData(optimized).attributes, 1);
256 m_state = optimized ? STATE_MEASURE_OPTIMIZED : STATE_MEASURE_UNOPTIMIZED;
266 const bool optimized = m_state == STATE_MEASURE_OPTIMIZED;
267 const tcu::ScopedLogSection section (log, optimized ? "OptimizedResult" : "UnoptimizedResult",
268 optimized ? "Measurement results for hand-optimized program" : "Measurement result for unoptimized program");
270 result(optimized) = m_measurer.getResult();
272 m_state = optimized ? STATE_FINISHED : STATE_INIT_OPTIMIZED;
287 log << TestLog::Message << "Unoptimized / optimized " << relevantResultName << " performance ratio: " << ratio << TestLog::EndMessage;
290 log << TestLog::Message << "Note: " << handOptimizationGain << "% performance gain was achieved with hand-optimized version" << TestLog::EndMessage;
319 ProgramData generateProgramData (bool optimized) const
321 const string repetition = optimized ? repeatIndexedTemplate("\t" + expressionTemplate(m_caseType) + ";\n", m_numRepetitions)
359 ProgramData generateProgramData (bool optimized) const
367 const string statements = optimized ? " " + precision + " vec4 valueOrig = value;\n"
402 ProgramData generateProgramData (bool optimized) const
406 const string maybeFuncDefs = optimized ? "" : funcDefinitions(m_callNestingDepth, precision, expression);
407 const string mainValueStatement = (optimized ? "\tvalue = " + expression : "\tvalue = func" + toString(m_callNestingDepth-1) + "(value)") + ";\n";
447 ProgramData generateProgramData (bool optimized) const
451 const string statements = m_caseType == CASETYPE_BUILT_IN_FUNCTIONS ? builtinFunctionsCaseStatements (optimized, m_useConstantExpressionsOnly, precision, isVertexCase)
452 : m_caseType == CASETYPE_ARRAY ? arrayCaseStatements (optimized, precision, isVertexCase)
453 : m_caseType == CASETYPE_STRUCT ? structCaseStatements (optimized, m_useConstantExpressionsOnly, precision, isVertexCase)
463 static inline string builtinFunctionsCaseStatements (bool optimized, bool constantExpressionsOnly, const string& precision, bool useHeavierWorkload)
468 return optimized
480 static inline string arrayCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
484 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"
499 static inline string structCaseStatements (bool optimized, bool constantExpressionsOnly, const string& precision, bool useHeavierWorkload)
504 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"
547 ProgramData generateProgramData (bool optimized) const
551 const string statements = m_caseType == CASETYPE_SINGLE_STATEMENT ? singleStatementCaseStatements (optimized, precision, isVertexCase)
552 : m_caseType == CASETYPE_MULTIPLE_STATEMENTS ? multipleStatementsCaseStatements (optimized, precision, isVertexCase)
553 : m_caseType == CASETYPE_STATIC_BRANCH ? staticBranchCaseStatements (optimized, precision, isVertexCase)
554 : m_caseType == CASETYPE_LOOP ? loopCaseStatements (optimized, precision, isVertexCase)
563 static inline string singleStatementCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
567 return optimized ? " " + precision + " vec4 s = sin(value);\n"
575 static inline string multipleStatementsCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
580 return optimized ? " " + precision + " vec4 a = sin(value) + cos(exp(value));\n"
595 static inline string staticBranchCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
600 if (optimized)
639 static inline string loopCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
643 return optimized ? " " + precision + " vec4 acc = value;\n"
688 ProgramData generateProgramData (bool optimized) const
692 const string funcDefs = m_caseType == CASETYPE_DEAD_BRANCH_FUNC_CALL ? deadBranchFuncCallCaseFuncDefs (optimized, precision)
693 : m_caseType == CASETYPE_UNUSED_VALUE_AFTER_RETURN ? unusedValueAfterReturnCaseFuncDefs (optimized, precision, isVertexCase)
696 const string statements = m_caseType == CASETYPE_DEAD_BRANCH_SIMPLE ? deadBranchSimpleCaseStatements (optimized, isVertexCase)
697 : m_caseType == CASETYPE_DEAD_BRANCH_COMPLEX ? deadBranchComplexCaseStatements (optimized, precision, true, isVertexCase)
698 : m_caseType == CASETYPE_DEAD_BRANCH_COMPLEX_NO_CONST ? deadBranchComplexCaseStatements (optimized, precision, false, isVertexCase)
699 : m_caseType == CASETYPE_DEAD_BRANCH_FUNC_CALL ? deadBranchFuncCallCaseStatements (optimized, isVertexCase)
700 : m_caseType == CASETYPE_UNUSED_VALUE_BASIC ? unusedValueBasicCaseStatements (optimized, precision, isVertexCase)
701 : m_caseType == CASETYPE_UNUSED_VALUE_LOOP ? unusedValueLoopCaseStatements (optimized, precision, isVertexCase)
702 : m_caseType == CASETYPE_UNUSED_VALUE_DEAD_BRANCH ? unusedValueDeadBranchCaseStatements (optimized, precision, isVertexCase)
704 : m_caseType == CASETYPE_UNUSED_VALUE_MUL_ZERO ? unusedValueMulZeroCaseStatements (optimized, precision, isVertexCase)
713 static inline string deadBranchSimpleCaseStatements (bool optimized, bool useHeavierWorkload)
717 return optimized ? " value = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
728 static inline string deadBranchComplexCaseStatements (bool optimized, const string& precision, bool useConst, bool useHeavierWorkload)
733 return optimized ? " value = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
749 static inline string deadBranchFuncCallCaseFuncDefs (bool optimized, const string& precision)
751 return optimized ? "" : precision + " float func (" + precision + " float x) { return 2.0*x; }\n";
754 static inline string deadBranchFuncCallCaseStatements (bool optimized, bool useHeavierWorkload)
758 return optimized ? " value = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
769 static inline string unusedValueBasicCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
773 return optimized ? " " + precision + " vec4 used = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
782 static inline string unusedValueLoopCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
786 return optimized ? " " + precision + " vec4 used = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
796 static inline string unusedValueAfterReturnCaseFuncDefs (bool optimized, const string& precision, bool useHeavierWorkload)
800 return optimized ? precision + " vec4 func (" + precision + " vec4 v)\n"
822 static inline string unusedValueDeadBranchCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
826 return optimized ? " " + precision + " vec4 used = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"
837 static inline string unusedValueMulZeroCaseStatements (bool optimized, const string& precision, bool useHeavierWorkload)
841 return optimized ? " " + precision + " vec4 used = vec4(0.6, 0.7, 0.8, 0.9) * value;\n"