• 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 // GlslangWrapperVk: Wrapper for Vulkan's glslang compiler.
7 //
8 
9 #include "libANGLE/renderer/vulkan/GlslangWrapperVk.h"
10 
11 #include "libANGLE/renderer/vulkan/ContextVk.h"
12 #include "libANGLE/renderer/vulkan/vk_cache_utils.h"
13 
14 namespace rx
15 {
16 // static
CreateSourceOptions(const angle::FeaturesVk & features)17 GlslangSourceOptions GlslangWrapperVk::CreateSourceOptions(const angle::FeaturesVk &features)
18 {
19     GlslangSourceOptions options;
20 
21     options.supportsTransformFeedbackExtension =
22         features.supportsTransformFeedbackExtension.enabled;
23     options.supportsTransformFeedbackEmulation = features.emulateTransformFeedback.enabled;
24     options.enableTransformFeedbackEmulation   = options.supportsTransformFeedbackEmulation;
25     options.emulateBresenhamLines              = features.basicGLLineRasterization.enabled;
26 
27     return options;
28 }
29 
30 // static
ResetGlslangProgramInterfaceInfo(GlslangProgramInterfaceInfo * glslangProgramInterfaceInfo)31 void GlslangWrapperVk::ResetGlslangProgramInterfaceInfo(
32     GlslangProgramInterfaceInfo *glslangProgramInterfaceInfo)
33 {
34     glslangProgramInterfaceInfo->uniformsAndXfbDescriptorSetIndex =
35         ToUnderlying(DescriptorSetIndex::UniformsAndXfb);
36     glslangProgramInterfaceInfo->currentUniformBindingIndex = 0;
37     glslangProgramInterfaceInfo->textureDescriptorSetIndex =
38         ToUnderlying(DescriptorSetIndex::Texture);
39     glslangProgramInterfaceInfo->currentTextureBindingIndex = 0;
40     glslangProgramInterfaceInfo->shaderResourceDescriptorSetIndex =
41         ToUnderlying(DescriptorSetIndex::ShaderResource);
42     glslangProgramInterfaceInfo->currentShaderResourceBindingIndex = 0;
43     glslangProgramInterfaceInfo->driverUniformsDescriptorSetIndex =
44         ToUnderlying(DescriptorSetIndex::Internal);
45 
46     glslangProgramInterfaceInfo->locationsUsedForXfbExtension = 0;
47 }
48 
49 // static
GetShaderCode(const angle::FeaturesVk & features,const gl::ProgramState & programState,const gl::ProgramLinkedResources & resources,GlslangProgramInterfaceInfo * programInterfaceInfo,gl::ShaderMap<const angle::spirv::Blob * > * spirvBlobsOut,ShaderInterfaceVariableInfoMap * variableInfoMapOut)50 void GlslangWrapperVk::GetShaderCode(const angle::FeaturesVk &features,
51                                      const gl::ProgramState &programState,
52                                      const gl::ProgramLinkedResources &resources,
53                                      GlslangProgramInterfaceInfo *programInterfaceInfo,
54                                      gl::ShaderMap<const angle::spirv::Blob *> *spirvBlobsOut,
55                                      ShaderInterfaceVariableInfoMap *variableInfoMapOut)
56 {
57     GlslangSourceOptions options = CreateSourceOptions(features);
58     GlslangGetShaderSpirvCode(options, programState, resources, programInterfaceInfo, spirvBlobsOut,
59                               variableInfoMapOut);
60 }
61 
62 // static
TransformSpirV(const GlslangSpirvOptions & options,const ShaderInterfaceVariableInfoMap & variableInfoMap,const angle::spirv::Blob & initialSpirvBlob,angle::spirv::Blob * shaderCodeOut)63 angle::Result GlslangWrapperVk::TransformSpirV(
64     const GlslangSpirvOptions &options,
65     const ShaderInterfaceVariableInfoMap &variableInfoMap,
66     const angle::spirv::Blob &initialSpirvBlob,
67     angle::spirv::Blob *shaderCodeOut)
68 {
69     return GlslangTransformSpirvCode(options, variableInfoMap, initialSpirvBlob, shaderCodeOut);
70 }
71 }  // namespace rx
72