Removes getDisplay and getContext calls

TRAC #22000 Signed-off-by: Daniel Koch Author: Shannon Woods git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1408 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent a9571686
...@@ -273,7 +273,6 @@ bool Framebuffer::hasStencil() ...@@ -273,7 +273,6 @@ bool Framebuffer::hasStencil()
GLenum Framebuffer::completeness() GLenum Framebuffer::completeness()
{ {
gl::Context *context = gl::getContext();
int width = 0; int width = 0;
int height = 0; int height = 0;
int samples = -1; int samples = -1;
...@@ -313,8 +312,10 @@ GLenum Framebuffer::completeness() ...@@ -313,8 +312,10 @@ GLenum Framebuffer::completeness()
return GL_FRAMEBUFFER_UNSUPPORTED; return GL_FRAMEBUFFER_UNSUPPORTED;
} }
if ((gl::IsFloat32Format(internalformat) && !context->supportsFloat32RenderableTextures()) || bool filtering, renderable;
(gl::IsFloat16Format(internalformat) && !context->supportsFloat16RenderableTextures()))
if ((gl::IsFloat32Format(internalformat) && !mRenderer->getFloat32TextureSupport(&filtering, &renderable)) ||
(gl::IsFloat16Format(internalformat) && !mRenderer->getFloat16TextureSupport(&filtering, &renderable)))
{ {
return GL_FRAMEBUFFER_UNSUPPORTED; return GL_FRAMEBUFFER_UNSUPPORTED;
} }
...@@ -365,7 +366,7 @@ GLenum Framebuffer::completeness() ...@@ -365,7 +366,7 @@ GLenum Framebuffer::completeness()
GLint internalformat = depthbuffer->getInternalFormat(); GLint internalformat = depthbuffer->getInternalFormat();
// depth texture attachments require OES/ANGLE_depth_texture // depth texture attachments require OES/ANGLE_depth_texture
if (!context->supportsDepthTextures()) if (!mRenderer->getDepthTextureSupport())
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
...@@ -425,7 +426,7 @@ GLenum Framebuffer::completeness() ...@@ -425,7 +426,7 @@ GLenum Framebuffer::completeness()
// texture stencil attachments come along as part // texture stencil attachments come along as part
// of OES_packed_depth_stencil + OES/ANGLE_depth_texture // of OES_packed_depth_stencil + OES/ANGLE_depth_texture
if (!context->supportsDepthTextures()) if (!mRenderer->getDepthTextureSupport())
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
......
...@@ -1318,8 +1318,8 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std:: ...@@ -1318,8 +1318,8 @@ bool ProgramBinary::linkVaryings(InfoLog &infoLog, std::string& pixelHLSL, std::
} }
// Write the HLSL input/output declarations // Write the HLSL input/output declarations
const bool sm3 = mRenderer->getShaderModel3Support();
Context *context = getContext(); Context *context = getContext();
const bool sm3 = context->supportsShaderModel3();
const int maxVaryingVectors = context->getMaximumVaryingVectors(); const int maxVaryingVectors = context->getMaximumVaryingVectors();
if (registers == maxVaryingVectors && fragmentShader->mUsesFragCoord) if (registers == maxVaryingVectors && fragmentShader->mUsesFragCoord)
...@@ -1931,9 +1931,8 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin ...@@ -1931,9 +1931,8 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
return false; return false;
} }
Context *context = getContext(); const char *vertexProfile = mRenderer->getShaderModel3Support() ? "vs_3_0" : "vs_2_0";
const char *vertexProfile = context->supportsShaderModel3() ? "vs_3_0" : "vs_2_0"; const char *pixelProfile = mRenderer->getShaderModel3Support() ? "ps_3_0" : "ps_2_0";
const char *pixelProfile = context->supportsShaderModel3() ? "ps_3_0" : "ps_2_0";
ID3D10Blob *vertexBinary = compileToBinary(infoLog, vertexHLSL.c_str(), vertexProfile, &mConstantTableVS); ID3D10Blob *vertexBinary = compileToBinary(infoLog, vertexHLSL.c_str(), vertexProfile, &mConstantTableVS);
ID3D10Blob *pixelBinary = compileToBinary(infoLog, pixelHLSL.c_str(), pixelProfile, &mConstantTablePS); ID3D10Blob *pixelBinary = compileToBinary(infoLog, pixelHLSL.c_str(), pixelProfile, &mConstantTablePS);
...@@ -1983,6 +1982,7 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin ...@@ -1983,6 +1982,7 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
mDxFrontCCWLocation = getUniformLocation("dx_FrontCCW"); mDxFrontCCWLocation = getUniformLocation("dx_FrontCCW");
mDxPointsOrLinesLocation = getUniformLocation("dx_PointsOrLines"); mDxPointsOrLinesLocation = getUniformLocation("dx_PointsOrLines");
Context *context = getContext();
context->markDxUniformsDirty(); context->markDxUniformsDirty();
return true; return true;
......
...@@ -310,7 +310,7 @@ bool Texture::isImmutable() const ...@@ -310,7 +310,7 @@ bool Texture::isImmutable() const
GLint Texture::creationLevels(GLsizei width, GLsizei height) const GLint Texture::creationLevels(GLsizei width, GLsizei height) const
{ {
if ((isPow2(width) && isPow2(height)) || getContext()->supportsNonPower2Texture()) if ((isPow2(width) && isPow2(height)) || mRenderer->getNonPower2TextureSupport())
{ {
return 0; // Maximum number of levels return 0; // Maximum number of levels
} }
...@@ -627,9 +627,10 @@ bool Texture2D::isSamplerComplete() const ...@@ -627,9 +627,10 @@ bool Texture2D::isSamplerComplete() const
} }
bool mipmapping = isMipmapFiltered(); bool mipmapping = isMipmapFiltered();
bool filtering, renderable;
if ((IsFloat32Format(getInternalFormat(0)) && !getContext()->supportsFloat32LinearFilter()) || if ((IsFloat32Format(getInternalFormat(0)) && !mRenderer->getFloat32TextureSupport(&filtering, &renderable)) ||
(IsFloat16Format(getInternalFormat(0)) && !getContext()->supportsFloat16LinearFilter())) (IsFloat16Format(getInternalFormat(0)) && !mRenderer->getFloat16TextureSupport(&filtering, &renderable)))
{ {
if (mSamplerState.magFilter != GL_NEAREST || if (mSamplerState.magFilter != GL_NEAREST ||
(mSamplerState.minFilter != GL_NEAREST && mSamplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST)) (mSamplerState.minFilter != GL_NEAREST && mSamplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
...@@ -638,7 +639,7 @@ bool Texture2D::isSamplerComplete() const ...@@ -638,7 +639,7 @@ bool Texture2D::isSamplerComplete() const
} }
} }
bool npotSupport = getContext()->supportsNonPower2Texture(); bool npotSupport = mRenderer->getNonPower2TextureSupport();
if (!npotSupport) if (!npotSupport)
{ {
...@@ -797,7 +798,7 @@ void Texture2D::convertToRenderTarget() ...@@ -797,7 +798,7 @@ void Texture2D::convertToRenderTarget()
void Texture2D::generateMipmaps() void Texture2D::generateMipmaps()
{ {
if (!getContext()->supportsNonPower2Texture()) if (!mRenderer->getNonPower2TextureSupport())
{ {
if (!isPow2(mImageArray[0].getWidth()) || !isPow2(mImageArray[0].getHeight())) if (!isPow2(mImageArray[0].getWidth()) || !isPow2(mImageArray[0].getHeight()))
{ {
...@@ -1072,9 +1073,10 @@ bool TextureCubeMap::isSamplerComplete() const ...@@ -1072,9 +1073,10 @@ bool TextureCubeMap::isSamplerComplete() const
int size = mImageArray[0][0].getWidth(); int size = mImageArray[0][0].getWidth();
bool mipmapping = isMipmapFiltered(); bool mipmapping = isMipmapFiltered();
bool filtering, renderable;
if ((gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)) == GL_FLOAT && !getContext()->supportsFloat32LinearFilter()) || if ((gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0)) == GL_FLOAT && !mRenderer->getFloat32TextureSupport(&filtering, &renderable)) ||
(gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0) == GL_HALF_FLOAT_OES) && !getContext()->supportsFloat16LinearFilter())) (gl::ExtractType(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0) == GL_HALF_FLOAT_OES) && !mRenderer->getFloat16TextureSupport(&filtering, &renderable)))
{ {
if (mSamplerState.magFilter != GL_NEAREST || if (mSamplerState.magFilter != GL_NEAREST ||
(mSamplerState.minFilter != GL_NEAREST && mSamplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST)) (mSamplerState.minFilter != GL_NEAREST && mSamplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
...@@ -1083,7 +1085,7 @@ bool TextureCubeMap::isSamplerComplete() const ...@@ -1083,7 +1085,7 @@ bool TextureCubeMap::isSamplerComplete() const
} }
} }
if (!isPow2(size) && !getContext()->supportsNonPower2Texture()) if (!isPow2(size) && !mRenderer->getNonPower2TextureSupport())
{ {
if (mSamplerState.wrapS != GL_CLAMP_TO_EDGE || mSamplerState.wrapT != GL_CLAMP_TO_EDGE || mipmapping) if (mSamplerState.wrapS != GL_CLAMP_TO_EDGE || mSamplerState.wrapT != GL_CLAMP_TO_EDGE || mipmapping)
{ {
...@@ -1415,7 +1417,7 @@ void TextureCubeMap::generateMipmaps() ...@@ -1415,7 +1417,7 @@ void TextureCubeMap::generateMipmaps()
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
if (!getContext()->supportsNonPower2Texture()) if (!mRenderer->getNonPower2TextureSupport())
{ {
if (!isPow2(mImageArray[0][0].getWidth())) if (!isPow2(mImageArray[0][0].getWidth()))
{ {
......
...@@ -210,6 +210,8 @@ Image::Image() ...@@ -210,6 +210,8 @@ Image::Image()
mDirty = false; mDirty = false;
mRenderer = NULL;
mD3DPool = D3DPOOL_SYSTEMMEM; mD3DPool = D3DPOOL_SYSTEMMEM;
mD3DFormat = D3DFMT_UNKNOWN; mD3DFormat = D3DFMT_UNKNOWN;
mActualFormat = GL_NONE; mActualFormat = GL_NONE;
...@@ -277,6 +279,9 @@ bool Image::redefine(rx::Renderer9 *renderer, GLint internalformat, GLsizei widt ...@@ -277,6 +279,9 @@ bool Image::redefine(rx::Renderer9 *renderer, GLint internalformat, GLsizei widt
mD3DFormat = renderer->ConvertTextureInternalFormat(internalformat); mD3DFormat = renderer->ConvertTextureInternalFormat(internalformat);
mActualFormat = dx2es::GetEquivalentFormat(mD3DFormat); mActualFormat = dx2es::GetEquivalentFormat(mD3DFormat);
ASSERT(dynamic_cast<rx::Renderer9*>(renderer) != NULL); // D3D9_REPLACE
mRenderer = static_cast<rx::Renderer9*>(renderer); // D3D9_REPLACE
if (mSurface) if (mSurface)
{ {
mSurface->Release(); mSurface->Release();
...@@ -309,8 +314,8 @@ void Image::createSurface() ...@@ -309,8 +314,8 @@ void Image::createSurface()
GLsizei requestHeight = mHeight; GLsizei requestHeight = mHeight;
MakeValidSize(true, IsCompressed(mInternalFormat), &requestWidth, &requestHeight, &levelToFetch); MakeValidSize(true, IsCompressed(mInternalFormat), &requestWidth, &requestHeight, &levelToFetch);
// D3D9_REPLACE IDirect3DDevice9 *device = mRenderer->getDevice(); // D3D9_REPLACE
IDirect3DDevice9 *device = getDisplay()->getRenderer9()->getDevice();
HRESULT result = device->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, NULL, d3dFormat, HRESULT result = device->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, NULL, d3dFormat,
poolToUse, &newTexture, NULL); poolToUse, &newTexture, NULL);
...@@ -437,7 +442,8 @@ bool Image::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint y ...@@ -437,7 +442,8 @@ bool Image::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint y
rect.bottom = yoffset + height; rect.bottom = yoffset + height;
POINT point = {rect.left, rect.top}; POINT point = {rect.left, rect.top};
IDirect3DDevice9 *device = getDisplay()->getRenderer9()->getDevice(); // D3D9_REPLACE
IDirect3DDevice9 *device = mRenderer->getDevice(); // D3D9_REPLACE
if (mD3DPool == D3DPOOL_MANAGED) if (mD3DPool == D3DPOOL_MANAGED)
{ {
...@@ -986,7 +992,8 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, ...@@ -986,7 +992,8 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
return error(GL_OUT_OF_MEMORY); return error(GL_OUT_OF_MEMORY);
} }
IDirect3DDevice9 *device = getDisplay()->getRenderer9()->getDevice(); // D3D9_REPLACE IDirect3DDevice9 *device = mRenderer->getDevice(); // D3D9_REPLACE
IDirect3DSurface9 *renderTargetData = NULL; IDirect3DSurface9 *renderTargetData = NULL;
D3DSURFACE_DESC description; D3DSURFACE_DESC description;
renderTarget->GetDesc(&description); renderTarget->GetDesc(&description);
......
...@@ -121,6 +121,8 @@ class Image ...@@ -121,6 +121,8 @@ class Image
bool mDirty; bool mDirty;
rx::Renderer9 *mRenderer;
D3DPOOL mD3DPool; // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be lockable. D3DPOOL mD3DPool; // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be lockable.
D3DFORMAT mD3DFormat; D3DFORMAT mD3DFormat;
GLenum mActualFormat; GLenum mActualFormat;
......
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