• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // BufferImpl.h: Defines the abstract rx::BufferImpl class.
8 
9 #ifndef LIBANGLE_RENDERER_BUFFERIMPL_H_
10 #define LIBANGLE_RENDERER_BUFFERIMPL_H_
11 
12 #include "common/PackedEnums.h"
13 #include "common/angleutils.h"
14 #include "common/mathutil.h"
15 #include "libANGLE/Error.h"
16 #include "libANGLE/Observer.h"
17 
18 #include <stdint.h>
19 
20 namespace gl
21 {
22 class BufferState;
23 class Context;
24 }  // namespace gl
25 
26 namespace rx
27 {
28 // We use two set of Subject messages. The CONTENTS_CHANGED message is signaled whenever data
29 // changes, to trigger re-translation or other events. Some buffers only need to be updated when the
30 // underlying driver object changes - this is notified via the STORAGE_CHANGED message.
31 class BufferImpl : public angle::Subject
32 {
33   public:
BufferImpl(const gl::BufferState & state)34     BufferImpl(const gl::BufferState &state) : mState(state) {}
~BufferImpl()35     ~BufferImpl() override {}
destroy(const gl::Context * context)36     virtual void destroy(const gl::Context *context) {}
37 
38     virtual angle::Result setData(const gl::Context *context,
39                                   gl::BufferBinding target,
40                                   const void *data,
41                                   size_t size,
42                                   gl::BufferUsage usage)                                = 0;
43     virtual angle::Result setSubData(const gl::Context *context,
44                                      gl::BufferBinding target,
45                                      const void *data,
46                                      size_t size,
47                                      size_t offset)                                     = 0;
48     virtual angle::Result copySubData(const gl::Context *context,
49                                       BufferImpl *source,
50                                       GLintptr sourceOffset,
51                                       GLintptr destOffset,
52                                       GLsizeiptr size)                                  = 0;
53     virtual angle::Result map(const gl::Context *context, GLenum access, void **mapPtr) = 0;
54     virtual angle::Result mapRange(const gl::Context *context,
55                                    size_t offset,
56                                    size_t length,
57                                    GLbitfield access,
58                                    void **mapPtr)                                       = 0;
59     virtual angle::Result unmap(const gl::Context *context, GLboolean *result)          = 0;
60 
61     virtual angle::Result getIndexRange(const gl::Context *context,
62                                         gl::DrawElementsType type,
63                                         size_t offset,
64                                         size_t count,
65                                         bool primitiveRestartEnabled,
66                                         gl::IndexRange *outRange) = 0;
67 
68     // Override if accurate native memory size information is available
69     virtual GLint64 getMemorySize() const;
70 
onDataChanged()71     virtual void onDataChanged() {}
72 
73   protected:
74     const gl::BufferState &mState;
75 };
76 
getMemorySize()77 inline GLint64 BufferImpl::getMemorySize() const
78 {
79     return 0;
80 }
81 
82 }  // namespace rx
83 
84 #endif  // LIBANGLE_RENDERER_BUFFERIMPL_H_
85