Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.h Source File

Diligent Engine API Reference

ShaderGLImpl.h
1 /* Copyright 2015-2018 Egor Yusov
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12 *
13 * In no event and under no legal theory, whether in tort (including negligence),
14 * contract, or otherwise, unless required by applicable law (such as deliberate
15 * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16 * liable for any damages, including any direct, indirect, special, incidental,
17 * or consequential damages of any character arising as a result of this License or
18 * out of the use or inability to use the software (including but not limited to damages
19 * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20 * all other commercial damages or losses), even if such Contributor has been advised
21 * of the possibility of such damages.
22 */
23
24 #pragma once
25
26 #include "BaseInterfacesGL.h"
27 #include "ShaderGL.h"
28 #include "ShaderBase.h"
29 #include "RenderDevice.h"
30 #include "GLObjectWrapper.h"
31 #include "GLProgram.h"
32
33 namespace Diligent
34 {
35
36 class FixedBlockMemoryAllocator;
37
38 inline GLenum GetGLShaderType(SHADER_TYPE ShaderType)
39 {
40 switch(ShaderType)
41 {
42 case SHADER_TYPE_VERTEX: return GL_VERTEX_SHADER; break;
43 case SHADER_TYPE_PIXEL: return GL_FRAGMENT_SHADER; break;
44 case SHADER_TYPE_GEOMETRY: return GL_GEOMETRY_SHADER; break;
45 case SHADER_TYPE_HULL: return GL_TESS_CONTROL_SHADER; break;
46 case SHADER_TYPE_DOMAIN: return GL_TESS_EVALUATION_SHADER; break;
47 case SHADER_TYPE_COMPUTE: return GL_COMPUTE_SHADER; break;
48 default: return 0;
49 }
50 }
51
52 inline GLenum ShaderTypeToGLShaderBit(SHADER_TYPE ShaderType)
53 {
54 switch(ShaderType)
55 {
56 case SHADER_TYPE_VERTEX: return GL_VERTEX_SHADER_BIT; break;
57 case SHADER_TYPE_PIXEL: return GL_FRAGMENT_SHADER_BIT; break;
58 case SHADER_TYPE_GEOMETRY: return GL_GEOMETRY_SHADER_BIT; break;
59 case SHADER_TYPE_HULL: return GL_TESS_CONTROL_SHADER_BIT; break;
60 case SHADER_TYPE_DOMAIN: return GL_TESS_EVALUATION_SHADER_BIT; break;
61 case SHADER_TYPE_COMPUTE: return GL_COMPUTE_SHADER_BIT; break;
62 default: return 0;
63 }
64 }
65
67 class ShaderGLImpl : public ShaderBase<IShaderGL, IGLDeviceBaseInterface>
68 {
69 public:
70 typedef ShaderBase<IShaderGL, IGLDeviceBaseInterface> TShaderBase;
71
72 ShaderGLImpl( IReferenceCounters *pRefCounters, class RenderDeviceGLImpl *pDeviceGL, const ShaderCreationAttribs &ShaderCreationAttribs, bool bIsDeviceInternal = false );
73 ~ShaderGLImpl();
74
75 virtual void BindResources( IResourceMapping* pResourceMapping, Uint32 Flags )override;
76
77 virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override;
78
79 virtual IShaderVariable* GetShaderVariable( const Char* Name )override;
80
81 GLProgram& GetGlProgram(){return m_GlProgObj;}
82
83 private:
84
85 friend class PipelineStateGLImpl;
86 friend class DeviceContextGLImpl;
87
88 GLProgram m_GlProgObj; // Used if program pipeline supported
89 GLObjectWrappers::GLShaderObj m_GLShaderObj; // Used if program pipelines are not supported
90 };
91
92 }
Diligent::ShaderGLImpl
Implementation of the Diligent::IShaderGL interface.
Definition: ShaderGLImpl.h:67
Diligent::IShaderVariable
Shader resource variable.
Definition: Shader.h:265
Diligent::SHADER_TYPE
SHADER_TYPE
Describes the shader type.
Definition: Shader.h:46
Diligent
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Diligent::DeviceContextGLImpl
Implementation of the Diligent::IDeviceContextGL interface.
Definition: DeviceContextGLImpl.h:35
Diligent::SHADER_TYPE_PIXEL
Pixel (fragment) shader.
Definition: Shader.h:50
Diligent::ShaderBase
Template class implementing base functionality for a shader object.
Definition: ShaderBase.h:172
Diligent::SHADER_TYPE_HULL
Hull (tessellation control) shader.
Definition: Shader.h:52
Diligent::IResourceMapping
Resouce mapping.
Definition: ResourceMapping.h:80
Diligent::SHADER_TYPE_DOMAIN
Domain (tessellation evaluation) shader.
Definition: Shader.h:53
Diligent::RenderDeviceGLImpl
Implementation of the render device interface in OpenGL.
Definition: RenderDeviceGLImpl.h:53
Diligent::PipelineStateGLImpl
Implementation of the Diligent::IPipelineStateGL interface.
Definition: PipelineStateGLImpl.h:39
Diligent::SHADER_TYPE_VERTEX
Vertex shader.
Definition: Shader.h:49
Diligent::ShaderGLImpl::BindResources
virtual void BindResources(IResourceMapping *pResourceMapping, Uint32 Flags) override
Binds shader resources.
Definition: ShaderGLImpl.cpp:317
Diligent::ShaderGLImpl::GetShaderVariable
virtual IShaderVariable * GetShaderVariable(const Char *Name) override
Returns an interface to a shader variable. If the shader variable is not found, an interface to a dum...
Definition: ShaderGLImpl.cpp:334
Diligent::ShaderGLImpl::QueryInterface
virtual void QueryInterface(const Diligent::INTERFACE_ID &IID, IObject **ppInterface) override
Queries the specific interface, see IObject::QueryInterface() for details.
Diligent::SHADER_TYPE_COMPUTE
Compute shader.
Definition: Shader.h:54
Diligent::ShaderCreationAttribs
Shader creation attributes.
Definition: Shader.h:204
Diligent::SHADER_TYPE_GEOMETRY
Geometry shader.
Definition: Shader.h:51