Cogs.Core
EffectsGLES30.h
1#pragma once
2
3#include "../Base/EffectsCommon.h"
4
5#include "CommonGLES30.h"
6
7#include "../Base/Utilities.h"
8
9namespace Cogs
10{
11 struct ContextGLES30;
12
14 {
15 void initialize(ContextGLES30* context, uint32_t delayFrames = 0);
16
18 void beginFrame() { ++currentFrame; }
19
20 EffectHandle load(const ProcessedContent & vsSource,
21 const ProcessedContent & hsSource,
22 const ProcessedContent & dsSource,
23 const ProcessedContent & gsSource,
24 const ProcessedContent & psSource,
25 const StringView & vsEntryPoint,
26 const StringView & hsEntryPoint,
27 const StringView & dsEntryPoint,
28 const StringView & gsEntryPoint,
29 const StringView & psEntryPoint,
30 const EffectDescription & desc) override;
31
32 void releaseEffect(EffectHandle handle);
33
34 ResourceStatus checkEffect(EffectHandle effectHandle) override;
35
36 EffectVariableHandle getEffectVariable(EffectHandle effectHandle, const StringView & name) override;
38
39 TextureBindingHandle getTextureBinding(EffectHandle effectHandle, const StringView & name, const unsigned int slot) override;
40 SamplerStateBindingHandle getSamplerStateBinding(EffectHandle effectHandle, const StringView & name, const unsigned int slot) override;
41
42 void releaseResources();
43
45
51 uint32_t delayFrames = 0;
52 uint32_t currentFrame = 0;
53 uint32_t allEffectsReadyFrame = 0; // Highest readyAtFrame across all effects, used to know when to stop requesting redraws.
54
55 // Inherited via EffectsCommon
56 virtual EffectHandle loadComputeEffect(const StringView & fileName, EffectFlags::EEffectFlags effectFlags) override;
57 virtual EffectHandle loadComputeEffect(const StringView & fileName, const PreprocessorDefinitions & definitions, EffectFlags::EEffectFlags effectFlags) override;
58 private:
59 ContextGLES30* context = nullptr;
60 EffectHandle loadEffect(const char* pVertexSource, const char* pFragmentSource, const PreprocessorDefinitions& definitions, EffectFlags::EEffectFlags effectFlags);
61 GLint loadShader(GLenum shaderType, const char* pSource, PreprocessorDefinitions definitions);
62
63 };
64}
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:50
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
ResourceStatus
Status of an asynchronously loaded resource, such as an effect or a pipeline.
Definition: Common.h:198
std::vector< PreprocessorDefinition > PreprocessorDefinitions
A set of preprocessor definitions.
Definition: IEffects.h:20
Contains an effect description used to load a single effect.
Definition: IEffects.h:62
EEffectFlags
Effect source flags.
Definition: IEffects.h:27
SamplerStateBindingHandle getSamplerStateBinding(EffectHandle effectHandle, const StringView &name, const unsigned int slot) override
Get a handle to a sampler state object binding, mapping how to bind the sampler state to the given ef...
EffectVariableHandle getEffectVariable(EffectHandle effectHandle, const StringView &name) override
Get a handle to the variable with the given name in the effect with the given effectHandle.
void beginFrame()
Advances the frame counter used to simulate asynchronous effect loading, see delayFrames.
Definition: EffectsGLES30.h:18
virtual EffectHandle loadComputeEffect(const StringView &fileName, EffectFlags::EEffectFlags effectFlags) override
Load the compute shader with the given file name and create an effect.
uint32_t delayFrames
Number of frames to delay effect readiness by, simulating asynchronous loading.
Definition: EffectsGLES30.h:51
ResourceStatus checkEffect(EffectHandle effectHandle) override
Check the load status of the effect with the given effectHandle.
void releaseResources()
Release all allocated effect resources.
TextureBindingHandle getTextureBinding(EffectHandle effectHandle, const StringView &name, const unsigned int slot) override
Get a handle to a texture object binding, mapping how to bind textures to the given effect.
ConstantBufferBindingHandle getConstantBufferBinding(EffectHandle effectHandle, const StringView &name) override
Get a handle to a constant buffer binding, mapping how to bind a constant buffer to the given effect.
void releaseEffect(EffectHandle handle)
Release the effect with the given handle, freeing all resources generated during program loading.