Hash :
752ce192
Author :
Date :
2015-04-14T11:11:12
D3D11: Use DX generateMips to generate mipmaps whenever possible. BUG=angleproject:974 Change-Id: I95937fe7a0833de77c52f838ebb3ecba55dfbf8a Reviewed-on: https://chromium-review.googlesource.com/265640 Tested-by: Gregoire Payen de La Garanderie <Gregory.Payen@imgtec.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
//
// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// TextureStorage9.h: Defines the abstract rx::TextureStorage9 class and its concrete derived
// classes TextureStorage9_2D and TextureStorage9_Cube, which act as the interface to the
// D3D9 texture.
#ifndef LIBANGLE_RENDERER_D3D_D3D9_TEXTURESTORAGE9_H_
#define LIBANGLE_RENDERER_D3D_D3D9_TEXTURESTORAGE9_H_
#include "libANGLE/renderer/d3d/TextureStorage.h"
#include "common/debug.h"
namespace rx
{
class Renderer9;
class SwapChain9;
class RenderTargetD3D;
class RenderTarget9;
class TextureStorage9 : public TextureStorage
{
public:
virtual ~TextureStorage9();
static DWORD GetTextureUsage(GLenum internalformat, bool renderTarget);
D3DPOOL getPool() const;
DWORD getUsage() const;
virtual gl::Error getBaseTexture(IDirect3DBaseTexture9 **outTexture) = 0;
virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT) = 0;
virtual int getTopLevel() const;
virtual bool isRenderTarget() const;
virtual bool isManaged() const;
bool supportsNativeMipmapFunction() const override;
virtual int getLevelCount() const;
virtual gl::Error setData(const gl::ImageIndex &index, ImageD3D *image, const gl::Box *destBox, GLenum type,
const gl::PixelUnpackState &unpack, const uint8_t *pixelData);
protected:
int mTopLevel;
size_t mMipLevels;
size_t mTextureWidth;
size_t mTextureHeight;
GLenum mInternalFormat;
D3DFORMAT mTextureFormat;
Renderer9 *mRenderer;
TextureStorage9(Renderer9 *renderer, DWORD usage);
private:
const DWORD mD3DUsage;
const D3DPOOL mD3DPool;
};
class TextureStorage9_2D : public TextureStorage9
{
public:
TextureStorage9_2D(Renderer9 *renderer, SwapChain9 *swapchain);
TextureStorage9_2D(Renderer9 *renderer, GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
virtual ~TextureStorage9_2D();
gl::Error getSurfaceLevel(int level, bool dirty, IDirect3DSurface9 **outSurface);
virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT);
virtual gl::Error getBaseTexture(IDirect3DBaseTexture9 **outTexture);
virtual gl::Error generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex);
virtual gl::Error copyToStorage(TextureStorage *destStorage);
private:
IDirect3DTexture9 *mTexture;
RenderTarget9 *mRenderTarget;
};
class TextureStorage9_Cube : public TextureStorage9
{
public:
TextureStorage9_Cube(Renderer9 *renderer, GLenum internalformat, bool renderTarget, int size, int levels, bool hintLevelZeroOnly);
virtual ~TextureStorage9_Cube();
gl::Error getCubeMapSurface(GLenum faceTarget, int level, bool dirty, IDirect3DSurface9 **outSurface);
virtual gl::Error getRenderTarget(const gl::ImageIndex &index, RenderTargetD3D **outRT);
virtual gl::Error getBaseTexture(IDirect3DBaseTexture9 **outTexture);
virtual gl::Error generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex);
virtual gl::Error copyToStorage(TextureStorage *destStorage);
private:
static const size_t CUBE_FACE_COUNT = 6;
IDirect3DCubeTexture9 *mTexture;
RenderTarget9 *mRenderTarget[CUBE_FACE_COUNT];
};
}
#endif // LIBANGLE_RENDERER_D3D_D3D9_TEXTURESTORAGE9_H_