RetroArch
TestFixture.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2016 Google, Inc.
3 //
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
8 // are met:
9 //
10 // Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following
15 // disclaimer in the documentation and/or other materials provided
16 // with the distribution.
17 //
18 // Neither the name of Google Inc. nor the names of its
19 // contributors may be used to endorse or promote products derived
20 // from this software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 // POSSIBILITY OF SUCH DAMAGE.
34 
35 #ifndef GLSLANG_GTESTS_TEST_FIXTURE_H
36 #define GLSLANG_GTESTS_TEST_FIXTURE_H
37 
38 #include <cstdint>
39 #include <fstream>
40 #include <sstream>
41 #include <streambuf>
42 #include <tuple>
43 #include <string>
44 
45 #include <gtest/gtest.h>
46 
47 #include "SPIRV/GlslangToSpv.h"
48 #include "SPIRV/disassemble.h"
49 #include "SPIRV/doc.h"
50 #include "SPIRV/SPVRemapper.h"
53 
54 #include "Initializer.h"
55 #include "Settings.h"
56 
57 namespace glslangtest {
58 
59 // This function is used to provide custom test name suffixes based on the
60 // shader source file names. Otherwise, the test name suffixes will just be
61 // numbers, which are not quite obvious.
63  const ::testing::TestParamInfo<std::string>& info);
64 
65 enum class Source {
66  GLSL,
67  HLSL,
68 };
69 
70 // Enum for shader compilation semantics.
71 enum class Semantics {
72  OpenGL,
73  Vulkan
74 };
75 
76 // Enum for compilation target.
77 enum class Target {
78  AST,
79  Spv,
81 };
82 
84 
86 
87 // Reads the content of the file at the given |path|. On success, returns true
88 // and the contents; otherwise, returns false and an empty string.
89 std::pair<bool, std::string> ReadFile(const std::string& path);
90 std::pair<bool, std::vector<std::uint32_t> > ReadSpvBinaryFile(const std::string& path);
91 
92 // Writes the given |contents| into the file at the given |path|. Returns true
93 // on successful output.
94 bool WriteFile(const std::string& path, const std::string& contents);
95 
96 // Returns the suffix of the given |name|.
98 
99 // Base class for glslang integration tests. It contains many handy utility-like
100 // methods such as reading shader source files, compiling into AST/SPIR-V, and
101 // comparing with expected outputs.
102 //
103 // To write value-Parameterized tests:
104 // using ValueParamTest = GlslangTest<::testing::TestWithParam<std::string>>;
105 // To use as normal fixture:
106 // using FixtureTest = GlslangTest<::testing::Test>;
107 template <typename GT>
108 class GlslangTest : public GT {
109 public:
111  : defaultVersion(100),
115 
116  // Tries to load the contents from the file at the given |path|. On success,
117  // writes the contents into |contents|. On failure, errors out.
119  std::string* contents)
120  {
121  bool fileReadOk;
122  std::tie(fileReadOk, *contents) = ReadFile(path);
123  ASSERT_TRUE(fileReadOk) << "Cannot open " << tag << " file: " << path;
124  }
125 
126  // Tries to load the contents from the file at the given |path|. On success,
127  // writes the contents into |contents|. On failure, errors out.
129  std::vector<uint32_t>& contents)
130  {
131  bool fileReadOk;
132  std::tie(fileReadOk, contents) = ReadSpvBinaryFile(path);
133  ASSERT_TRUE(fileReadOk) << "Cannot open " << tag << " file: " << path;
134  }
135 
136  // Checks the equality of |expected| and |real|. If they are not equal,
137  // write |real| to the given file named as |fname| if update mode is on.
139  const std::string& real,
140  const std::string& fname)
141  {
142  // In order to output the message we want under proper circumstances,
143  // we need the following operator<< stuff.
144  EXPECT_EQ(expected, real)
146  ? ("Mismatch found and update mode turned on - "
147  "flushing expected result output.")
148  : "");
149 
150  // Update the expected output file if requested.
151  // It looks weird to duplicate the comparison between expected_output
152  // and stream.str(). However, if creating a variable for the comparison
153  // result, we cannot have pretty print of the string diff in the above.
154  if (GlobalTestSettings.updateMode && expected != real) {
155  EXPECT_TRUE(WriteFile(fname, real)) << "Flushing failed";
156  }
157  }
158 
159  struct ShaderResult {
163  };
164 
165  // A struct for holding all the information returned by glslang compilation
166  // and linking.
167  struct GlslangResult {
168  std::vector<ShaderResult> shaderResults;
172  std::string spirv; // Optional SPIR-V disassembly text.
173  };
174 
175  // Compiles and the given source |code| of the given shader |stage| into
176  // the target under the semantics conveyed via |controls|. Returns true
177  // and modifies |shader| on success.
180  const TBuiltInResource* resources=nullptr)
181  {
182  const char* shaderStrings = code.data();
183  const int shaderLengths = static_cast<int>(code.size());
184 
185  shader->setStringsWithLengths(&shaderStrings, &shaderLengths, 1);
186  if (!entryPointName.empty()) shader->setEntryPoint(entryPointName.c_str());
187  return shader->parse(
188  (resources ? resources : &glslang::DefaultTBuiltInResource),
190  }
191 
192  // Compiles and links the given source |code| of the given shader
193  // |stage| into the target under the semantics specified via |controls|.
194  // Returns a GlslangResult instance containing all the information generated
195  // during the process. If the target includes SPIR-V, also disassembles
196  // the result and returns disassembly text.
198  const std::string shaderName, const std::string& code,
200  glslang::EShTargetClientVersion clientTargetVersion,
201  bool flattenUniformArrays = false,
203  bool enableOptimizer = false,
204  bool automap = true)
205  {
206  const EShLanguage stage = GetShaderStage(GetSuffix(shaderName));
207 
208  glslang::TShader shader(stage);
209  if (automap) {
210  shader.setAutoMapLocations(true);
211  shader.setAutoMapBindings(true);
212  }
213  shader.setTextureSamplerTransformMode(texSampTransMode);
214  shader.setFlattenUniformArrays(flattenUniformArrays);
215 
216  if (controls & EShMsgSpvRules) {
217  if (controls & EShMsgVulkanRules) {
220  stage, glslang::EShClientVulkan, 100);
221  shader.setEnvClient(glslang::EShClientVulkan, clientTargetVersion);
222  shader.setEnvTarget(glslang::EShTargetSpv,
225  } else {
228  stage, glslang::EShClientOpenGL, 100);
229  shader.setEnvClient(glslang::EShClientOpenGL, clientTargetVersion);
231  }
232  }
233 
235 
237  program.addShader(&shader);
238  success &= program.link(controls);
239 
241 
242  if (success && (controls & EShMsgSpvRules)) {
243  std::vector<uint32_t> spirv_binary;
245  options.disableOptimizer = !enableOptimizer;
246  glslang::GlslangToSpv(*program.getIntermediate(stage),
247  spirv_binary, &logger, &options);
248 
249  std::ostringstream disassembly_stream;
251  spv::Disassemble(disassembly_stream, spirv_binary);
252  return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
253  program.getInfoLog(), program.getInfoDebugLog(),
254  logger.getAllMessages(), disassembly_stream.str()};
255  } else {
256  return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
257  program.getInfoLog(), program.getInfoDebugLog(), "", ""};
258  }
259  }
260 
261  // Compiles and links the given source |code| of the given shader
262  // |stage| into the target under the semantics specified via |controls|.
263  // Returns a GlslangResult instance containing all the information generated
264  // during the process. If the target includes SPIR-V, also disassembles
265  // the result and returns disassembly text.
267  const std::string shaderName, const std::string& code,
269  int baseSamplerBinding,
270  int baseTextureBinding,
271  int baseImageBinding,
272  int baseUboBinding,
273  int baseSsboBinding,
274  bool autoMapBindings,
275  bool flattenUniformArrays)
276  {
277  const EShLanguage stage = GetShaderStage(GetSuffix(shaderName));
278 
279  glslang::TShader shader(stage);
280  shader.setShiftSamplerBinding(baseSamplerBinding);
281  shader.setShiftTextureBinding(baseTextureBinding);
282  shader.setShiftImageBinding(baseImageBinding);
283  shader.setShiftUboBinding(baseUboBinding);
284  shader.setShiftSsboBinding(baseSsboBinding);
285  shader.setAutoMapBindings(autoMapBindings);
286  shader.setAutoMapLocations(true);
287  shader.setFlattenUniformArrays(flattenUniformArrays);
288 
290 
292  program.addShader(&shader);
293 
294  success &= program.link(controls);
295  success &= program.mapIO();
296 
298 
299  if (success && (controls & EShMsgSpvRules)) {
300  std::vector<uint32_t> spirv_binary;
301  glslang::GlslangToSpv(*program.getIntermediate(stage),
302  spirv_binary, &logger);
303 
304  std::ostringstream disassembly_stream;
306  spv::Disassemble(disassembly_stream, spirv_binary);
307  return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
308  program.getInfoLog(), program.getInfoDebugLog(),
309  logger.getAllMessages(), disassembly_stream.str()};
310  } else {
311  return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
312  program.getInfoLog(), program.getInfoDebugLog(), "", ""};
313  }
314  }
315 
316  // This is like compileAndLink but with remapping of the SPV binary
317  // through spirvbin_t::remap(). While technically this could be merged
318  // with compileAndLink() above (with the remap step optionally being a no-op)
319  // it is given separately here for ease of future extraction.
321  const std::string shaderName, const std::string& code,
323  const unsigned int remapOptions = spv::spirvbin_t::NONE)
324  {
325  const EShLanguage stage = GetShaderStage(GetSuffix(shaderName));
326 
327  glslang::TShader shader(stage);
328  shader.setAutoMapBindings(true);
329  shader.setAutoMapLocations(true);
330 
332 
334  program.addShader(&shader);
335  success &= program.link(controls);
336 
338 
339  if (success && (controls & EShMsgSpvRules)) {
340  std::vector<uint32_t> spirv_binary;
341  glslang::GlslangToSpv(*program.getIntermediate(stage),
342  spirv_binary, &logger);
343 
344  spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions);
345 
346  std::ostringstream disassembly_stream;
348  spv::Disassemble(disassembly_stream, spirv_binary);
349  return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
350  program.getInfoLog(), program.getInfoDebugLog(),
351  logger.getAllMessages(), disassembly_stream.str()};
352  } else {
353  return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
354  program.getInfoLog(), program.getInfoDebugLog(), "", ""};
355  }
356  }
357 
358  // remap the binary in 'code' with the options in remapOptions
360  const std::string shaderName, const std::vector<uint32_t>& code,
362  const unsigned int remapOptions = spv::spirvbin_t::NONE)
363  {
364  if ((controls & EShMsgSpvRules)) {
365  std::vector<uint32_t> spirv_binary(code); // scratch copy
366 
367  spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions);
368 
369  std::ostringstream disassembly_stream;
371  spv::Disassemble(disassembly_stream, spirv_binary);
372 
373  return {{{shaderName, "", ""},},
374  "", "",
375  "", disassembly_stream.str()};
376  } else {
377  return {{{shaderName, "", ""},}, "", "", "", ""};
378  }
379  }
380 
381  void outputResultToStream(std::ostringstream* stream,
382  const GlslangResult& result,
384  {
385  const auto outputIfNotEmpty = [&stream](const std::string& str) {
386  if (!str.empty()) *stream << str << "\n";
387  };
388 
389  for (const auto& shaderResult : result.shaderResults) {
390  *stream << shaderResult.shaderName << "\n";
391  outputIfNotEmpty(shaderResult.output);
392  outputIfNotEmpty(shaderResult.error);
393  }
394  outputIfNotEmpty(result.linkingOutput);
395  outputIfNotEmpty(result.linkingError);
396  *stream << result.spirvWarningsErrors;
397 
398  if (controls & EShMsgSpvRules) {
399  *stream
400  << (result.spirv.empty()
401  ? "SPIR-V is not generated for failed compile or link\n"
402  : result.spirv);
403  }
404  }
405 
407  const std::string& testName,
408  Source source,
409  Semantics semantics,
410  glslang::EShTargetClientVersion clientTargetVersion,
411  Target target,
412  bool automap = true,
413  const std::string& entryPointName="",
414  const std::string& baseDir="/baseResults/",
415  const bool enableOptimizer = false)
416  {
417  const std::string inputFname = testDir + "/" + testName;
418  const std::string expectedOutputFname =
419  testDir + baseDir + testName + ".out";
420  std::string input, expectedOutput;
421 
422  tryLoadFile(inputFname, "input", &input);
423  tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
424 
426  if (enableOptimizer)
428  GlslangResult result = compileAndLink(testName, input, entryPointName, controls, clientTargetVersion, false,
429  EShTexSampTransKeep, enableOptimizer, automap);
430 
431  // Generate the hybrid output in the way of glslangValidator.
432  std::ostringstream stream;
434 
435  checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
436  expectedOutputFname);
437  }
438 
440  const std::string& testName,
441  Source source,
442  Semantics semantics,
443  Target target,
444  const std::string& entryPointName="")
445  {
446  const std::string inputFname = testDir + "/" + testName;
447  const std::string expectedOutputFname =
448  testDir + "/baseResults/" + testName + ".out";
449  std::string input, expectedOutput;
450 
451  tryLoadFile(inputFname, "input", &input);
452  tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
453 
454  const EShMessages controls = DeriveOptions(source, semantics, target);
457 
458  // Generate the hybrid output in the way of glslangValidator.
459  std::ostringstream stream;
461 
462  checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
463  expectedOutputFname);
464  }
465 
467  const std::string& testName,
468  Source source,
469  Semantics semantics,
470  Target target,
472  int baseSamplerBinding,
473  int baseTextureBinding,
474  int baseImageBinding,
475  int baseUboBinding,
476  int baseSsboBinding,
477  bool autoMapBindings,
478  bool flattenUniformArrays)
479  {
480  const std::string inputFname = testDir + "/" + testName;
481  const std::string expectedOutputFname =
482  testDir + "/baseResults/" + testName + ".out";
483  std::string input, expectedOutput;
484 
485  tryLoadFile(inputFname, "input", &input);
486  tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
487 
488  const EShMessages controls = DeriveOptions(source, semantics, target);
493  flattenUniformArrays);
494 
495  // Generate the hybrid output in the way of glslangValidator.
496  std::ostringstream stream;
498 
499  checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
500  expectedOutputFname);
501  }
502 
504  const std::string& testName,
505  Source source,
506  Semantics semantics,
507  Target target,
508  const std::string& entryPointName="",
509  const unsigned int remapOptions = spv::spirvbin_t::NONE)
510  {
511  const std::string inputFname = testDir + "/" + testName;
512  const std::string expectedOutputFname =
513  testDir + "/baseResults/" + testName + ".out";
514  std::string input, expectedOutput;
515 
516  tryLoadFile(inputFname, "input", &input);
517  tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
518 
519  const EShMessages controls = DeriveOptions(source, semantics, target);
520  GlslangResult result = compileLinkRemap(testName, input, entryPointName, controls, remapOptions);
521 
522  // Generate the hybrid output in the way of glslangValidator.
523  std::ostringstream stream;
525 
526  checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
527  expectedOutputFname);
528  }
529 
530  void loadFileRemapAndCheck(const std::string& testDir,
531  const std::string& testName,
532  Source source,
533  Semantics semantics,
534  Target target,
535  const unsigned int remapOptions = spv::spirvbin_t::NONE)
536  {
537  const std::string inputFname = testDir + "/" + testName;
538  const std::string expectedOutputFname =
539  testDir + "/baseResults/" + testName + ".out";
540  std::vector<std::uint32_t> input;
541  std::string expectedOutput;
542 
543  tryLoadSpvFile(inputFname, "input", input);
544  tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
545 
546  const EShMessages controls = DeriveOptions(source, semantics, target);
547  GlslangResult result = remap(testName, input, controls, remapOptions);
548 
549  // Generate the hybrid output in the way of glslangValidator.
550  std::ostringstream stream;
552 
553  checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
554  expectedOutputFname);
555  }
556 
557  // Preprocesses the given |source| code. On success, returns true, the
558  // preprocessed shader, and warning messages. Otherwise, returns false, an
559  // empty string, and error messages.
560  std::tuple<bool, std::string, std::string> preprocess(
561  const std::string& source)
562  {
563  const char* shaderStrings = source.data();
564  const int shaderLengths = static_cast<int>(source.size());
565 
567  shader.setStringsWithLengths(&shaderStrings, &shaderLengths, 1);
568  std::string ppShader;
570  const bool success = shader.preprocess(
573  &ppShader, includer);
574 
575  std::string log = shader.getInfoLog();
576  log += shader.getInfoDebugLog();
577  if (success) {
578  return std::make_tuple(true, ppShader, log);
579  } else {
580  return std::make_tuple(false, "", log);
581  }
582  }
583 
585  const std::string& testName)
586  {
587  const std::string inputFname = testDir + "/" + testName;
588  const std::string expectedOutputFname =
589  testDir + "/baseResults/" + testName + ".out";
590  const std::string expectedErrorFname =
591  testDir + "/baseResults/" + testName + ".err";
592  std::string input, expectedOutput, expectedError;
593 
594  tryLoadFile(inputFname, "input", &input);
595  tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
596  tryLoadFile(expectedErrorFname, "expected error", &expectedError);
597 
598  bool ppOk;
600  std::tie(ppOk, output, error) = preprocess(input);
601  if (!output.empty()) output += '\n';
602  if (!error.empty()) error += '\n';
603 
604  checkEqAndUpdateIfRequested(expectedOutput, output,
605  expectedOutputFname);
606  checkEqAndUpdateIfRequested(expectedError, error,
607  expectedErrorFname);
608  }
609 
611  const std::string& testName,
612  Source source,
613  Semantics semantics,
614  Target target,
615  const std::string& entryPointName = "")
616  {
617  const std::string inputFname = testDir + "/" + testName;
618  const std::string expectedOutputFname = testDir + "/baseResults/" + testName + ".out";
619  std::string input, expectedOutput;
620 
621  tryLoadFile(inputFname, "input", &input);
622  tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
623 
624  const EShMessages controls = DeriveOptions(source, semantics, target);
628 
629  // Generate the hybrid output in the way of glslangValidator.
630  std::ostringstream stream;
632 
633  checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
634  expectedOutputFname);
635  }
636 
637 private:
638  const int defaultVersion;
642 };
643 
644 } // namespace glslangtest
645 
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
Definition: Logger.h:45
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 &reg2 endm macro vzip8 reg2 vzip d d &reg2 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