Commit 8cdc21c2 by Geoff Lang

Image11::map now takes a parameter to specify if the mapping is for reading or writing.

ANGLEBUG=470 R=shannonwoods@chromium.org Review URL: https://codereview.appspot.com/13253044
parent 0bd6d117
...@@ -50,8 +50,8 @@ void Image11::generateMipmap(Image11 *dest, Image11 *src) ...@@ -50,8 +50,8 @@ void Image11::generateMipmap(Image11 *dest, Image11 *src)
ASSERT(src->getHeight() == 1 || src->getHeight() / 2 == dest->getHeight()); ASSERT(src->getHeight() == 1 || src->getHeight() / 2 == dest->getHeight());
D3D11_MAPPED_SUBRESOURCE destMapped, srcMapped; D3D11_MAPPED_SUBRESOURCE destMapped, srcMapped;
dest->map(&destMapped); dest->map(D3D11_MAP_WRITE, &destMapped);
src->map(&srcMapped); src->map(D3D11_MAP_READ, &srcMapped);
const unsigned char *sourceData = reinterpret_cast<const unsigned char*>(srcMapped.pData); const unsigned char *sourceData = reinterpret_cast<const unsigned char*>(srcMapped.pData);
unsigned char *destData = reinterpret_cast<unsigned char*>(destMapped.pData); unsigned char *destData = reinterpret_cast<unsigned char*>(destMapped.pData);
...@@ -171,7 +171,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig ...@@ -171,7 +171,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig
GLint unpackAlignment, const void *input) GLint unpackAlignment, const void *input)
{ {
D3D11_MAPPED_SUBRESOURCE mappedImage; D3D11_MAPPED_SUBRESOURCE mappedImage;
HRESULT result = map(&mappedImage); HRESULT result = map(D3D11_MAP_WRITE, &mappedImage);
if (FAILED(result)) if (FAILED(result))
{ {
ERR("Could not map image for loading."); ERR("Could not map image for loading.");
...@@ -254,7 +254,7 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GL ...@@ -254,7 +254,7 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GL
ASSERT(yoffset % 4 == 0); ASSERT(yoffset % 4 == 0);
D3D11_MAPPED_SUBRESOURCE mappedImage; D3D11_MAPPED_SUBRESOURCE mappedImage;
HRESULT result = map(&mappedImage); HRESULT result = map(D3D11_MAP_WRITE, &mappedImage);
if (FAILED(result)) if (FAILED(result))
{ {
ERR("Could not map image for loading."); ERR("Could not map image for loading.");
...@@ -344,8 +344,8 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width ...@@ -344,8 +344,8 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width
{ {
// This format requires conversion, so we must copy the texture to staging and manually convert via readPixels // This format requires conversion, so we must copy the texture to staging and manually convert via readPixels
D3D11_MAPPED_SUBRESOURCE mappedImage; D3D11_MAPPED_SUBRESOURCE mappedImage;
HRESULT result = map(&mappedImage); HRESULT result = map(D3D11_MAP_WRITE, &mappedImage);
// determine the offset coordinate into the destination buffer // determine the offset coordinate into the destination buffer
GLsizei rowOffset = gl::ComputePixelSize(mActualFormat) * xoffset; GLsizei rowOffset = gl::ComputePixelSize(mActualFormat) * xoffset;
void *dataOffset = static_cast<unsigned char*>(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset; void *dataOffset = static_cast<unsigned char*>(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset;
...@@ -402,7 +402,7 @@ void Image11::createStagingTexture() ...@@ -402,7 +402,7 @@ void Image11::createStagingTexture()
desc.SampleDesc.Quality = 0; desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_STAGING; desc.Usage = D3D11_USAGE_STAGING;
desc.BindFlags = 0; desc.BindFlags = 0;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
desc.MiscFlags = 0; desc.MiscFlags = 0;
HRESULT result = device->CreateTexture2D(&desc, NULL, &newTexture); HRESULT result = device->CreateTexture2D(&desc, NULL, &newTexture);
...@@ -420,7 +420,7 @@ void Image11::createStagingTexture() ...@@ -420,7 +420,7 @@ void Image11::createStagingTexture()
mDirty = false; mDirty = false;
} }
HRESULT Image11::map(D3D11_MAPPED_SUBRESOURCE *map) HRESULT Image11::map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map)
{ {
createStagingTexture(); createStagingTexture();
...@@ -429,7 +429,7 @@ HRESULT Image11::map(D3D11_MAPPED_SUBRESOURCE *map) ...@@ -429,7 +429,7 @@ HRESULT Image11::map(D3D11_MAPPED_SUBRESOURCE *map)
if (mStagingTexture) if (mStagingTexture)
{ {
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext(); ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
result = deviceContext->Map(mStagingTexture, mStagingSubresource, D3D11_MAP_WRITE, 0, map); result = deviceContext->Map(mStagingTexture, mStagingSubresource, mapType, 0, map);
// this can fail if the device is removed (from TDR) // this can fail if the device is removed (from TDR)
if (d3d11::isDeviceLostError(result)) if (d3d11::isDeviceLostError(result))
......
...@@ -54,7 +54,7 @@ class Image11 : public Image ...@@ -54,7 +54,7 @@ class Image11 : public Image
virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
protected: protected:
HRESULT map(D3D11_MAPPED_SUBRESOURCE *map); HRESULT map(D3D11_MAP mapType, D3D11_MAPPED_SUBRESOURCE *map);
void unmap(); void unmap();
private: private:
......
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