• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 
6 #include "libANGLE/renderer/gl/MemoryObjectGL.h"
7 
8 #include "libANGLE/Context.h"
9 #include "libANGLE/queryconversions.h"
10 #include "libANGLE/renderer/gl/ContextGL.h"
11 #include "libANGLE/renderer/gl/FunctionsGL.h"
12 #include "libANGLE/renderer/gl/renderergl_utils.h"
13 
14 namespace rx
15 {
MemoryObjectGL(GLuint memoryObject)16 MemoryObjectGL::MemoryObjectGL(GLuint memoryObject) : mMemoryObject(memoryObject)
17 {
18     ASSERT(mMemoryObject != 0);
19 }
20 
~MemoryObjectGL()21 MemoryObjectGL::~MemoryObjectGL()
22 {
23     ASSERT(mMemoryObject == 0);
24 }
25 
onDestroy(const gl::Context * context)26 void MemoryObjectGL::onDestroy(const gl::Context *context)
27 {
28     const FunctionsGL *functions = GetFunctionsGL(context);
29     functions->deleteMemoryObjectsEXT(1, &mMemoryObject);
30     mMemoryObject = 0;
31 }
32 
setDedicatedMemory(const gl::Context * context,bool dedicatedMemory)33 angle::Result MemoryObjectGL::setDedicatedMemory(const gl::Context *context, bool dedicatedMemory)
34 {
35     const FunctionsGL *functions = GetFunctionsGL(context);
36 
37     GLint params = gl::ConvertToGLBoolean(dedicatedMemory);
38     ANGLE_GL_TRY(context, functions->memoryObjectParameterivEXT(
39                               mMemoryObject, GL_DEDICATED_MEMORY_OBJECT_EXT, &params));
40     return angle::Result::Continue;
41 }
42 
importFd(gl::Context * context,GLuint64 size,gl::HandleType handleType,GLint fd)43 angle::Result MemoryObjectGL::importFd(gl::Context *context,
44                                        GLuint64 size,
45                                        gl::HandleType handleType,
46                                        GLint fd)
47 {
48     const FunctionsGL *functions = GetFunctionsGL(context);
49     ANGLE_GL_TRY(context,
50                  functions->importMemoryFdEXT(mMemoryObject, size, ToGLenum(handleType), fd));
51     return angle::Result::Continue;
52 }
53 
importZirconHandle(gl::Context * context,GLuint64 size,gl::HandleType handleType,GLuint handle)54 angle::Result MemoryObjectGL::importZirconHandle(gl::Context *context,
55                                                  GLuint64 size,
56                                                  gl::HandleType handleType,
57                                                  GLuint handle)
58 {
59     UNREACHABLE();
60     return angle::Result::Stop;
61 }
62 
getMemoryObjectID() const63 GLuint MemoryObjectGL::getMemoryObjectID() const
64 {
65     return mMemoryObject;
66 }
67 }  // namespace rx
68