2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2013-07-17 17:58:09 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef WEBGL2CONTEXT_H_
|
|
|
|
#define WEBGL2CONTEXT_H_
|
|
|
|
|
|
|
|
#include "WebGLContext.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2015-05-25 14:50:15 +03:00
|
|
|
class ErrorResult;
|
2020-01-09 01:19:14 +03:00
|
|
|
class HostWebGLContext;
|
2014-09-18 02:08:41 +04:00
|
|
|
class WebGLSampler;
|
|
|
|
class WebGLSync;
|
|
|
|
class WebGLTransformFeedback;
|
|
|
|
class WebGLVertexArrayObject;
|
2014-12-16 08:20:15 +03:00
|
|
|
namespace dom {
|
|
|
|
class OwningUnsignedLongOrUint32ArrayOrBoolean;
|
|
|
|
class OwningWebGLBufferOrLongLong;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
class WebGL2Context final : public WebGLContext {
|
|
|
|
friend class WebGLContext;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
public:
|
|
|
|
WebGL2Context(HostWebGLContext& host, const webgl::InitContextDesc& desc)
|
|
|
|
: WebGLContext(host, desc) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsWebGL2() const override { return true; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-07-17 17:58:09 +04:00
|
|
|
// -------------------------------------------------------------------------
|
2014-09-18 02:08:41 +04:00
|
|
|
// Buffer objects - WebGL2ContextBuffers.cpp
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-09-18 02:08:41 +04:00
|
|
|
void CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
|
2020-01-09 01:19:16 +03:00
|
|
|
uint64_t readOffset, uint64_t writeOffset,
|
|
|
|
uint64_t size) const;
|
|
|
|
void GetBufferSubData(GLenum target, uint64_t srcByteOffset,
|
|
|
|
const Range<uint8_t>& dest) const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-09-18 02:08:41 +04:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Framebuffer objects - WebGL2ContextFramebuffers.cpp
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-09-18 02:08:41 +04:00
|
|
|
void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
|
|
|
|
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
|
|
|
GLbitfield mask, GLenum filter);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-05-25 14:50:15 +03:00
|
|
|
void InvalidateFramebuffer(GLenum target,
|
2020-01-09 01:19:16 +03:00
|
|
|
const Range<const GLenum>& attachments);
|
2014-09-18 02:08:41 +04:00
|
|
|
void InvalidateSubFramebuffer(GLenum target,
|
2020-01-09 01:19:16 +03:00
|
|
|
const Range<const GLenum>& attachments, GLint x,
|
2020-01-09 01:19:14 +03:00
|
|
|
GLint y, GLsizei width, GLsizei height);
|
2014-09-18 02:08:41 +04:00
|
|
|
void ReadBuffer(GLenum mode);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-07-03 04:54:07 +03:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Renderbuffer objects - WebGL2ContextRenderbuffers.cpp
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
Maybe<std::vector<int32_t>> GetInternalformatParameter(GLenum target,
|
|
|
|
GLenum internalformat,
|
|
|
|
GLenum pname) const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-07-17 17:58:09 +04:00
|
|
|
// -------------------------------------------------------------------------
|
2015-11-25 07:15:29 +03:00
|
|
|
// Texture objects - WebGL2ContextTextures.cpp
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-10-14 02:15:16 +03:00
|
|
|
// GL 3.0 & ES 3.0
|
2018-07-27 07:46:33 +03:00
|
|
|
void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
|
2014-09-18 02:08:41 +04:00
|
|
|
void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-09-18 02:08:41 +04:00
|
|
|
// -------------------------------------------------------------------------
|
2016-10-14 03:02:48 +03:00
|
|
|
// Writing to the drawing buffer
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-10-14 03:02:48 +03:00
|
|
|
/* Implemented in WebGLContext
|
|
|
|
void VertexAttribDivisor(GLuint index, GLuint divisor);
|
|
|
|
void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
|
|
|
|
GLsizei instanceCount);
|
|
|
|
void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
|
2019-03-07 02:52:05 +03:00
|
|
|
WebGLintptr offset, GLsizei instanceCount);
|
2018-11-30 13:46:48 +03:00
|
|
|
*/
|
|
|
|
|
2014-09-18 02:08:41 +04:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// Multiple Render Targets - WebGL2ContextMRTs.cpp
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
private:
|
2016-11-30 05:30:28 +03:00
|
|
|
bool ValidateClearBuffer(GLenum buffer, GLint drawBuffer,
|
2020-01-09 01:19:16 +03:00
|
|
|
webgl::AttribBaseType funcType);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
public:
|
2016-10-14 03:02:48 +03:00
|
|
|
void ClearBufferfi(GLenum buffer, GLint drawBuffer, GLfloat depth,
|
2016-11-02 00:58:07 +03:00
|
|
|
GLint stencil);
|
2020-01-09 01:19:16 +03:00
|
|
|
void ClearBufferTv(GLenum buffer, GLint drawBuffer,
|
|
|
|
const webgl::TypedQuad& data);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-09-18 02:08:41 +04:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Sampler Objects - WebGL2ContextSamplers.cpp
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
RefPtr<WebGLSampler> CreateSampler();
|
2014-11-26 05:00:06 +03:00
|
|
|
void BindSampler(GLuint unit, WebGLSampler* sampler);
|
2014-09-18 02:08:41 +04:00
|
|
|
void SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint param);
|
|
|
|
void SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat param);
|
2020-01-09 01:19:16 +03:00
|
|
|
Maybe<double> GetSamplerParameter(const WebGLSampler& sampler,
|
|
|
|
GLenum pname) const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-09-18 02:08:41 +04:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Sync objects - WebGL2ContextSync.cpp
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-11-02 00:58:07 +03:00
|
|
|
const GLuint64 kMaxClientWaitSyncTimeoutNS =
|
|
|
|
1000 * 1000 * 1000; // 1000ms in ns.
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
RefPtr<WebGLSync> FenceSync(GLenum condition, GLbitfield flags);
|
2014-09-18 02:08:41 +04:00
|
|
|
GLenum ClientWaitSync(const WebGLSync& sync, GLbitfield flags,
|
2016-11-02 00:58:07 +03:00
|
|
|
GLuint64 timeout);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-09-18 02:08:41 +04:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Transform Feedback - WebGL2ContextTransformFeedback.cpp
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
RefPtr<WebGLTransformFeedback> CreateTransformFeedback();
|
|
|
|
void BindTransformFeedback(WebGLTransformFeedback* tf);
|
2018-11-27 13:08:58 +03:00
|
|
|
void BeginTransformFeedback(GLenum primitiveMode);
|
|
|
|
void EndTransformFeedback();
|
|
|
|
void PauseTransformFeedback();
|
2014-09-18 02:08:41 +04:00
|
|
|
void ResumeTransformFeedback();
|
2018-11-27 13:08:58 +03:00
|
|
|
void TransformFeedbackVaryings(WebGLProgram& program,
|
2020-01-09 01:19:16 +03:00
|
|
|
const std::vector<std::string>& varyings,
|
|
|
|
GLenum bufferMode) const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-09-18 02:08:41 +04:00
|
|
|
// -------------------------------------------------------------------------
|
2018-11-27 13:08:58 +03:00
|
|
|
// Uniform Buffer Objects and Transform Feedback Buffers -
|
2015-06-05 06:26:34 +03:00
|
|
|
// WebGL2ContextUniforms.cpp
|
|
|
|
// TODO(djg): Implemented in WebGLContext
|
2018-11-30 13:46:48 +03:00
|
|
|
/*
|
2015-06-05 06:26:34 +03:00
|
|
|
void BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer);
|
2016-10-15 01:59:27 +03:00
|
|
|
void BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
|
2019-03-07 02:52:05 +03:00
|
|
|
WebGLintptr offset, WebGLsizeiptr size);
|
2018-11-30 13:46:48 +03:00
|
|
|
*/
|
2020-01-09 01:19:16 +03:00
|
|
|
Maybe<double> GetParameter(GLenum pname) override;
|
|
|
|
Maybe<double> GetIndexedParameter(GLenum pname, uint32_t index) const;
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2016-10-15 01:59:27 +03:00
|
|
|
// Make the inline version from the superclass visible here.
|
|
|
|
using WebGLContext::GetParameter;
|
2020-01-09 01:19:16 +03:00
|
|
|
|
2016-11-02 00:58:07 +03:00
|
|
|
void UniformBlockBinding(WebGLProgram& program, GLuint uniformBlockIndex,
|
2014-12-16 08:20:15 +03:00
|
|
|
GLuint uniformBlockBinding);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-09-18 02:08:41 +04:00
|
|
|
private:
|
2015-11-25 07:15:29 +03:00
|
|
|
virtual UniquePtr<webgl::FormatUsageAuthority> CreateFormatUsage(
|
|
|
|
gl::GLContext* gl) const override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-08-04 00:34:46 +03:00
|
|
|
virtual bool IsTexParamValid(GLenum pname) const override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-04-17 04:17:07 +03:00
|
|
|
void UpdateBoundQuery(GLenum target, WebGLQuery* query);
|
2013-07-17 17:58:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|