35 #ifndef GLSLANG_GTESTS_TEST_FIXTURE_H 36 #define GLSLANG_GTESTS_TEST_FIXTURE_H 45 #include <gtest/gtest.h> 63 const ::testing::TestParamInfo<std::string>&
info);
107 template <
typename GT>
123 ASSERT_TRUE(fileReadOk) <<
"Cannot open " <<
tag <<
" file: " <<
path;
129 std::vector<uint32_t>& contents)
133 ASSERT_TRUE(fileReadOk) <<
"Cannot open " <<
tag <<
" file: " <<
path;
144 EXPECT_EQ(expected, real)
146 ? (
"Mismatch found and update mode turned on - " 147 "flushing expected result output.")
182 const char* shaderStrings =
code.data();
183 const int shaderLengths =
static_cast<int>(
code.size());
185 shader->setStringsWithLengths(&shaderStrings, &shaderLengths, 1);
201 bool flattenUniformArrays =
false,
203 bool enableOptimizer =
false,
210 shader.setAutoMapLocations(
true);
211 shader.setAutoMapBindings(
true);
213 shader.setTextureSamplerTransformMode(texSampTransMode);
214 shader.setFlattenUniformArrays(flattenUniformArrays);
243 std::vector<uint32_t> spirv_binary;
245 options.disableOptimizer = !enableOptimizer;
249 std::ostringstream disassembly_stream;
252 return {{{shaderName,
shader.getInfoLog(),
shader.getInfoDebugLog()},},
254 logger.getAllMessages(), disassembly_stream.str()};
256 return {{{shaderName,
shader.getInfoLog(),
shader.getInfoDebugLog()},},
275 bool flattenUniformArrays)
286 shader.setAutoMapLocations(
true);
287 shader.setFlattenUniformArrays(flattenUniformArrays);
300 std::vector<uint32_t> spirv_binary;
304 std::ostringstream disassembly_stream;
307 return {{{shaderName,
shader.getInfoLog(),
shader.getInfoDebugLog()},},
309 logger.getAllMessages(), disassembly_stream.str()};
311 return {{{shaderName,
shader.getInfoLog(),
shader.getInfoDebugLog()},},
328 shader.setAutoMapBindings(
true);
329 shader.setAutoMapLocations(
true);
340 std::vector<uint32_t> spirv_binary;
346 std::ostringstream disassembly_stream;
349 return {{{shaderName,
shader.getInfoLog(),
shader.getInfoDebugLog()},},
351 logger.getAllMessages(), disassembly_stream.str()};
353 return {{{shaderName,
shader.getInfoLog(),
shader.getInfoDebugLog()},},
365 std::vector<uint32_t> spirv_binary(
code);
369 std::ostringstream disassembly_stream;
373 return {{{shaderName,
"",
""},},
375 "", disassembly_stream.str()};
377 return {{{shaderName,
"",
""},},
"",
"",
"",
""};
389 for (
const auto& shaderResult :
result.shaderResults) {
390 *
stream << shaderResult.shaderName <<
"\n";
391 outputIfNotEmpty(shaderResult.output);
392 outputIfNotEmpty(shaderResult.error);
394 outputIfNotEmpty(
result.linkingOutput);
395 outputIfNotEmpty(
result.linkingError);
401 ?
"SPIR-V is not generated for failed compile or link\n" 415 const bool enableOptimizer =
false)
417 const std::string inputFname = testDir +
"/" + testName;
419 testDir + baseDir + testName +
".out";
423 tryLoadFile(expectedOutputFname,
"expected output", &expectedOutput);
432 std::ostringstream
stream;
436 expectedOutputFname);
446 const std::string inputFname = testDir +
"/" + testName;
448 testDir +
"/baseResults/" + testName +
".out";
452 tryLoadFile(expectedOutputFname,
"expected output", &expectedOutput);
459 std::ostringstream
stream;
463 expectedOutputFname);
478 bool flattenUniformArrays)
480 const std::string inputFname = testDir +
"/" + testName;
482 testDir +
"/baseResults/" + testName +
".out";
486 tryLoadFile(expectedOutputFname,
"expected output", &expectedOutput);
493 flattenUniformArrays);
496 std::ostringstream
stream;
500 expectedOutputFname);
511 const std::string inputFname = testDir +
"/" + testName;
513 testDir +
"/baseResults/" + testName +
".out";
517 tryLoadFile(expectedOutputFname,
"expected output", &expectedOutput);
523 std::ostringstream
stream;
527 expectedOutputFname);
537 const std::string inputFname = testDir +
"/" + testName;
539 testDir +
"/baseResults/" + testName +
".out";
540 std::vector<std::uint32_t>
input;
544 tryLoadFile(expectedOutputFname,
"expected output", &expectedOutput);
550 std::ostringstream
stream;
554 expectedOutputFname);
563 const char* shaderStrings =
source.data();
564 const int shaderLengths =
static_cast<int>(
source.size());
567 shader.setStringsWithLengths(&shaderStrings, &shaderLengths, 1);
573 &ppShader, includer);
578 return std::make_tuple(
true, ppShader,
log);
580 return std::make_tuple(
false,
"",
log);
587 const std::string inputFname = testDir +
"/" + testName;
589 testDir +
"/baseResults/" + testName +
".out";
591 testDir +
"/baseResults/" + testName +
".err";
595 tryLoadFile(expectedOutputFname,
"expected output", &expectedOutput);
596 tryLoadFile(expectedErrorFname,
"expected error", &expectedError);
605 expectedOutputFname);
617 const std::string inputFname = testDir +
"/" + testName;
618 const std::string expectedOutputFname = testDir +
"/baseResults/" + testName +
".out";
622 tryLoadFile(expectedOutputFname,
"expected output", &expectedOutput);
630 std::ostringstream
stream;
634 expectedOutputFname);
646 #endif // GLSLANG_GTESTS_TEST_FIXTURE_H Definition: ShaderLang.h:127
GLuint shader
Definition: glext.h:6670
bool compile(glslang::TShader *shader, const std::string &code, const std::string &entryPointName, EShMessages controls, const TBuiltInResource *resources=nullptr)
Definition: TestFixture.h:178
EShTargetClientVersion
Definition: ShaderLang.h:131
void Parameterize()
Definition: doc.cpp:1246
GLuint const GLchar * name
Definition: glext.h:6671
bool updateMode
Definition: Settings.h:49
Definition: Versions.h:53
const int defaultVersion
Definition: TestFixture.h:638
EShTextureSamplerTransformMode
Definition: ShaderLang.h:196
static const unsigned char tag[MAX_TESTS *3][16]
Definition: gcm.c:696
int baseTextureBinding
Definition: Spv.FromFile.cpp:48
std::string error
Definition: TestFixture.h:162
std::string FileNameAsCustomTestSuffix(const ::testing::TestParamInfo< std::string > &info)
Definition: TestFixture.cpp:39
EShLanguage
Definition: ShaderLang.h:90
Definition: TestFixture.h:108
GlslangResult compileLinkRemap(const std::string shaderName, const std::string &code, const std::string &entryPointName, EShMessages controls, const unsigned int remapOptions=spv::spirvbin_t::NONE)
Definition: TestFixture.h:320
bool autoMapBindings
Definition: Spv.FromFile.cpp:52
std::string spirvWarningsErrors
Definition: TestFixture.h:171
Definition: libretro.h:2275
GLsizei const GLchar ** path
Definition: glext.h:7901
GlslangTest()
Definition: TestFixture.h:110
bool WriteFile(const std::string &path, const std::string &contents)
Definition: TestFixture.cpp:149
void loadFileCompileFlattenUniformsAndCheck(const std::string &testDir, const std::string &testName, Source source, Semantics semantics, Target target, const std::string &entryPointName="")
Definition: TestFixture.h:439
Definition: ShaderLang.h:140
EShMessages DeriveOptions(Source source, Semantics semantics, Target target)
Definition: TestFixture.cpp:69
int baseSamplerBinding
Definition: Spv.FromFile.cpp:47
Definition: ShaderLang.h:133
Definition: TestFixture.h:167
Definition: ResourceLimits.h:52
Target
Definition: TestFixture.h:77
void loadFilePreprocessAndCheck(const std::string &testDir, const std::string &testName)
Definition: TestFixture.h:584
GLsizei const GLchar *const * string
Definition: glext.h:6699
void loadFileCompileIoMapAndCheck(const std::string &testDir, const std::string &testName, Source source, Semantics semantics, Target target, const std::string &entryPointName, int baseSamplerBinding, int baseTextureBinding, int baseImageBinding, int baseUboBinding, int baseSsboBinding, bool autoMapBindings, bool flattenUniformArrays)
Definition: TestFixture.h:466
Definition: ShaderLang.h:197
const bool isForwardCompatible
Definition: TestFixture.h:641
Definition: ShaderLang.h:508
GLenum GLenum GLenum input
Definition: glext.h:9938
bool success(size_t len)
Definition: peglib.h:475
std::pair< bool, std::vector< std::uint32_t > > ReadSpvBinaryFile(const std::string &path)
Definition: TestFixture.cpp:123
Definition: ShaderLang.h:374
Source
Definition: TestFixture.h:65
std::string linkingError
Definition: TestFixture.h:170
std::pair< bool, std::string > ReadFile(const std::string &path)
Definition: TestFixture.cpp:108
Definition: TestFixture.h:159
int baseImageBinding
Definition: Spv.FromFile.cpp:49
GlslangResult remap(const std::string shaderName, const std::vector< uint32_t > &code, EShMessages controls, const unsigned int remapOptions=spv::spirvbin_t::NONE)
Definition: TestFixture.h:359
GlslangResult compileAndLink(const std::string shaderName, const std::string &code, const std::string &entryPointName, EShMessages controls, glslang::EShTargetClientVersion clientTargetVersion, bool flattenUniformArrays=false, EShTextureSamplerTransformMode texSampTransMode=EShTexSampTransKeep, bool enableOptimizer=false, bool automap=true)
Definition: TestFixture.h:197
#define log(...)
Definition: spirv_cross.cpp:28
Definition: ShaderLang.h:122
GLuint program
Definition: glext.h:7390
EProfile
Definition: Versions.h:51
void tryLoadFile(const std::string &path, const std::string &tag, std::string *contents)
Definition: TestFixture.h:118
void loadFileCompileRemapAndCheck(const std::string &testDir, const std::string &testName, Source source, Semantics semantics, Target target, const std::string &entryPointName="", const unsigned int remapOptions=spv::spirvbin_t::NONE)
Definition: TestFixture.h:503
const EProfile defaultProfile
Definition: TestFixture.h:639
void loadFileRemapAndCheck(const std::string &testDir, const std::string &testName, Source source, Semantics semantics, Target target, const unsigned int remapOptions=spv::spirvbin_t::NONE)
Definition: TestFixture.h:530
void outputResultToStream(std::ostringstream *stream, const GlslangResult &result, EShMessages controls)
Definition: TestFixture.h:381
static struct retro_log_callback logger
Definition: net_retropad_core.c:76
const char * entryPointName
Definition: StandAlone.cpp:156
EShMessages controls
Definition: Config.FromFile.cpp:45
Definition: ShaderLang.h:115
GTestSettings GlobalTestSettings
Definition: Settings.cpp:49
static l_noret error(LoadState *S, const char *why)
Definition: lundump.c:39
GLuint64EXT * result
Definition: glext.h:12211
Definition: GlslangToSpv.h:50
std::string shaderName
Definition: TestFixture.h:160
Definition: inftrees.h:27
Definition: ShaderLang.h:212
Definition: SPVRemapper.h:56
void checkEqAndUpdateIfRequested(const std::string &expected, const std::string &real, const std::string &fname)
Definition: TestFixture.h:138
void tryLoadSpvFile(const std::string &path, const std::string &tag, std::vector< uint32_t > &contents)
Definition: TestFixture.h:128
Definition: ShaderLang.h:116
Definition: ShaderLang.h:211
GLsizei GLsizei GLchar * source
Definition: glext.h:6688
Definition: AST.FromFile.cpp:39
void GlslangToSpv(const glslang::TIntermediate &intermediate, std::vector< unsigned int > &spirv, SpvOptions *options)
Definition: GlslangToSpv.cpp:6942
std::string output
Definition: Config.FromFile.cpp:44
GlslangResult compileLinkIoMap(const std::string shaderName, const std::string &code, const std::string &entryPointName, EShMessages controls, int baseSamplerBinding, int baseTextureBinding, int baseImageBinding, int baseUboBinding, int baseSsboBinding, bool autoMapBindings, bool flattenUniformArrays)
Definition: TestFixture.h:266
GLuint GLuint stream
Definition: glext.h:8189
std::tuple< bool, std::string, std::string > preprocess(const std::string &source)
Definition: TestFixture.h:560
int baseUboBinding
Definition: Spv.FromFile.cpp:50
Definition: ShaderLang.h:141
int baseSsboBinding
Definition: Spv.FromFile.cpp:51
std::string linkingOutput
Definition: TestFixture.h:169
Definition: ShaderLang.h:218
Definition: ffmpeg_fft.c:36
Definition: ShaderLang.h:198
Semantics
Definition: TestFixture.h:71
void loadFileCompileAndCheck(const std::string &testDir, const std::string &testName, Source source, Semantics semantics, glslang::EShTargetClientVersion clientTargetVersion, Target target, bool automap=true, const std::string &entryPointName="", const std::string &baseDir="/baseResults/", const bool enableOptimizer=false)
Definition: TestFixture.h:406
void remap(std::vector< std::uint32_t > &, unsigned int)
Definition: SPVRemapper.h:87
EShLanguage GetShaderStage(const std::string &stage)
Definition: TestFixture.cpp:49
const bool forceVersionProfile
Definition: TestFixture.h:640
std::vector< ShaderResult > shaderResults
Definition: TestFixture.h:168
std::string output
Definition: TestFixture.h:161
std::string spirv
Definition: TestFixture.h:172
Definition: ShaderLang.h:209
#define false
Definition: ordinals.h:83
EShMessages
Definition: ShaderLang.h:204
void loadCompileUpgradeTextureToSampledTextureAndDropSamplersAndCheck(const std::string &testDir, const std::string &testName, Source source, Semantics semantics, Target target, const std::string &entryPointName="")
Definition: TestFixture.h:610
Definition: SPVRemapper.h:82
Definition: ShaderLang.h:132
std::string GetSuffix(const std::string &name)
Definition: TestFixture.cpp:158
Definition: ShaderLang.h:213
Definition: ShaderLang.h:91
Definition: ShaderLang.h:210
const TBuiltInResource DefaultTBuiltInResource
Definition: ResourceLimits.cpp:44
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld fname[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld_src SRC pixld MASK if DST_R else pixld DST_R endif if src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head if pixblock_size cache_preload_simple endif process_pixblock_tail pixinterleave dst_w_basereg irp if pixblock_size chunk_size tst beq if DST_W else pixst DST_W else mov ORIG_W endif add lsl if lsl endif if lsl endif lsl endif lsl endif lsl endif subs mov DST_W if regs_shortage str endif bge start_of_loop_label endm macro generate_composite_function
Definition: pixman-arm-neon-asm.h:600
Definition: ShaderLang.h:128
Definition: ShaderLang.h:652
Definition: ShaderLang.h:121
bf_uint8_t options
Definition: connect_ps4.c:78
const char *const str
Definition: portlistingparse.c:18
void Disassemble(std::ostream &out, const std::vector< unsigned int > &stream)
Definition: disassemble.cpp:710