Fix FBO/Texture/renderbuffer class hierarchy issues

TRAC #14744 Issue=51/52 Delegated format queries to RenderbufferStorage. Eliminated TextureColorbufferProxy by merging it into Colorbuffer. Abstracted texture colorbuffer queries. Moved some conversion functions to the right namespace. Fixed line-endings in Texture.cpp Signed-off-by: Daniel Koch Author: Nicolas Capens <nicolas@transgaming.com> git-svn-id: https://angleproject.googlecode.com/svn/trunk@553 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 7cfb2cff
......@@ -2378,7 +2378,7 @@ void Context::clear(GLbitfield mask)
D3DSURFACE_DESC desc;
depthStencil->GetDesc(&desc);
unsigned int stencilSize = es2dx::GetStencilSize(desc.Format);
unsigned int stencilSize = dx2es::GetStencilSize(desc.Format);
stencilUnmasked = (0x1 << stencilSize) - 1;
if (stencilUnmasked != 0x0)
......@@ -2415,7 +2415,7 @@ void Context::clear(GLbitfield mask)
D3DSURFACE_DESC desc;
renderTarget->GetDesc(&desc);
bool alphaUnmasked = (es2dx::GetAlphaSize(desc.Format) == 0) || mState.colorMaskAlpha;
bool alphaUnmasked = (dx2es::GetAlphaSize(desc.Format) == 0) || mState.colorMaskAlpha;
const bool needMaskedStencilClear = (flags & D3DCLEAR_STENCIL) &&
(mState.stencilWritemask & stencilUnmasked) != stencilUnmasked;
......
......@@ -46,7 +46,7 @@ Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle) const
}
else if (IsTextureTarget(type))
{
buffer = context->getTexture(handle)->getColorbuffer(type);
buffer = context->getTexture(handle)->getRenderbuffer(type);
}
else
{
......@@ -307,14 +307,14 @@ GLenum Framebuffer::completeness()
if (mColorbufferType == GL_RENDERBUFFER)
{
if (!gl::IsColorRenderable(colorbuffer->getFormat()))
if (!gl::IsColorRenderable(colorbuffer->getInternalFormat()))
{
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
}
}
else if (IsTextureTarget(mColorbufferType))
{
if (IsCompressed(colorbuffer->getFormat()))
if (IsCompressed(colorbuffer->getInternalFormat()))
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
......@@ -325,7 +325,7 @@ GLenum Framebuffer::completeness()
return GL_FRAMEBUFFER_UNSUPPORTED;
}
if (colorbuffer->getFormat() == GL_LUMINANCE || colorbuffer->getFormat() == GL_LUMINANCE_ALPHA)
if (colorbuffer->getInternalFormat() == GL_LUMINANCE || colorbuffer->getInternalFormat() == GL_LUMINANCE_ALPHA)
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
......@@ -424,8 +424,8 @@ GLenum Framebuffer::completeness()
if (mDepthbufferType == GL_RENDERBUFFER && mStencilbufferType == GL_RENDERBUFFER)
{
if (depthbuffer->getFormat() != GL_DEPTH24_STENCIL8_OES ||
stencilbuffer->getFormat() != GL_DEPTH24_STENCIL8_OES ||
if (depthbuffer->getInternalFormat() != GL_DEPTH24_STENCIL8_OES ||
stencilbuffer->getInternalFormat() != GL_DEPTH24_STENCIL8_OES ||
depthbuffer->getSerial() != stencilbuffer->getSerial())
{
return GL_FRAMEBUFFER_UNSUPPORTED;
......
......@@ -21,7 +21,7 @@
namespace gl
{
class Texture;
class Texture;
// A class derived from RenderbufferStorage is created whenever glRenderbufferStorage
// is called. The specific concrete type depends on whether the internal format is
......@@ -40,34 +40,40 @@ class RenderbufferStorage
virtual IDirect3DSurface9 *getRenderTarget();
virtual IDirect3DSurface9 *getDepthStencil();
virtual int getWidth() const;
virtual int getHeight() const;
virtual GLenum getFormat() const;
virtual bool isFloatingPoint() const;
D3DFORMAT getD3DFormat() const;
GLsizei getSamples() const;
unsigned int getSerial() const;
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
GLuint getRedSize() const;
GLuint getGreenSize() const;
GLuint getBlueSize() const;
GLuint getAlphaSize() const;
GLuint getDepthSize() const;
GLuint getStencilSize() const;
virtual GLsizei getSamples() const;
static unsigned int issueSerial();
virtual D3DFORMAT getD3DFormat() const;
unsigned int getSerial() const;
protected:
void setSize(int width, int height);
GLenum mFormat;
GLsizei mWidth;
GLsizei mHeight;
GLenum mInternalFormat;
D3DFORMAT mD3DFormat;
GLsizei mSamples;
const unsigned int mSerial;
private:
DISALLOW_COPY_AND_ASSIGN(RenderbufferStorage);
static unsigned int mCurrentSerial;
static unsigned int issueSerial();
const unsigned int mSerial;
int mWidth;
int mHeight;
static unsigned int mCurrentSerial;
};
// Renderbuffer implements the GL renderbuffer object.
// It's only a wrapper for a RenderbufferStorage, but the internal object
// It's only a proxy for a RenderbufferStorage instance; the internal object
// can change whenever glRenderbufferStorage is called.
class Renderbuffer : public RefCountObject
{
......@@ -83,10 +89,18 @@ class Renderbuffer : public RefCountObject
IDirect3DSurface9 *getRenderTarget();
IDirect3DSurface9 *getDepthStencil();
int getWidth() const;
int getHeight() const;
GLenum getFormat() const;
GLsizei getWidth() const;
GLsizei getHeight() const;
GLenum getInternalFormat() const;
D3DFORMAT getD3DFormat() const;
GLuint getRedSize() const;
GLuint getGreenSize() const;
GLuint getBlueSize() const;
GLuint getAlphaSize() const;
GLuint getDepthSize() const;
GLuint getStencilSize() const;
GLsizei getSamples() const;
unsigned int getSerial() const;
void setStorage(RenderbufferStorage *newStorage);
......@@ -102,42 +116,43 @@ class Colorbuffer : public RenderbufferStorage
{
public:
explicit Colorbuffer(IDirect3DSurface9 *renderTarget);
explicit Colorbuffer(const Texture* texture);
Colorbuffer(int width, int height, GLenum format, GLsizei samples);
Colorbuffer(Texture *texture, GLenum target);
Colorbuffer(GLsizei width, GLsizei height, GLenum format, GLsizei samples);
~Colorbuffer();
virtual ~Colorbuffer();
bool isColorbuffer() const;
virtual bool isColorbuffer() const;
GLuint getRedSize() const;
GLuint getGreenSize() const;
GLuint getBlueSize() const;
GLuint getAlphaSize() const;
virtual IDirect3DSurface9 *getRenderTarget();
IDirect3DSurface9 *getRenderTarget();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
protected:
IDirect3DSurface9 *mRenderTarget;
virtual D3DFORMAT getD3DFormat() const;
bool isFloatingPoint() const;
private:
DISALLOW_COPY_AND_ASSIGN(Colorbuffer);
IDirect3DSurface9 *mRenderTarget;
Texture *mTexture;
GLenum mTarget;
};
class DepthStencilbuffer : public RenderbufferStorage
{
public:
explicit DepthStencilbuffer(IDirect3DSurface9 *depthStencil);
DepthStencilbuffer(int width, int height, GLsizei samples);
DepthStencilbuffer(GLsizei width, GLsizei height, GLsizei samples);
~DepthStencilbuffer();
virtual bool isDepthbuffer() const;
virtual bool isStencilbuffer() const;
GLuint getDepthSize() const;
GLuint getStencilSize() const;
IDirect3DSurface9 *getDepthStencil();
virtual IDirect3DSurface9 *getDepthStencil();
private:
DISALLOW_COPY_AND_ASSIGN(DepthStencilbuffer);
......@@ -148,12 +163,12 @@ class Depthbuffer : public DepthStencilbuffer
{
public:
explicit Depthbuffer(IDirect3DSurface9 *depthStencil);
Depthbuffer(int width, int height, GLsizei samples);
Depthbuffer(GLsizei width, GLsizei height, GLsizei samples);
~Depthbuffer();
virtual ~Depthbuffer();
bool isDepthbuffer() const;
bool isStencilbuffer() const;
virtual bool isDepthbuffer() const;
virtual bool isStencilbuffer() const;
private:
DISALLOW_COPY_AND_ASSIGN(Depthbuffer);
......@@ -163,12 +178,12 @@ class Stencilbuffer : public DepthStencilbuffer
{
public:
explicit Stencilbuffer(IDirect3DSurface9 *depthStencil);
Stencilbuffer(int width, int height, GLsizei samples);
Stencilbuffer(GLsizei width, GLsizei height, GLsizei samples);
~Stencilbuffer();
virtual ~Stencilbuffer();
bool isDepthbuffer() const;
bool isStencilbuffer() const;
virtual bool isDepthbuffer() const;
virtual bool isStencilbuffer() const;
private:
DISALLOW_COPY_AND_ASSIGN(Stencilbuffer);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -57,10 +57,10 @@ class Texture : public RefCountObject
GLenum getWrapS() const;
GLenum getWrapT() const;
GLuint getWidth() const;
GLuint getHeight() const;
GLsizei getWidth() const;
GLsizei getHeight() const;
virtual GLenum getFormat() const = 0;
virtual GLenum getInternalFormat() const = 0;
virtual bool isComplete() const = 0;
virtual bool isCompressed() const = 0;
bool isFloatingPoint() const;
......@@ -68,38 +68,17 @@ class Texture : public RefCountObject
D3DFORMAT getD3DFormat() const;
IDirect3DBaseTexture9 *getTexture();
virtual Renderbuffer *getColorbuffer(GLenum target) = 0;
virtual Renderbuffer *getRenderbuffer(GLenum target) = 0;
virtual void generateMipmaps() = 0;
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0;
bool isDirty() const;
static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1); // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager.
static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1); // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager.
protected:
class TextureColorbufferProxy;
friend class TextureColorbufferProxy;
class TextureColorbufferProxy : public Colorbuffer
{
public:
TextureColorbufferProxy(Texture *texture, GLenum target);
// target is a 2D-like texture target (GL_TEXTURE_2D or one of the cube face targets)
virtual void addRef() const;
virtual void release() const;
virtual IDirect3DSurface9 *getRenderTarget();
virtual int getWidth() const;
virtual int getHeight() const;
virtual GLenum getFormat() const;
virtual bool isFloatingPoint() const;
private:
Texture *mTexture;
GLenum mTarget;
};
friend class Colorbuffer;
// Helper structure representing a single image layer
struct Image
......@@ -147,8 +126,8 @@ class Texture : public RefCountObject
bool isRenderable() const;
unsigned int mWidth;
unsigned int mHeight;
GLsizei mWidth;
GLsizei mHeight;
GLenum mMinFilter;
GLenum mMagFilter;
GLenum mWrapS;
......@@ -218,7 +197,7 @@ class Texture2D : public Texture
~Texture2D();
GLenum getTarget() const;
GLenum getFormat() const;
GLenum getInternalFormat() const;
void setImage(GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setCompressedImage(GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
......@@ -232,7 +211,7 @@ class Texture2D : public Texture
virtual void generateMipmaps();
virtual Renderbuffer *getColorbuffer(GLenum target);
virtual Renderbuffer *getRenderbuffer(GLenum target);
private:
DISALLOW_COPY_AND_ASSIGN(Texture2D);
......@@ -262,7 +241,7 @@ class TextureCubeMap : public Texture
~TextureCubeMap();
GLenum getTarget() const;
GLenum getFormat() const;
GLenum getInternalFormat() const;
void setImagePosX(GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
void setImageNegX(GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
......@@ -283,7 +262,7 @@ class TextureCubeMap : public Texture
virtual void generateMipmaps();
virtual Renderbuffer *getColorbuffer(GLenum target);
virtual Renderbuffer *getRenderbuffer(GLenum target);
private:
DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
......
......@@ -1044,7 +1044,7 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma
}
gl::Colorbuffer *source = framebuffer->getColorbuffer();
GLenum colorbufferFormat = source->getFormat();
GLenum colorbufferFormat = source->getInternalFormat();
// [OpenGL ES 2.0.24] table 3.9
switch (internalformat)
......@@ -1178,7 +1178,7 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
}
gl::Colorbuffer *source = framebuffer->getColorbuffer();
GLenum colorbufferFormat = source->getFormat();
GLenum colorbufferFormat = source->getInternalFormat();
gl::Texture *texture = NULL;
if (target == GL_TEXTURE_2D)
......@@ -1196,7 +1196,7 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
return error(GL_INVALID_OPERATION);
}
GLenum textureFormat = texture->getFormat();
GLenum textureFormat = texture->getInternalFormat();
// [OpenGL ES 2.0.24] table 3.9
switch (textureFormat)
......@@ -2954,85 +2954,23 @@ void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint*
switch (pname)
{
case GL_RENDERBUFFER_WIDTH:
*params = renderbuffer->getWidth();
break;
case GL_RENDERBUFFER_HEIGHT:
*params = renderbuffer->getHeight();
break;
case GL_RENDERBUFFER_INTERNAL_FORMAT:
*params = renderbuffer->getFormat();
break;
case GL_RENDERBUFFER_RED_SIZE:
if (renderbuffer->isColorbuffer())
{
*params = static_cast<gl::Colorbuffer*>(renderbuffer->getStorage())->getRedSize();
}
else
{
*params = 0;
}
break;
case GL_RENDERBUFFER_GREEN_SIZE:
if (renderbuffer->isColorbuffer())
{
*params = static_cast<gl::Colorbuffer*>(renderbuffer->getStorage())->getGreenSize();
}
else
{
*params = 0;
}
break;
case GL_RENDERBUFFER_BLUE_SIZE:
if (renderbuffer->isColorbuffer())
{
*params = static_cast<gl::Colorbuffer*>(renderbuffer->getStorage())->getBlueSize();
}
else
{
*params = 0;
}
break;
case GL_RENDERBUFFER_ALPHA_SIZE:
if (renderbuffer->isColorbuffer())
{
*params = static_cast<gl::Colorbuffer*>(renderbuffer->getStorage())->getAlphaSize();
}
else
{
*params = 0;
}
break;
case GL_RENDERBUFFER_DEPTH_SIZE:
if (renderbuffer->isDepthbuffer())
{
*params = static_cast<gl::Depthbuffer*>(renderbuffer->getStorage())->getDepthSize();
}
else
{
*params = 0;
}
break;
case GL_RENDERBUFFER_STENCIL_SIZE:
if (renderbuffer->isStencilbuffer())
case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
case GL_RENDERBUFFER_SAMPLES_ANGLE:
if (context->getMaxSupportedSamples() != 0)
{
*params = static_cast<gl::Stencilbuffer*>(renderbuffer->getStorage())->getStencilSize();
*params = renderbuffer->getSamples();
}
else
{
*params = 0;
}
break;
case GL_RENDERBUFFER_SAMPLES_ANGLE:
{
if (context->getMaxSupportedSamples() != 0)
{
*params = renderbuffer->getStorage()->getSamples();
}
else
{
return error(GL_INVALID_ENUM);
}
return error(GL_INVALID_ENUM);
}
break;
default:
......@@ -4797,7 +4735,7 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
return error(GL_INVALID_OPERATION);
}
if (format != texture->getFormat())
if (format != texture->getInternalFormat())
{
return error(GL_INVALID_OPERATION);
}
......@@ -4818,7 +4756,7 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
return error(GL_INVALID_OPERATION);
}
if (format != texture->getFormat())
if (format != texture->getInternalFormat())
{
return error(GL_INVALID_OPERATION);
}
......
......@@ -608,6 +608,75 @@ void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DT
}
}
bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount,
D3DPRIMITIVETYPE *d3dPrimitiveType, int *d3dPrimitiveCount)
{
switch (primitiveType)
{
case GL_POINTS:
*d3dPrimitiveType = D3DPT_POINTLIST;
*d3dPrimitiveCount = elementCount;
break;
case GL_LINES:
*d3dPrimitiveType = D3DPT_LINELIST;
*d3dPrimitiveCount = elementCount / 2;
break;
case GL_LINE_LOOP:
*d3dPrimitiveType = D3DPT_LINESTRIP;
*d3dPrimitiveCount = elementCount - 1; // D3D doesn't support line loops, so we draw the last line separately
break;
case GL_LINE_STRIP:
*d3dPrimitiveType = D3DPT_LINESTRIP;
*d3dPrimitiveCount = elementCount - 1;
break;
case GL_TRIANGLES:
*d3dPrimitiveType = D3DPT_TRIANGLELIST;
*d3dPrimitiveCount = elementCount / 3;
break;
case GL_TRIANGLE_STRIP:
*d3dPrimitiveType = D3DPT_TRIANGLESTRIP;
*d3dPrimitiveCount = elementCount - 2;
break;
case GL_TRIANGLE_FAN:
*d3dPrimitiveType = D3DPT_TRIANGLEFAN;
*d3dPrimitiveCount = elementCount - 2;
break;
default:
return false;
}
return true;
}
D3DFORMAT ConvertRenderbufferFormat(GLenum format)
{
switch (format)
{
case GL_RGBA4:
case GL_RGB5_A1:
case GL_RGBA8_OES: return D3DFMT_A8R8G8B8;
case GL_RGB565: return D3DFMT_R5G6B5;
case GL_RGB8_OES: return D3DFMT_X8R8G8B8;
case GL_DEPTH_COMPONENT16:
case GL_STENCIL_INDEX8:
case GL_DEPTH24_STENCIL8_OES: return D3DFMT_D24S8;
default: UNREACHABLE(); return D3DFMT_A8R8G8B8;
}
}
D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples)
{
if (samples <= 1)
return D3DMULTISAMPLE_NONE;
else
return (D3DMULTISAMPLE_TYPE)samples;
}
}
namespace dx2es
{
unsigned int GetStencilSize(D3DFORMAT stencilFormat)
{
switch(stencilFormat)
......@@ -625,8 +694,8 @@ unsigned int GetStencilSize(D3DFORMAT stencilFormat)
case D3DFMT_D32F_LOCKABLE:
case D3DFMT_D16:
return 0;
// case D3DFMT_D32_LOCKABLE: return 0; // DirectX 9Ex only
// case D3DFMT_S8_LOCKABLE: return 8; // DirectX 9Ex only
//case D3DFMT_D32_LOCKABLE: return 0; // DirectX 9Ex only
//case D3DFMT_S8_LOCKABLE: return 8; // DirectX 9Ex only
default: UNREACHABLE();
}
return 0;
......@@ -739,62 +808,6 @@ unsigned int GetDepthSize(D3DFORMAT depthFormat)
return 0;
}
bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount,
D3DPRIMITIVETYPE *d3dPrimitiveType, int *d3dPrimitiveCount)
{
switch (primitiveType)
{
case GL_POINTS:
*d3dPrimitiveType = D3DPT_POINTLIST;
*d3dPrimitiveCount = elementCount;
break;
case GL_LINES:
*d3dPrimitiveType = D3DPT_LINELIST;
*d3dPrimitiveCount = elementCount / 2;
break;
case GL_LINE_LOOP:
*d3dPrimitiveType = D3DPT_LINESTRIP;
*d3dPrimitiveCount = elementCount - 1; // D3D doesn't support line loops, so we draw the last line separately
break;
case GL_LINE_STRIP:
*d3dPrimitiveType = D3DPT_LINESTRIP;
*d3dPrimitiveCount = elementCount - 1;
break;
case GL_TRIANGLES:
*d3dPrimitiveType = D3DPT_TRIANGLELIST;
*d3dPrimitiveCount = elementCount / 3;
break;
case GL_TRIANGLE_STRIP:
*d3dPrimitiveType = D3DPT_TRIANGLESTRIP;
*d3dPrimitiveCount = elementCount - 2;
break;
case GL_TRIANGLE_FAN:
*d3dPrimitiveType = D3DPT_TRIANGLEFAN;
*d3dPrimitiveCount = elementCount - 2;
break;
default:
return false;
}
return true;
}
D3DFORMAT ConvertRenderbufferFormat(GLenum format)
{
switch (format)
{
case GL_RGBA4:
case GL_RGB5_A1:
case GL_RGBA8_OES: return D3DFMT_A8R8G8B8;
case GL_RGB565: return D3DFMT_R5G6B5;
case GL_RGB8_OES: return D3DFMT_X8R8G8B8;
case GL_DEPTH_COMPONENT16:
case GL_STENCIL_INDEX8:
case GL_DEPTH24_STENCIL8_OES: return D3DFMT_D24S8;
default: UNREACHABLE(); return D3DFMT_A8R8G8B8;
}
}
GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type)
{
if (type == D3DMULTISAMPLE_NONMASKABLE)
......@@ -803,19 +816,6 @@ GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type)
return type;
}
D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples)
{
if (samples <= 1)
return D3DMULTISAMPLE_NONE;
else
return (D3DMULTISAMPLE_TYPE)samples;
}
}
namespace dx2es
{
GLenum ConvertBackBufferFormat(D3DFORMAT format)
{
switch (format)
......@@ -852,33 +852,33 @@ GLenum ConvertDepthStencilFormat(D3DFORMAT format)
std::string getTempPath()
{
char path[MAX_PATH];
DWORD pathLen = GetTempPathA(sizeof(path) / sizeof(path[0]), path);
if (pathLen == 0)
{
UNREACHABLE();
return std::string();
}
UINT unique = GetTempFileNameA(path, "sh", 0, path);
if (unique == 0)
{
UNREACHABLE();
return std::string();
}
return path;
char path[MAX_PATH];
DWORD pathLen = GetTempPathA(sizeof(path) / sizeof(path[0]), path);
if (pathLen == 0)
{
UNREACHABLE();
return std::string();
}
UINT unique = GetTempFileNameA(path, "sh", 0, path);
if (unique == 0)
{
UNREACHABLE();
return std::string();
}
return path;
}
void writeFile(const char* path, const void* content, size_t size)
{
FILE* file = fopen(path, "w");
if (!file)
{
UNREACHABLE();
return;
}
fwrite(content, sizeof(char), size, file);
fclose(file);
{
FILE* file = fopen(path, "w");
if (!file)
{
UNREACHABLE();
return;
}
fwrite(content, sizeof(char), size, file);
fclose(file);
}
......@@ -58,22 +58,23 @@ D3DCUBEMAP_FACES ConvertCubeFace(GLenum cubeFace);
DWORD ConvertColorMask(bool red, bool green, bool blue, bool alpha);
D3DTEXTUREFILTERTYPE ConvertMagFilter(GLenum magFilter);
void ConvertMinFilter(GLenum minFilter, D3DTEXTUREFILTERTYPE *d3dMinFilter, D3DTEXTUREFILTERTYPE *d3dMipFilter);
unsigned int GetAlphaSize(D3DFORMAT colorFormat);
unsigned int GetRedSize(D3DFORMAT colorFormat);
unsigned int GetGreenSize(D3DFORMAT colorFormat);
unsigned int GetBlueSize(D3DFORMAT colorFormat);
unsigned int GetDepthSize(D3DFORMAT depthFormat);
unsigned int GetStencilSize(D3DFORMAT stencilFormat);
bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount,
D3DPRIMITIVETYPE *d3dPrimitiveType, int *d3dPrimitiveCount);
D3DFORMAT ConvertRenderbufferFormat(GLenum format);
D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples);
GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type);
}
namespace dx2es
{
GLuint GetAlphaSize(D3DFORMAT colorFormat);
GLuint GetRedSize(D3DFORMAT colorFormat);
GLuint GetGreenSize(D3DFORMAT colorFormat);
GLuint GetBlueSize(D3DFORMAT colorFormat);
GLuint GetDepthSize(D3DFORMAT depthFormat);
GLuint GetStencilSize(D3DFORMAT stencilFormat);
GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type);
GLenum ConvertBackBufferFormat(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