Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
glShaderProgram.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef GL_SHADER_PROGRAM_H
34#define GL_SHADER_PROGRAM_H
35
36#include "glShader.h"
39
40namespace Divide {
41
42class GL_API;
43class PlatformContext;
44
45struct PushConstantsStruct;
46
48{
50 gl46core::GLuint _handle{ GL_NULL_HANDLE };
51 gl46core::UseProgramStageMask _stageMask{ gl46core::UseProgramStageMask::GL_NONE_BIT };
52};
53
54namespace Attorney {
55 class GLAPIShaderProgram;
56};
58class glShaderProgram final : public ShaderProgram {
60 public:
61 using glShaders = eastl::fixed_vector<glShaderEntry, to_base( ShaderType::COUNT ), false>;
62
63 public:
65
66 ~glShaderProgram() override;
67
68 static void Idle(PlatformContext& platformContext);
69
71 bool unload() override;
72
73 protected:
74 [[nodiscard]] ShaderResult validatePreBind(bool rebind = true) override;
75 void processValidation();
76
78 bool loadInternal(hashMap<U64, PerFileShaderData>& fileData, bool overwrite) override;
79
82
83 void uploadPushConstants(const PushConstantsStruct& pushConstants);
84
85 private:
86 gl46core::GLuint _glHandle = GL_NULL_HANDLE;
87
88 bool _validationQueued = false;
89 bool _stagesBound = false;
91};
92
93namespace Attorney
94{
96 {
98 {
99 return program.bind();
100 }
101
102 static void uploadPushConstants(glShaderProgram& program, const PushConstantsStruct& pushConstants)
103 {
104 program.uploadPushConstants(pushConstants);
105 }
106 friend class Divide::GL_API;
107 };
108}; // namespace Attorney
109}; // namespace Divide
110
111#endif //GL_SHADER_PROGRAM_H
112
static ShaderResult bind(glShaderProgram &program)
static void uploadPushConstants(glShaderProgram &program, const PushConstantsStruct &pushConstants)
OpenGL implementation of the RenderAPIWrapper.
Definition: GLWrapper.h:65
GFXDevice & context() const noexcept
const ShaderProgramDescriptor & descriptor() const noexcept
OpenGL implementation of the ShaderProgram entity.
ShaderResult validatePreBind(bool rebind=true) override
void uploadPushConstants(const PushConstantsStruct &pushConstants)
bool unload() override
Make sure this program is ready for deletion.
bool loadInternal(hashMap< U64, PerFileShaderData > &fileData, bool overwrite) override
Returns true if at least one shader linked successfully.
eastl::fixed_vector< glShaderEntry, to_base(ShaderType::COUNT), false > glShaders
gl46core::GLuint _glHandle
static void Idle(PlatformContext &platformContext)
ShaderResult bind()
Bind this shader program (returns false if the program failed validation)
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
constexpr gl46core::GLuint GL_NULL_HANDLE
Invalid object value. Used to compare handles and determine if they were properly created.
Definition: glResources.h:105
hashAlg::unordered_map< K, V, HashFun, Predicate > hashMap
Definition: HashMap.h:55
constexpr auto to_base(const Type value) -> Type
gl46core::UseProgramStageMask _stageMask
gl46core::GLuint _handle
Str< 256 > _name
Definition: glShader.h:49