3#include "../IContext.h"
5#include "CommonGLES30.h"
6#include "../Base/ContextCommon.h"
7#include "../RasterizerState.h"
8#include "../BlendState.h"
9#include "../DepthStencilState.h"
10#include "../BaseGL/SyncObjects.h"
18 struct TexturesGLES30;
20 struct RenderTargetsGLES30;
21 struct CapabilitiesGLES30;
25 BufferGLES30* currentVertexBuffers[kMaxVertexInputSlots];
27 size_t requiredVertexBuffers = 0;
28 size_t indexBufferStride;
37 this->buffers = buffers;
38 this->textures = textures;
39 this->effects = effects;
40 this->renderTargets = renderTargets;
41 this->capabilities = caps;
42 this->syncObjects = sync;
47 EffectHandle getCurrentEffect()
override {
return currentEffect.handle; }
59 void setViewport(
const float x,
const float y,
const float width,
const float height)
override;
60 void setScissor(
const int x,
const int y,
const int width,
const int height)
override;
64 void clearDepth(
const float depth = 1.0f)
override;
71 EffectHandle getEffect() {
return currentEffect.handle; }
115 void dispatchCompute(
const unsigned int ,
const unsigned int ,
const unsigned int ) {}
137 void copyTexture(
TextureHandle dstHandle,
unsigned dstSub,
unsigned dstX,
unsigned dstY,
unsigned dstZ,
TextureHandle sourceHandle,
unsigned srcSub)
override;
139 void clearResource(
BufferHandle , uint32_t* )
override {}
140 void clearResource(BufferHandle ,
float* )
override {}
142 void setBuffer(
const BufferBindingHandle bufferBindingHandle, BufferHandle bufferHandle)
override;
146 void setBufferCounter(BufferHandle bufferHandle, BufferHandle sourceBufferHandle)
override;
148 void getBufferCounter(BufferHandle bufferHandle, BufferHandle destinationBufferHandle)
override;
152 void copyResource(BufferHandle destinationHandle, BufferHandle sourceHandle)
override;
153 void copyResource(TextureHandle destinationHandle, TextureHandle sourceHandle)
override;
155 void reset()
override;
162 TextureGLES30* bindTexture(TextureHandle texture, GLuint unit = GLuint(~0u));
164 GLenum bindBuffer(OpenGLES30::BufferTarget target, GLuint buffer);
173 GLenum bindBufferCopy(OpenGLES30::BufferTarget target, BufferGLES30& buffer)
175 if (buffer.target == OpenGLES30::BufferTarget::ElementArrayBuffer) {
177 return bindBuffer(OpenGLES30::BufferTarget::ElementArrayBuffer, buffer.bufferId);
179 return bindBuffer(target, buffer.bufferId);
183 void unbindBuffer(GLuint buffer);
188 void setupVertexAttributes(
size_t baseVertex);
191 bool setupDraw(
size_t baseVertex);
192 bool setupIndexedDraw(GLenum& indexType, GLsizei& indexCount,
const GLvoid*& indexOffset,
const size_t startIndex,
const size_t numIndices,
const size_t baseVertex);
194 BuffersGLES30* buffers =
nullptr;
195 TexturesGLES30* textures =
nullptr;
196 EffectsGLES30* effects =
nullptr;
197 RenderTargetsGLES30* renderTargets =
nullptr;
198 CapabilitiesGLES30* capabilities =
nullptr;
199 GLSyncObjects* syncObjects =
nullptr;
203 GLuint activeTexUnit = 0;
207 GLenum target = GL_TEXTURE_2D;
208 } texUnits[OpenGLES30::maxTexUnits];
210 bool inRenderPass =
false;
211 RenderPassInfo renderPassInfo = {};
218 } bufferTargets[size_t(OpenGLES30::BufferTarget::Count)];
229 } uniformBufferTargets[size_t(OpenGLES30::maxUniformBuffers)];
236 } currItems[OpenGLES30::maxVertexAttributes];
237 uint32_t baseVertex = 0;
257 GLenum indexType = GL_INVALID_ENUM;
258 GLsizei indexCount = 0;
259 GLsizei indexStride = 0;
264 EffectGLES30* ptr =
nullptr;
266 uint32_t currentAttributeMask = 0;
272 float constant[4] = {};
273 BlendStateGLES30 state;
278 float constant[4] = {};
283 bool needVertexAttributeSetup =
true;
Provides a weakly referenced view over the contents of a string.
Contains all Cogs related functionality.
void signal(FenceHandle fenceHandle) override
Insert a fence in the command stream that will signal when all commands before the fence are complete...
void setScalarVariable(const EffectVariableHandle variableHandle, const float value) override
Sets the given scalar floating point variable to the given value.
void setVector4Variable(const StringView &name, const float *value) override
Sets the vector variable with the given name to the given four-component value.
void setVector3Variable(const StringView &name, const float *value) override
Sets the vector variable with the given name to the given three-component value.
void setDepthStencilState(const DepthStencilStateHandle handle) override
Set the current depth stencil state.
void draw(PrimitiveType::EPrimitiveType primitiveType, const size_t startVertex, const size_t numVertexes) override
Draws non-indexed, non-instanced primitives.
void setViewport(const float x, const float y, const float width, const float height) override
Sets the current viewport to the given location and dimensions.
void setInputLayout(const InputLayoutHandle inputLayoutHandle) override
Sets the current input layout.
void drawIndexed(PrimitiveType::EPrimitiveType primitiveType, const size_t startIndex, const size_t numIndexes, const size_t startVertex=0) override
Draws indexed, non-instanced primitives.
void beginRenderPass(const RenderPassInfo &info) override
Begin a render pass.
void setSamplerState(const SamplerStateBindingHandle samplerStateBindingHandle, const SamplerStateHandle samplerStateHandle) override
Sets the sampler state binding given to the given sampler state.
void readDepthBuffer(BufferHandle bufferHandle, int x, int y, int width, int height, Framebuffer::EFrameBuffer framebuffer) override
Reads data from the current depth target into the given bufferHandle.
void setBuffer(const BufferBindingHandle bufferBindingHandle, BufferHandle bufferHandle) override
Sets a buffer to bind to the given binding.
void endRenderPass() override
End a render pass.
void setVertexArrayObject(VertexArrayObjectHandle vertexArrayObject) override
void updateSubTexture(TextureHandle textureHandle, const size_t level, const void *data) override
Update the data of a level in the given texture.
void unmap(BufferHandle bufferHandle) override
Unmaps the given buffer, applying any synchronization necessary to reflect changes in the mapped memo...
void setConstantBuffer(const ConstantBufferBindingHandle bufferBindingHandle, const BufferHandle bufferHandle, const uint32_t offset, const uint32_t size) override
Sets a constant buffer to the given constant buffer binding.
void updateSubBuffer(BufferHandle bufferHandle, const size_t offset, const size_t size, const void *data) override
Update a region of data in a buffer.
void setVector2Variable(const StringView &name, const float *value) override
Sets the vector variable with the given name to the given two-component value.
void setScissor(const int x, const int y, const int width, const int height) override
Sets the current scissor rectangle.
void setBlendState(const BlendStateHandle handle, const float *constant) override
Set the current blend state.
void setRasterizerState(const RasterizerStateHandle handle) override
Set the current rasterizer state.
void resolveResource(TextureHandle source, TextureHandle destination) override
Resolves the given source resource target into the given destination texture.
void readColorBuffer(BufferHandle bufferHandle, int x, int y, int width, int height, Framebuffer::EFrameBuffer framebuffer) override
Reads data from the current render target into the given bufferHandle.
void reset() override
Resets all state changes made to the GPU since the last call to beginFrame.
void clearDepth(const float depth=1.0f) override
Clear the currently set depth/stencil target to the given depth.
void getBufferCounter(BufferHandle bufferHandle, BufferHandle destinationBufferHandle) override
Get the associated counter of a buffer.
void clearRenderTarget(const float *color) override
Clear the currently set render target to the given value (4 component floating point RGBA).
void setBufferCounter(BufferHandle bufferHandle, uint32_t value) override
Set the associated counter of a buffer.
void dispatchCompute(const unsigned int, const unsigned int, const unsigned int)
Dispatch computing work on the graphics device using the desired thread group count.
void setIndexBuffer(IndexBufferHandle indexBufferHandle, uint32_t stride, uint32_t offset) override
Sets the current index buffer.
void unmap(TextureHandle) override
Release a host mapping of a staging texture.
void * map(TextureHandle, MapMode::EMapMode, uint32_t *, uint32_t *) override
Create host mapping of a staging texture.
void drawInstanced(PrimitiveType::EPrimitiveType primitiveType, const size_t startVertex, const size_t numVertexes, const size_t startInstance, const size_t numInstances) override
Draws non-indexed, instanced primitives.
void drawInstancedIndexed(PrimitiveType::EPrimitiveType primitiveType, const size_t startInstance, const size_t numInstances, const size_t startIndex, const size_t numIndexes) override
Draws indexed, instanced primitives.
void setVariable(const EffectVariableHandle index, const uint8_t *data, size_t size) override
Sets the variable with the given name and size.
void clearCachedState() final
Prepare context for external manipulation of graphics device.
void setMatrixVariable(const StringView &name, const float *value) override
Sets the matrix variable with the given name in the current effect to value.
void setMatrixVariable(const EffectVariableHandle variableHandle, const float *value) override
Sets the given matrix variable to value.
void setScalarVariable(const EffectVariableHandle variableHandle, int value) override
Sets the given scalar integer point variable to the given value.
void setEffect(EffectHandle handle) override
Set the current effect.
void setVertexBuffers(const VertexBufferHandle *vertexBufferHandles, const size_t count, const uint32_t *strides, const uint32_t *offsets) override
Sets the current vertex buffers.
void setRenderTarget(const RenderTargetHandle handle, const DepthStencilHandle depthStencilHandle) override
Sets the current render target and an associated depth stencil target.
void setScalarVariable(const StringView &name, const float value) override
Sets the scalar floating point variable with the given name to the given value.
void updateBuffer(BufferHandle bufferHandle, const void *data, size_t size) override
Replace contents of buffer with new data.
static DepthStencilState DefaultState()
Constructs a depth stencil state object initialized with the default values.
static const Handle_t NoHandle
Represents a handle to nothing.
Provides effects and shader management functionality.
EMapMode
Mapping mode enumeration.
EPrimitiveType
Primitive type enumeration.
static RasterizerState DefaultState()
Constructs a rasterizer state initialized with the default values.