Fixes cases where desired destination format was ignored by CopyTexImage.

TRAC #21595 Issue=339 Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/trunk@1299 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 2187b4a3
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 1293 #define BUILD_REVISION 1299
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "common/debug.h" #include "common/debug.h"
#include "libGLESv2/main.h" #include "libGLESv2/main.h"
#include "libGLESv2/utilities.h"
namespace namespace
{ {
...@@ -216,7 +217,8 @@ bool Blit::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFo ...@@ -216,7 +217,8 @@ bool Blit::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFo
source->GetDesc(&sourceDesc); source->GetDesc(&sourceDesc);
dest->GetDesc(&destDesc); dest->GetDesc(&destDesc);
if (sourceDesc.Format == destDesc.Format && destDesc.Usage & D3DUSAGE_RENDERTARGET) // Can use StretchRect if (sourceDesc.Format == destDesc.Format && destDesc.Usage & D3DUSAGE_RENDERTARGET &&
dx2es::IsFormatChannelEquivalent(destDesc.Format, destFormat)) // Can use StretchRect
{ {
RECT destRect = {xoffset, yoffset, xoffset + (sourceRect.right - sourceRect.left), yoffset + (sourceRect.bottom - sourceRect.top)}; RECT destRect = {xoffset, yoffset, xoffset + (sourceRect.right - sourceRect.left), yoffset + (sourceRect.bottom - sourceRect.top)};
HRESULT result = device->StretchRect(source, &sourceRect, dest, &destRect, D3DTEXF_POINT); HRESULT result = device->StretchRect(source, &sourceRect, dest, &destRect, D3DTEXF_POINT);
......
...@@ -990,6 +990,33 @@ GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type) ...@@ -990,6 +990,33 @@ GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type)
return type; return type;
} }
bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format)
{
switch (d3dformat)
{
case D3DFMT_L8:
return (format == GL_LUMINANCE);
case D3DFMT_A8L8:
return (format == GL_LUMINANCE_ALPHA);
case D3DFMT_DXT1:
return (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT || format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
case D3DFMT_DXT3:
return (format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE);
case D3DFMT_DXT5:
return (format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE);
case D3DFMT_A8R8G8B8:
case D3DFMT_A16B16G16R16F:
case D3DFMT_A32B32G32R32F:
return (format == GL_RGBA || format == GL_BGRA_EXT);
case D3DFMT_X8R8G8B8:
return (format == GL_RGB);
default:
if (d3dformat == D3DFMT_INTZ && gl::IsDepthTexture(format))
return true;
return false;
}
}
bool ConvertReadBufferFormat(D3DFORMAT d3dformat, GLenum *format, GLenum *type) bool ConvertReadBufferFormat(D3DFORMAT d3dformat, GLenum *format, GLenum *type)
{ {
switch (d3dformat) switch (d3dformat)
......
...@@ -88,6 +88,7 @@ bool IsCompressedD3DFormat(D3DFORMAT format); ...@@ -88,6 +88,7 @@ bool IsCompressedD3DFormat(D3DFORMAT format);
GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type); GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type);
bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format);
bool ConvertReadBufferFormat(D3DFORMAT d3dformat, GLenum *format, GLenum *type); bool ConvertReadBufferFormat(D3DFORMAT d3dformat, GLenum *format, GLenum *type);
GLenum ConvertBackBufferFormat(D3DFORMAT format); GLenum ConvertBackBufferFormat(D3DFORMAT format);
GLenum ConvertDepthStencilFormat(D3DFORMAT format); GLenum ConvertDepthStencilFormat(D3DFORMAT format);
......
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