xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/gl/MemoryObjectGL.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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 
setProtectedMemory(const gl::Context * context,bool protectedMemory)43 angle::Result MemoryObjectGL::setProtectedMemory(const gl::Context *context, bool protectedMemory)
44 {
45     ANGLE_UNUSED_VARIABLE(context);
46     ANGLE_UNUSED_VARIABLE(protectedMemory);
47     return angle::Result::Continue;
48 }
49 
importFd(gl::Context * context,GLuint64 size,gl::HandleType handleType,GLint fd)50 angle::Result MemoryObjectGL::importFd(gl::Context *context,
51                                        GLuint64 size,
52                                        gl::HandleType handleType,
53                                        GLint fd)
54 {
55     const FunctionsGL *functions = GetFunctionsGL(context);
56     ANGLE_GL_TRY(context,
57                  functions->importMemoryFdEXT(mMemoryObject, size, ToGLenum(handleType), fd));
58     return angle::Result::Continue;
59 }
60 
importZirconHandle(gl::Context * context,GLuint64 size,gl::HandleType handleType,GLuint handle)61 angle::Result MemoryObjectGL::importZirconHandle(gl::Context *context,
62                                                  GLuint64 size,
63                                                  gl::HandleType handleType,
64                                                  GLuint handle)
65 {
66     UNREACHABLE();
67     return angle::Result::Stop;
68 }
69 
getMemoryObjectID() const70 GLuint MemoryObjectGL::getMemoryObjectID() const
71 {
72     return mMemoryObject;
73 }
74 }  // namespace rx
75