xref: /aosp_15_r20/external/skia/src/gpu/ganesh/gl/builders/GrGLShaderStringBuilder.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef GrGLShaderStringBuilder_DEFINED
9 #define GrGLShaderStringBuilder_DEFINED
10 
11 #include "include/core/SkTypes.h"
12 #include "include/gpu/ganesh/GrContextOptions.h"
13 #include "include/gpu/ganesh/gl/GrGLTypes.h"
14 #include "include/private/gpu/ganesh/GrTypesPriv.h"
15 #include "src/gpu/SkSLToBackend.h"
16 #include "src/gpu/ganesh/GrThreadSafePipelineBuilder.h"
17 #include "src/gpu/ganesh/gl/GrGLContext.h"
18 #include "src/sksl/codegen/SkSLGLSLCodeGenerator.h"
19 
20 #include <cstdint>
21 #include <string>
22 
23 class GrGLGpu;
24 
25 namespace SkSL {
26 
27 enum class ProgramKind : int8_t;
28 struct ProgramInterface;
29 struct ProgramSettings;
30 struct ShaderCaps;
31 
32 }  // namespace SkSL
33 
34 namespace skgpu {
35 
36 class ShaderErrorHandler;
37 
SkSLToGLSL(const SkSL::ShaderCaps * caps,const std::string & sksl,SkSL::ProgramKind programKind,const SkSL::ProgramSettings & settings,std::string * glsl,SkSL::ProgramInterface * outInterface,ShaderErrorHandler * errorHandler)38 inline bool SkSLToGLSL(const SkSL::ShaderCaps* caps,
39                        const std::string& sksl,
40                        SkSL::ProgramKind programKind,
41                        const SkSL::ProgramSettings& settings,
42                        std::string* glsl,
43                        SkSL::ProgramInterface* outInterface,
44                        ShaderErrorHandler* errorHandler) {
45     return SkSLToBackend(caps, &SkSL::ToGLSL, "GLSL",
46                          sksl, programKind, settings, glsl, outInterface, errorHandler);
47 }
48 
49 }  // namespace skgpu
50 
51 GrGLuint GrGLCompileAndAttachShader(const GrGLContext& glCtx,
52                                     GrGLuint programId,
53                                     GrGLenum type,
54                                     const std::string& glsl,
55                                     bool shaderWasCached,
56                                     GrThreadSafePipelineBuilder::Stats*,
57                                     GrContextOptions::ShaderErrorHandler* errorHandler);
58 
59 bool GrGLCheckLinkStatus(const GrGLGpu* gpu,
60                          GrGLuint programID,
61                          bool shaderWasCached,
62                          GrContextOptions::ShaderErrorHandler* errorHandler,
63                          const std::string* sksl[kGrShaderTypeCount],
64                          const std::string glsl[kGrShaderTypeCount]);
65 
66 #endif
67