mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
0dfd1a2a0d
(This is a combination of 31 commits) * Fix Linux compilation. * Fix mac compilation. * CI compile fixes. * printf's size_t is %zu. %tu would be unsigned ptrdiff_t. * No non-ref Maybe args. * MOZ_CRASH for noreturn * Handle implied texture sizes, rewrite comment stripping. * Replace e.g. WebGLProgramInner with simpler webgl::ProgramKeepAlive. * Bounce ValidateProgram call off driver. * Uniform name length limit, cubemap fb-attach, non-array uniforms, undersized texImage views. * alignas for uint8_t[sizeof(float)*N] pun buffers. * CC fixes? * Fill attrib0Active. * Repair max-warnings limit. * This is basically required in order for CI's logging to not explode. * Don't cache WebGLMemoryTracker. * Deleted prog/shader error, no texSubImage(null), client-side fingerprint resist for exts. * Fix GetUniformIndices and MakeRangeFromView. * CC Traverse base class from within derived class to fix leaking the world. :( * PauseTransformFeedback * TexImage video fastpath * GetFragLocation for arrays * Forbid BindBufferRange during TF * Mark tests and fix RBAB query and test. * Change(!) query deletion behavior to match spec. * Mark conformance2/query/query.html failing for now. * Implicitly EndQuery on DeleteQuery while spec is in flux. * Fix error code for test. * RAII LruPosition for WebGL context limit. * Include std::list. * Mark CompileResult and LinkResult.pending as false when retrieved. * Hold strong-ref to NotLostData during Run<> to prevent LoseContext=>UAF. * Don't assume GetUniformLocation(foo+'[0]') means foo is an array. * Don't assume !mCanvasElement means !!mOffscreenCanvas. * Handle composition while context-lost. * All non-value-init members must be const or have inline init. * Mark passing tests on Linux. Depends on D54019 Differential Revision: https://phabricator.services.mozilla.com/D55739 --HG-- extra : moz-landing-system : lando
157 lines
6.1 KiB
C++
157 lines
6.1 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* 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 {
|
|
|
|
class ErrorResult;
|
|
class HostWebGLContext;
|
|
class WebGLSampler;
|
|
class WebGLSync;
|
|
class WebGLTransformFeedback;
|
|
class WebGLVertexArrayObject;
|
|
namespace dom {
|
|
class OwningUnsignedLongOrUint32ArrayOrBoolean;
|
|
class OwningWebGLBufferOrLongLong;
|
|
} // namespace dom
|
|
|
|
class WebGL2Context final : public WebGLContext {
|
|
friend class WebGLContext;
|
|
|
|
public:
|
|
WebGL2Context(HostWebGLContext& host, const webgl::InitContextDesc& desc)
|
|
: WebGLContext(host, desc) {}
|
|
|
|
virtual bool IsWebGL2() const override { return true; }
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Buffer objects - WebGL2ContextBuffers.cpp
|
|
|
|
void CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
|
|
uint64_t readOffset, uint64_t writeOffset,
|
|
uint64_t size) const;
|
|
void GetBufferSubData(GLenum target, uint64_t srcByteOffset,
|
|
const Range<uint8_t>& dest) const;
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Framebuffer objects - WebGL2ContextFramebuffers.cpp
|
|
|
|
void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
|
|
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
|
GLbitfield mask, GLenum filter);
|
|
|
|
void InvalidateFramebuffer(GLenum target,
|
|
const Range<const GLenum>& attachments);
|
|
void InvalidateSubFramebuffer(GLenum target,
|
|
const Range<const GLenum>& attachments, GLint x,
|
|
GLint y, GLsizei width, GLsizei height);
|
|
void ReadBuffer(GLenum mode);
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Renderbuffer objects - WebGL2ContextRenderbuffers.cpp
|
|
|
|
Maybe<std::vector<int32_t>> GetInternalformatParameter(GLenum target,
|
|
GLenum internalformat,
|
|
GLenum pname) const;
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Texture objects - WebGL2ContextTextures.cpp
|
|
|
|
// GL 3.0 & ES 3.0
|
|
void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
|
|
void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Writing to the drawing buffer
|
|
|
|
/* 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,
|
|
WebGLintptr offset, GLsizei instanceCount);
|
|
*/
|
|
|
|
// ------------------------------------------------------------------------
|
|
// Multiple Render Targets - WebGL2ContextMRTs.cpp
|
|
|
|
private:
|
|
bool ValidateClearBuffer(GLenum buffer, GLint drawBuffer,
|
|
webgl::AttribBaseType funcType);
|
|
|
|
public:
|
|
void ClearBufferfi(GLenum buffer, GLint drawBuffer, GLfloat depth,
|
|
GLint stencil);
|
|
void ClearBufferTv(GLenum buffer, GLint drawBuffer,
|
|
const webgl::TypedQuad& data);
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Sampler Objects - WebGL2ContextSamplers.cpp
|
|
|
|
RefPtr<WebGLSampler> CreateSampler();
|
|
void BindSampler(GLuint unit, WebGLSampler* sampler);
|
|
void SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint param);
|
|
void SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat param);
|
|
Maybe<double> GetSamplerParameter(const WebGLSampler& sampler,
|
|
GLenum pname) const;
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Sync objects - WebGL2ContextSync.cpp
|
|
|
|
const GLuint64 kMaxClientWaitSyncTimeoutNS =
|
|
1000 * 1000 * 1000; // 1000ms in ns.
|
|
|
|
RefPtr<WebGLSync> FenceSync(GLenum condition, GLbitfield flags);
|
|
GLenum ClientWaitSync(const WebGLSync& sync, GLbitfield flags,
|
|
GLuint64 timeout);
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Transform Feedback - WebGL2ContextTransformFeedback.cpp
|
|
|
|
RefPtr<WebGLTransformFeedback> CreateTransformFeedback();
|
|
void BindTransformFeedback(WebGLTransformFeedback* tf);
|
|
void BeginTransformFeedback(GLenum primitiveMode);
|
|
void EndTransformFeedback();
|
|
void PauseTransformFeedback();
|
|
void ResumeTransformFeedback();
|
|
void TransformFeedbackVaryings(WebGLProgram& program,
|
|
const std::vector<std::string>& varyings,
|
|
GLenum bufferMode) const;
|
|
|
|
// -------------------------------------------------------------------------
|
|
// Uniform Buffer Objects and Transform Feedback Buffers -
|
|
// WebGL2ContextUniforms.cpp
|
|
// TODO(djg): Implemented in WebGLContext
|
|
/*
|
|
void BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer);
|
|
void BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
|
|
WebGLintptr offset, WebGLsizeiptr size);
|
|
*/
|
|
Maybe<double> GetParameter(GLenum pname) override;
|
|
Maybe<double> GetIndexedParameter(GLenum pname, uint32_t index) const;
|
|
|
|
// Make the inline version from the superclass visible here.
|
|
using WebGLContext::GetParameter;
|
|
|
|
void UniformBlockBinding(WebGLProgram& program, GLuint uniformBlockIndex,
|
|
GLuint uniformBlockBinding);
|
|
|
|
private:
|
|
virtual UniquePtr<webgl::FormatUsageAuthority> CreateFormatUsage(
|
|
gl::GLContext* gl) const override;
|
|
|
|
virtual bool IsTexParamValid(GLenum pname) const override;
|
|
|
|
void UpdateBoundQuery(GLenum target, WebGLQuery* query);
|
|
};
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif
|