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; }
86 void draw(
PrimitiveType primitiveType,
const size_t startVertex,
const size_t numVertexes)
override;
87 void drawIndexed(
PrimitiveType primitiveType,
const size_t startIndex,
const size_t numIndexes,
const size_t startVertex = 0)
override;
89 void drawInstanced(
PrimitiveType primitiveType,
const size_t startVertex,
const size_t numVertexes,
const size_t startInstance,
const size_t numInstances)
override;
90 void drawInstancedIndexed(
PrimitiveType primitiveType,
const size_t startInstance,
const size_t numInstances,
const size_t startIndex,
const size_t numIndexes)
override;
92 void dispatchCompute(
const unsigned int ,
const unsigned int ,
const unsigned int ) {}
114 void copyTexture(
TextureHandle dstHandle,
unsigned dstSub,
unsigned dstX,
unsigned dstY,
unsigned dstZ,
TextureHandle sourceHandle,
unsigned srcSub)
override;
116 void clearResource(
BufferHandle , uint32_t* )
override {}
117 void clearResource(BufferHandle ,
float* )
override {}
119 void setBuffer(
const BufferBindingHandle bufferBindingHandle, BufferHandle bufferHandle)
override;
123 void setBufferCounter(BufferHandle bufferHandle, BufferHandle sourceBufferHandle)
override;
125 void getBufferCounter(BufferHandle bufferHandle, BufferHandle destinationBufferHandle)
override;
129 void copyResource(BufferHandle destinationHandle, BufferHandle sourceHandle)
override;
130 void copyResource(TextureHandle destinationHandle, TextureHandle sourceHandle)
override;
132 void reset()
override;
139 TextureGLES30* bindTexture(TextureHandle texture, GLuint unit = GLuint(~0u));
141 GLenum bindBuffer(OpenGLES30::BufferTarget target, GLuint buffer);
150 GLenum bindBufferCopy(OpenGLES30::BufferTarget target, BufferGLES30& buffer)
152 if (buffer.target == OpenGLES30::BufferTarget::ElementArrayBuffer) {
154 return bindBuffer(OpenGLES30::BufferTarget::ElementArrayBuffer, buffer.bufferId);
156 return bindBuffer(target, buffer.bufferId);
160 void unbindBuffer(GLuint buffer);
165 void setupVertexAttributes(
size_t baseVertex);
168 bool setupDraw(
size_t baseVertex);
169 bool setupIndexedDraw(GLenum& indexType, GLsizei& indexCount,
const GLvoid*& indexOffset,
const size_t startIndex,
const size_t numIndices,
const size_t baseVertex);
171 BuffersGLES30* buffers =
nullptr;
172 TexturesGLES30* textures =
nullptr;
173 EffectsGLES30* effects =
nullptr;
174 RenderTargetsGLES30* renderTargets =
nullptr;
175 CapabilitiesGLES30* capabilities =
nullptr;
176 GLSyncObjects* syncObjects =
nullptr;
180 GLuint activeTexUnit = 0;
184 GLenum target = GL_TEXTURE_2D;
185 } texUnits[OpenGLES30::maxTexUnits];
187 bool inRenderPass =
false;
188 RenderPassInfo renderPassInfo = {};
195 } bufferTargets[size_t(OpenGLES30::BufferTarget::Count)];
206 } uniformBufferTargets[size_t(OpenGLES30::maxUniformBuffers)];
213 } currItems[OpenGLES30::maxVertexAttributes];
214 uint32_t baseVertex = 0;
234 GLenum indexType = GL_INVALID_ENUM;
235 GLsizei indexCount = 0;
236 GLsizei indexStride = 0;
241 EffectGLES30* ptr =
nullptr;
243 uint32_t currentAttributeMask = 0;
249 float constant[4] = {};
250 BlendStateGLES30 state;
255 float constant[4] = {};
260 bool needVertexAttributeSetup =
true;
Contains all Cogs related functionality.
Framebuffer
Framebuffers to select from when doing framebuffer operations.
PrimitiveType
Primitive types for interpreting vertex data sent to the graphics pipeline.
void signal(FenceHandle fenceHandle) override
Insert a fence in the command stream that will signal when all commands before the fence are complete...
void setDepthStencilState(const DepthStencilStateHandle handle) override
Set the current depth stencil state.
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 drawInstanced(PrimitiveType primitiveType, const size_t startVertex, const size_t numVertexes, const size_t startInstance, const size_t numInstances) override
Draws non-indexed, 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 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 readDepthBuffer(BufferHandle bufferHandle, int x, int y, int width, int height, Framebuffer framebuffer) override
Reads data from the current depth target into the given bufferHandle.
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 readColorBuffer(BufferHandle bufferHandle, int x, int y, int width, int height, Framebuffer framebuffer) override
Reads data from the current render target into the given bufferHandle.
void resolveResource(TextureHandle source, TextureHandle destination) override
Resolves the given source resource target into the given destination texture.
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 drawInstancedIndexed(PrimitiveType primitiveType, const size_t startInstance, const size_t numInstances, const size_t startIndex, const size_t numIndexes) override
Draws indexed, instanced primitives.
void clearCachedState() final
Prepare context for external manipulation of graphics device.
void draw(PrimitiveType primitiveType, const size_t startVertex, const size_t numVertexes) override
Draws non-indexed, non-instanced primitives.
void drawIndexed(PrimitiveType primitiveType, const size_t startIndex, const size_t numIndexes, const size_t startVertex=0) override
Draws indexed, non-instanced primitives.
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 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.
static RasterizerState DefaultState()
Constructs a rasterizer state initialized with the default values.