Added a map type parameter to Image11::map since it was always being mapped for…

Added a map type parameter to Image11::map since it was always being mapped for writing but mipmap generation was reading. TRAC #22927 Signed-off-by: Jamie Madill Signed-off-by: Nicolas Capens Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2275 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 74b86cff
...@@ -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);
...@@ -185,7 +185,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt ...@@ -185,7 +185,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt
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.");
...@@ -269,7 +269,7 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GL ...@@ -269,7 +269,7 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, 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.");
...@@ -367,7 +367,7 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y ...@@ -367,7 +367,7 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y
{ {
// 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;
...@@ -427,7 +427,7 @@ void Image11::createStagingTexture() ...@@ -427,7 +427,7 @@ void Image11::createStagingTexture()
desc.Format = dxgiFormat; desc.Format = dxgiFormat;
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->CreateTexture3D(&desc, NULL, &newTexture); HRESULT result = device->CreateTexture3D(&desc, NULL, &newTexture);
...@@ -455,7 +455,7 @@ void Image11::createStagingTexture() ...@@ -455,7 +455,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);
...@@ -479,7 +479,7 @@ void Image11::createStagingTexture() ...@@ -479,7 +479,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();
...@@ -488,7 +488,7 @@ HRESULT Image11::map(D3D11_MAPPED_SUBRESOURCE *map) ...@@ -488,7 +488,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))
......
...@@ -56,7 +56,7 @@ class Image11 : public Image ...@@ -56,7 +56,7 @@ class Image11 : public Image
virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); virtual void copy(GLint xoffset, GLint yoffset, GLint zoffset, 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