• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2016 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // ShaderVk.cpp:
7 //    Implements the class methods for ShaderVk.
8 //
9 
10 #include "libANGLE/renderer/vulkan/ShaderVk.h"
11 
12 #include "common/debug.h"
13 #include "libANGLE/Context.h"
14 #include "libANGLE/renderer/vulkan/ContextVk.h"
15 #include "platform/FeaturesVk.h"
16 
17 namespace rx
18 {
19 
ShaderVk(const gl::ShaderState & data)20 ShaderVk::ShaderVk(const gl::ShaderState &data) : ShaderImpl(data) {}
21 
~ShaderVk()22 ShaderVk::~ShaderVk() {}
23 
compile(const gl::Context * context,gl::ShCompilerInstance * compilerInstance,ShCompileOptions options)24 std::shared_ptr<WaitableCompileEvent> ShaderVk::compile(const gl::Context *context,
25                                                         gl::ShCompilerInstance *compilerInstance,
26                                                         ShCompileOptions options)
27 {
28     ShCompileOptions compileOptions = SH_INITIALIZE_UNINITIALIZED_LOCALS;
29 
30     ContextVk *contextVk = vk::GetImpl(context);
31 
32     bool isWebGL = context->getExtensions().webglCompatibility;
33     if (isWebGL && mData.getShaderType() != gl::ShaderType::Compute)
34     {
35         compileOptions |= SH_INIT_OUTPUT_VARIABLES;
36     }
37 
38     if (contextVk->getFeatures().clampPointSize.enabled)
39     {
40         compileOptions |= SH_CLAMP_POINT_SIZE;
41     }
42 
43     if (contextVk->getFeatures().basicGLLineRasterization.enabled)
44     {
45         compileOptions |= SH_ADD_BRESENHAM_LINE_RASTER_EMULATION;
46     }
47 
48     if (contextVk->emulateSeamfulCubeMapSampling())
49     {
50         compileOptions |= SH_EMULATE_SEAMFUL_CUBE_MAP_SAMPLING;
51     }
52 
53     if (contextVk->useOldRewriteStructSamplers())
54     {
55         compileOptions |= SH_USE_OLD_REWRITE_STRUCT_SAMPLERS;
56     }
57 
58     if (!contextVk->getFeatures().enablePrecisionQualifiers.enabled)
59     {
60         compileOptions |= SH_IGNORE_PRECISION_QUALIFIERS;
61     }
62 
63     // Let compiler detect and emit early fragment test execution mode. We will remove it if
64     // context state does not allow it
65     compileOptions |= SH_EARLY_FRAGMENT_TESTS_OPTIMIZATION;
66 
67     return compileImpl(context, compilerInstance, mData.getSource(), compileOptions | options);
68 }
69 
getDebugInfo() const70 std::string ShaderVk::getDebugInfo() const
71 {
72     return mData.getTranslatedSource();
73 }
74 
75 }  // namespace rx
76