Buffer9.cpp (3635B)
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 // Buffer9.cpp Defines the Buffer9 class. 8 9 #include "libANGLE/renderer/d3d/d3d9/Buffer9.h" 10 11 #include "libANGLE/Context.h" 12 #include "libANGLE/renderer/d3d/d3d9/Renderer9.h" 13 14 namespace rx 15 { 16 17 Buffer9::Buffer9(const gl::BufferState &state, Renderer9 *renderer) 18 : BufferD3D(state, renderer), mSize(0) 19 {} 20 21 Buffer9::~Buffer9() 22 { 23 mSize = 0; 24 } 25 26 size_t Buffer9::getSize() const 27 { 28 return mSize; 29 } 30 31 bool Buffer9::supportsDirectBinding() const 32 { 33 return false; 34 } 35 36 angle::Result Buffer9::setData(const gl::Context *context, 37 gl::BufferBinding target, 38 const void *data, 39 size_t size, 40 gl::BufferUsage usage) 41 { 42 if (size > mMemory.size()) 43 { 44 ANGLE_CHECK_GL_ALLOC(GetImplAs<Context9>(context), mMemory.resize(size)); 45 } 46 47 mSize = size; 48 if (data && size > 0) 49 { 50 memcpy(mMemory.data(), data, size); 51 } 52 53 updateD3DBufferUsage(context, usage); 54 55 invalidateStaticData(context); 56 57 return angle::Result::Continue; 58 } 59 60 angle::Result Buffer9::getData(const gl::Context *context, const uint8_t **outData) 61 { 62 if (mMemory.empty()) 63 { 64 *outData = nullptr; 65 } 66 else 67 { 68 *outData = mMemory.data(); 69 } 70 return angle::Result::Continue; 71 } 72 73 angle::Result Buffer9::setSubData(const gl::Context *context, 74 gl::BufferBinding target, 75 const void *data, 76 size_t size, 77 size_t offset) 78 { 79 if (offset + size > mMemory.size()) 80 { 81 ANGLE_CHECK_GL_ALLOC(GetImplAs<Context9>(context), mMemory.resize(size + offset)); 82 } 83 84 mSize = std::max(mSize, offset + size); 85 if (data && size > 0) 86 { 87 memcpy(mMemory.data() + offset, data, size); 88 } 89 90 invalidateStaticData(context); 91 92 return angle::Result::Continue; 93 } 94 95 angle::Result Buffer9::copySubData(const gl::Context *context, 96 BufferImpl *source, 97 GLintptr sourceOffset, 98 GLintptr destOffset, 99 GLsizeiptr size) 100 { 101 // Note: this method is currently unreachable 102 Buffer9 *sourceBuffer = GetAs<Buffer9>(source); 103 ASSERT(sourceBuffer); 104 105 memcpy(mMemory.data() + destOffset, sourceBuffer->mMemory.data() + sourceOffset, size); 106 107 invalidateStaticData(context); 108 109 return angle::Result::Continue; 110 } 111 112 // We do not support buffer mapping in D3D9 113 angle::Result Buffer9::map(const gl::Context *context, GLenum access, void **mapPtr) 114 { 115 ANGLE_HR_UNREACHABLE(GetImplAs<Context9>(context)); 116 return angle::Result::Stop; 117 } 118 119 angle::Result Buffer9::mapRange(const gl::Context *context, 120 size_t offset, 121 size_t length, 122 GLbitfield access, 123 void **mapPtr) 124 { 125 ANGLE_HR_UNREACHABLE(GetImplAs<Context9>(context)); 126 return angle::Result::Stop; 127 } 128 129 angle::Result Buffer9::unmap(const gl::Context *context, GLboolean *result) 130 { 131 ANGLE_HR_UNREACHABLE(GetImplAs<Context9>(context)); 132 return angle::Result::Stop; 133 } 134 135 angle::Result Buffer9::markTransformFeedbackUsage(const gl::Context *context) 136 { 137 ANGLE_HR_UNREACHABLE(GetImplAs<Context9>(context)); 138 return angle::Result::Stop; 139 } 140 141 } // namespace rx