1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// RenderbufferGL.cpp: Implements the class methods for RenderbufferGL.
#include "libANGLE/renderer/gl/RenderbufferGL.h"
#include "common/debug.h"
#include "libANGLE/Caps.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/StateManagerGL.h"
#include "libANGLE/renderer/gl/formatutilsgl.h"
#include "libANGLE/renderer/gl/renderergl_utils.h"
namespace rx
{
RenderbufferGL::RenderbufferGL(const FunctionsGL *functions,
const WorkaroundsGL &workarounds,
StateManagerGL *stateManager,
const gl::TextureCapsMap &textureCaps)
: RenderbufferImpl(),
mFunctions(functions),
mWorkarounds(workarounds),
mStateManager(stateManager),
mTextureCaps(textureCaps),
mRenderbufferID(0)
{
mFunctions->genRenderbuffers(1, &mRenderbufferID);
mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mRenderbufferID);
}
RenderbufferGL::~RenderbufferGL()
{
mStateManager->deleteRenderbuffer(mRenderbufferID);
mRenderbufferID = 0;
}
gl::Error RenderbufferGL::setStorage(GLenum internalformat, size_t width, size_t height)
{
mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mRenderbufferID);
nativegl::RenderbufferFormat renderbufferFormat =
nativegl::GetRenderbufferFormat(mFunctions, mWorkarounds, internalformat);
mFunctions->renderbufferStorage(GL_RENDERBUFFER, renderbufferFormat.internalFormat,
static_cast<GLsizei>(width), static_cast<GLsizei>(height));
return gl::Error(GL_NO_ERROR);
}
gl::Error RenderbufferGL::setStorageMultisample(size_t samples, GLenum internalformat, size_t width, size_t height)
{
mStateManager->bindRenderbuffer(GL_RENDERBUFFER, mRenderbufferID);
nativegl::RenderbufferFormat renderbufferFormat =
nativegl::GetRenderbufferFormat(mFunctions, mWorkarounds, internalformat);
mFunctions->renderbufferStorageMultisample(
GL_RENDERBUFFER, static_cast<GLsizei>(samples), renderbufferFormat.internalFormat,
static_cast<GLsizei>(width), static_cast<GLsizei>(height));
const gl::TextureCaps &formatCaps = mTextureCaps.get(internalformat);
if (samples > formatCaps.getMaxSamples())
{
// Before version 4.2, it is unknown if the specific internal format can support the requested number
// of samples. It is expected that GL_OUT_OF_MEMORY is returned if the renderbuffer cannot be created.
GLenum error = GL_NO_ERROR;
do
{
error = mFunctions->getError();
if (error == GL_OUT_OF_MEMORY)
{
return gl::Error(GL_OUT_OF_MEMORY);
}
ASSERT(error == GL_NO_ERROR);
} while (error != GL_NO_ERROR);
}
return gl::Error(GL_NO_ERROR);
}
gl::Error RenderbufferGL::setStorageEGLImageTarget(egl::Image *image)
{
UNIMPLEMENTED();
return gl::Error(GL_INVALID_OPERATION);
}
GLuint RenderbufferGL::getRenderbufferID() const
{
return mRenderbufferID;
}
}
|