Commit 9ae396bb by Jamie Madill

Remove getData from BufferImpl.

We only ever call this method inside the D3D Renderer, so we can downcast to BufferD3D and call getData on the D3D-specific type. Leave a FIXME for handling index range validation, which will need a CPU-side data cache. Change-Id: Iaf71bc8055869a8561777b6b36f67e376a1d0b81 Reviewed-on: https://chromium-review.googlesource.com/224654Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c751d1e5
...@@ -23,7 +23,6 @@ class BufferImpl ...@@ -23,7 +23,6 @@ class BufferImpl
virtual ~BufferImpl() { } virtual ~BufferImpl() { }
virtual gl::Error setData(const void* data, size_t size, GLenum usage) = 0; virtual gl::Error setData(const void* data, size_t size, GLenum usage) = 0;
virtual gl::Error getData(const uint8_t **outData) = 0;
virtual gl::Error setSubData(const void* data, size_t size, size_t offset) = 0; virtual gl::Error setSubData(const void* data, size_t size, size_t offset) = 0;
virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) = 0; virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) = 0;
virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) = 0; virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) = 0;
......
...@@ -37,6 +37,13 @@ BufferD3D *BufferD3D::makeBufferD3D(BufferImpl *buffer) ...@@ -37,6 +37,13 @@ BufferD3D *BufferD3D::makeBufferD3D(BufferImpl *buffer)
return static_cast<BufferD3D*>(buffer); return static_cast<BufferD3D*>(buffer);
} }
BufferD3D *BufferD3D::makeFromBuffer(gl::Buffer *buffer)
{
BufferImpl *impl = buffer->getImplementation();
ASSERT(impl);
return makeBufferD3D(impl);
}
void BufferD3D::updateSerial() void BufferD3D::updateSerial()
{ {
mSerial = mNextSerial++; mSerial = mNextSerial++;
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "libGLESv2/renderer/BufferImpl.h" #include "libGLESv2/renderer/BufferImpl.h"
#include "libGLESv2/angletypes.h" #include "libGLESv2/angletypes.h"
#include <cstdint>
namespace rx namespace rx
{ {
...@@ -26,9 +28,11 @@ class BufferD3D : public BufferImpl ...@@ -26,9 +28,11 @@ class BufferD3D : public BufferImpl
virtual ~BufferD3D(); virtual ~BufferD3D();
static BufferD3D *makeBufferD3D(BufferImpl *buffer); static BufferD3D *makeBufferD3D(BufferImpl *buffer);
static BufferD3D *makeFromBuffer(gl::Buffer *buffer);
unsigned int getSerial() const { return mSerial; } unsigned int getSerial() const { return mSerial; }
virtual gl::Error getData(const uint8_t **outData) = 0;
virtual size_t getSize() const = 0; virtual size_t getSize() const = 0;
virtual bool supportsDirectBinding() const = 0; virtual bool supportsDirectBinding() const = 0;
virtual Renderer* getRenderer() = 0; virtual Renderer* getRenderer() = 0;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "libGLESv2/renderer/d3d/TextureD3D.h" #include "libGLESv2/renderer/d3d/TextureD3D.h"
#include "libGLESv2/renderer/d3d/TextureStorage.h" #include "libGLESv2/renderer/d3d/TextureStorage.h"
#include "libGLESv2/renderer/d3d/ImageD3D.h" #include "libGLESv2/renderer/d3d/ImageD3D.h"
#include "libGLESv2/Buffer.h" #include "libGLESv2/renderer/d3d/BufferD3D.h"
#include "libGLESv2/Framebuffer.h" #include "libGLESv2/Framebuffer.h"
#include "libGLESv2/Texture.h" #include "libGLESv2/Texture.h"
#include "libGLESv2/main.h" #include "libGLESv2/main.h"
...@@ -39,8 +39,10 @@ gl::Error GetUnpackPointer(const gl::PixelUnpackState &unpack, const void *pixel ...@@ -39,8 +39,10 @@ gl::Error GetUnpackPointer(const gl::PixelUnpackState &unpack, const void *pixel
// TODO: this is the only place outside of renderer that asks for a buffers raw data. // TODO: this is the only place outside of renderer that asks for a buffers raw data.
// This functionality should be moved into renderer and the getData method of BufferImpl removed. // This functionality should be moved into renderer and the getData method of BufferImpl removed.
BufferD3D *bufferD3D = BufferD3D::makeBufferD3D(pixelBuffer->getImplementation());
ASSERT(bufferD3D);
const uint8_t *bufferData = NULL; const uint8_t *bufferData = NULL;
gl::Error error = pixelBuffer->getImplementation()->getData(&bufferData); gl::Error error = bufferD3D->getData(&bufferData);
if (error.isError()) if (error.isError())
{ {
return error; return error;
......
...@@ -64,7 +64,7 @@ class Buffer11 : public BufferD3D ...@@ -64,7 +64,7 @@ class Buffer11 : public BufferD3D
// BufferImpl implementation // BufferImpl implementation
virtual gl::Error setData(const void* data, size_t size, GLenum usage); virtual gl::Error setData(const void* data, size_t size, GLenum usage);
virtual gl::Error getData(const uint8_t **outData); gl::Error getData(const uint8_t **outData) override;
virtual gl::Error setSubData(const void* data, size_t size, size_t offset); virtual gl::Error setSubData(const void* data, size_t size, size_t offset);
virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size); virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size);
virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr); virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr);
......
...@@ -1163,8 +1163,7 @@ gl::Error Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *ind ...@@ -1163,8 +1163,7 @@ gl::Error Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *ind
// Get the raw indices for an indexed draw // Get the raw indices for an indexed draw
if (type != GL_NONE && elementArrayBuffer) if (type != GL_NONE && elementArrayBuffer)
{ {
gl::Buffer *indexBuffer = elementArrayBuffer; BufferD3D *storage = BufferD3D::makeFromBuffer(elementArrayBuffer);
BufferImpl *storage = indexBuffer->getImplementation();
intptr_t offset = reinterpret_cast<intptr_t>(indices); intptr_t offset = reinterpret_cast<intptr_t>(indices);
const uint8_t *bufferData = NULL; const uint8_t *bufferData = NULL;
...@@ -1275,8 +1274,7 @@ gl::Error Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid * ...@@ -1275,8 +1274,7 @@ gl::Error Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *
// Get the raw indices for an indexed draw // Get the raw indices for an indexed draw
if (type != GL_NONE && elementArrayBuffer) if (type != GL_NONE && elementArrayBuffer)
{ {
gl::Buffer *indexBuffer = elementArrayBuffer; BufferD3D *storage = BufferD3D::makeFromBuffer(elementArrayBuffer);
BufferImpl *storage = indexBuffer->getImplementation();
intptr_t offset = reinterpret_cast<intptr_t>(indices); intptr_t offset = reinterpret_cast<intptr_t>(indices);
const uint8_t *bufferData = NULL; const uint8_t *bufferData = NULL;
......
...@@ -91,7 +91,7 @@ gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attri ...@@ -91,7 +91,7 @@ gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attri
{ {
if (buffer) if (buffer)
{ {
BufferImpl *storage = buffer->getImplementation(); BufferD3D *storage = BufferD3D::makeFromBuffer(buffer);
gl::Error error = storage->getData(&input); gl::Error error = storage->getData(&input);
if (error.isError()) if (error.isError())
{ {
......
...@@ -32,7 +32,7 @@ class Buffer9 : public BufferD3D ...@@ -32,7 +32,7 @@ class Buffer9 : public BufferD3D
// BufferImpl implementation // BufferImpl implementation
virtual gl::Error setData(const void* data, size_t size, GLenum usage); virtual gl::Error setData(const void* data, size_t size, GLenum usage);
virtual gl::Error getData(const uint8_t **outData); gl::Error getData(const uint8_t **outData) override;
virtual gl::Error setSubData(const void* data, size_t size, size_t offset); virtual gl::Error setSubData(const void* data, size_t size, size_t offset);
virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size); virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size);
virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr); virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr);
......
...@@ -1417,8 +1417,7 @@ gl::Error Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indi ...@@ -1417,8 +1417,7 @@ gl::Error Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indi
// Get the raw indices for an indexed draw // Get the raw indices for an indexed draw
if (type != GL_NONE && elementArrayBuffer) if (type != GL_NONE && elementArrayBuffer)
{ {
gl::Buffer *indexBuffer = elementArrayBuffer; BufferD3D *storage = BufferD3D::makeFromBuffer(elementArrayBuffer);
BufferImpl *storage = indexBuffer->getImplementation();
intptr_t offset = reinterpret_cast<intptr_t>(indices); intptr_t offset = reinterpret_cast<intptr_t>(indices);
const uint8_t *bufferData = NULL; const uint8_t *bufferData = NULL;
gl::Error error = storage->getData(&bufferData); gl::Error error = storage->getData(&bufferData);
...@@ -1620,7 +1619,7 @@ gl::Error Renderer9::drawIndexedPoints(GLsizei count, GLenum type, const GLvoid ...@@ -1620,7 +1619,7 @@ gl::Error Renderer9::drawIndexedPoints(GLsizei count, GLenum type, const GLvoid
if (elementArrayBuffer) if (elementArrayBuffer)
{ {
BufferImpl *storage = elementArrayBuffer->getImplementation(); BufferD3D *storage = BufferD3D::makeFromBuffer(elementArrayBuffer);
intptr_t offset = reinterpret_cast<intptr_t>(indices); intptr_t offset = reinterpret_cast<intptr_t>(indices);
const uint8_t *bufferData = NULL; const uint8_t *bufferData = NULL;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "libGLESv2/renderer/d3d/d3d9/Renderer9.h" #include "libGLESv2/renderer/d3d/d3d9/Renderer9.h"
#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h" #include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
#include "libGLESv2/renderer/vertexconversion.h" #include "libGLESv2/renderer/vertexconversion.h"
#include "libGLESv2/renderer/BufferImpl.h" #include "libGLESv2/renderer/d3d/BufferD3D.h"
#include "libGLESv2/VertexAttribute.h" #include "libGLESv2/VertexAttribute.h"
#include "libGLESv2/Buffer.h" #include "libGLESv2/Buffer.h"
...@@ -97,7 +97,8 @@ gl::Error VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib ...@@ -97,7 +97,8 @@ gl::Error VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib
{ {
if (buffer) if (buffer)
{ {
BufferImpl *storage = buffer->getImplementation(); BufferD3D *storage = BufferD3D::makeFromBuffer(buffer);
ASSERT(storage);
gl::Error error = storage->getData(&input); gl::Error error = storage->getData(&input);
if (error.isError()) if (error.isError())
{ {
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#include "common/mathutil.h" #include "common/mathutil.h"
#include "common/utilities.h" #include "common/utilities.h"
// FIXME(jmadill): remove this when we support buffer data caching
#include "libGLESv2/renderer/d3d/BufferD3D.h"
namespace gl namespace gl
{ {
...@@ -1671,8 +1674,10 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t ...@@ -1671,8 +1674,10 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t
uintptr_t offset = reinterpret_cast<uintptr_t>(indices); uintptr_t offset = reinterpret_cast<uintptr_t>(indices);
if (!elementArrayBuffer->getIndexRangeCache()->findRange(type, offset, count, indexRangeOut, NULL)) if (!elementArrayBuffer->getIndexRangeCache()->findRange(type, offset, count, indexRangeOut, NULL))
{ {
// FIXME(jmadill): Use buffer data caching instead of the D3D back-end
rx::BufferD3D *bufferD3D = rx::BufferD3D::makeBufferD3D(elementArrayBuffer->getImplementation());
const uint8_t *dataPointer = NULL; const uint8_t *dataPointer = NULL;
Error error = elementArrayBuffer->getImplementation()->getData(&dataPointer); Error error = bufferD3D->getData(&dataPointer);
if (error.isError()) if (error.isError())
{ {
context->recordError(error); context->recordError(error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment