mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-17 07:31:01 +00:00
Delete unnecessary form of CreateTexture
This commit is contained in:
parent
5e92a94175
commit
d2c4cbacad
@ -92,7 +92,11 @@ bool ManagedTexture::LoadFromFileData(const uint8_t *data, size_t dataSize, Imag
|
||||
ELOG("Invalid num_levels: %d. Falling back to one. Image: %dx%d", num_levels, width[0], height[0]);
|
||||
num_levels = 1;
|
||||
}
|
||||
texture_->Create(Draw::LINEAR2D, fmt, width[0], height[0], 1, num_levels);
|
||||
|
||||
if (texture_)
|
||||
delete texture_;
|
||||
|
||||
texture_ = draw_->CreateTexture(Draw::LINEAR2D, fmt, width[0], height[0], 1, num_levels);
|
||||
for (int i = 0; i < num_levels; i++) {
|
||||
if (image[i]) {
|
||||
texture_->SetImageData(0, 0, 0, width[i], height[i], 1, i, width[i] * 4, image[i]);
|
||||
|
@ -13,9 +13,8 @@ enum ImageFileType {
|
||||
|
||||
class ManagedTexture : public GfxResourceHolder {
|
||||
public:
|
||||
ManagedTexture(Draw::DrawContext *draw) : draw_(draw) {
|
||||
ManagedTexture(Draw::DrawContext *draw) : draw_(draw), texture_(nullptr) {
|
||||
register_gl_resource_holder(this);
|
||||
texture_ = draw->CreateTexture();
|
||||
}
|
||||
~ManagedTexture() {
|
||||
unregister_gl_resource_holder(this);
|
||||
|
@ -491,7 +491,6 @@ public:
|
||||
|
||||
// Resources
|
||||
virtual Buffer *CreateBuffer(size_t size, uint32_t usageFlags) = 0;
|
||||
virtual Texture *CreateTexture() = 0; // To be later filled in by ->LoadFromFile or similar.
|
||||
virtual Texture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) = 0;
|
||||
virtual ShaderModule *CreateShaderModule(ShaderStage stage, ShaderLanguage language, const uint8_t *data, size_t dataSize) = 0;
|
||||
virtual Pipeline *CreateGraphicsPipeline(const PipelineDesc &desc) = 0;
|
||||
|
@ -351,8 +351,6 @@ private:
|
||||
|
||||
class D3D9Texture : public Texture {
|
||||
public:
|
||||
D3D9Texture(LPDIRECT3DDEVICE9 device, LPDIRECT3DDEVICE9EX deviceEx) : device_(device), deviceEx_(deviceEx), type_(TextureType::UNKNOWN), fmt_(D3DFMT_UNKNOWN), tex_(NULL), volTex_(NULL), cubeTex_(NULL) {
|
||||
}
|
||||
D3D9Texture(LPDIRECT3DDEVICE9 device, LPDIRECT3DDEVICE9EX deviceEx, TextureType type, DataFormat format, int width, int height, int depth, int mipLevels);
|
||||
~D3D9Texture();
|
||||
bool Create(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) override;
|
||||
@ -526,7 +524,6 @@ public:
|
||||
Buffer *CreateBuffer(size_t size, uint32_t usageFlags) override;
|
||||
Pipeline *CreateGraphicsPipeline(const PipelineDesc &desc) override;
|
||||
InputLayout *CreateInputLayout(const InputLayoutDesc &desc) override;
|
||||
Texture *CreateTexture() override;
|
||||
Texture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) override;
|
||||
|
||||
void BindTextures(int start, int count, Texture **textures) override;
|
||||
@ -695,11 +692,6 @@ RasterState *D3D9Context::CreateRasterState(const RasterStateDesc &desc) {
|
||||
return rs;
|
||||
}
|
||||
|
||||
Texture *D3D9Context::CreateTexture() {
|
||||
D3D9Texture *tex = new D3D9Texture(device_, deviceEx_);
|
||||
return tex;
|
||||
}
|
||||
|
||||
Texture *D3D9Context::CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) {
|
||||
D3D9Texture *tex = new D3D9Texture(device_, deviceEx_, type, format, width, height, depth, mipLevels);
|
||||
return tex;
|
||||
|
@ -513,7 +513,6 @@ public:
|
||||
ShaderModule *CreateShaderModule(ShaderStage stage, ShaderLanguage language, const uint8_t *data, size_t dataSize) override;
|
||||
|
||||
Texture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) override;
|
||||
Texture *CreateTexture() override;
|
||||
|
||||
void BindSamplerStates(int start, int count, SamplerState **states) override {
|
||||
if (samplerStates_.size() < (size_t)(start + count)) {
|
||||
@ -636,18 +635,9 @@ GLuint TypeToTarget(TextureType type) {
|
||||
}
|
||||
}
|
||||
|
||||
class Thin3DGLTexture : public Texture, GfxResourceHolder {
|
||||
class OpenGLTexture : public Texture, GfxResourceHolder {
|
||||
public:
|
||||
Thin3DGLTexture() : tex_(0), target_(0) {
|
||||
generatedMips_ = false;
|
||||
canWrap_ = true;
|
||||
width_ = 0;
|
||||
height_ = 0;
|
||||
depth_ = 0;
|
||||
glGenTextures(1, &tex_);
|
||||
register_gl_resource_holder(this);
|
||||
}
|
||||
Thin3DGLTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) : tex_(0), target_(TypeToTarget(type)), format_(format), mipLevels_(mipLevels) {
|
||||
OpenGLTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) : tex_(0), target_(TypeToTarget(type)), format_(format), mipLevels_(mipLevels) {
|
||||
generatedMips_ = false;
|
||||
canWrap_ = true;
|
||||
width_ = width;
|
||||
@ -656,7 +646,7 @@ public:
|
||||
glGenTextures(1, &tex_);
|
||||
register_gl_resource_holder(this);
|
||||
}
|
||||
~Thin3DGLTexture() {
|
||||
~OpenGLTexture() {
|
||||
unregister_gl_resource_holder(this);
|
||||
Destroy();
|
||||
}
|
||||
@ -715,15 +705,11 @@ private:
|
||||
bool canWrap_;
|
||||
};
|
||||
|
||||
Texture *OpenGLContext::CreateTexture() {
|
||||
return new Thin3DGLTexture();
|
||||
}
|
||||
|
||||
Texture *OpenGLContext::CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) {
|
||||
return new Thin3DGLTexture(type, format, width, height, depth, mipLevels);
|
||||
return new OpenGLTexture(type, format, width, height, depth, mipLevels);
|
||||
}
|
||||
|
||||
void Thin3DGLTexture::AutoGenMipmaps() {
|
||||
void OpenGLTexture::AutoGenMipmaps() {
|
||||
if (!generatedMips_) {
|
||||
Bind();
|
||||
glGenerateMipmap(target_);
|
||||
@ -733,7 +719,7 @@ void Thin3DGLTexture::AutoGenMipmaps() {
|
||||
}
|
||||
}
|
||||
|
||||
void Thin3DGLTexture::SetImageData(int x, int y, int z, int width, int height, int depth, int level, int stride, const uint8_t *data) {
|
||||
void OpenGLTexture::SetImageData(int x, int y, int z, int width, int height, int depth, int level, int stride, const uint8_t *data) {
|
||||
int internalFormat;
|
||||
int format;
|
||||
int type;
|
||||
@ -772,7 +758,7 @@ bool isPowerOf2(int n) {
|
||||
return n == 1 || (n & (n - 1)) == 0;
|
||||
}
|
||||
|
||||
void Thin3DGLTexture::Finalize() {
|
||||
void OpenGLTexture::Finalize() {
|
||||
canWrap_ = !isPowerOf2(width_) || !isPowerOf2(height_);
|
||||
}
|
||||
|
||||
@ -912,7 +898,7 @@ Pipeline *OpenGLContext::CreateGraphicsPipeline(const PipelineDesc &desc) {
|
||||
|
||||
void OpenGLContext::BindTextures(int start, int count, Texture **textures) {
|
||||
for (int i = start; i < start + count; i++) {
|
||||
Thin3DGLTexture *glTex = static_cast<Thin3DGLTexture *>(textures[i]);
|
||||
OpenGLTexture *glTex = static_cast<OpenGLTexture *>(textures[i]);
|
||||
glActiveTexture(GL_TEXTURE0 + i);
|
||||
glTex->Bind();
|
||||
|
||||
|
@ -365,7 +365,6 @@ public:
|
||||
ShaderModule *CreateShaderModule(ShaderStage stage, ShaderLanguage language, const uint8_t *data, size_t dataSize) override;
|
||||
|
||||
Texture *CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) override;
|
||||
Texture *CreateTexture() override;
|
||||
|
||||
void SetScissorRect(int left, int top, int width, int height) override;
|
||||
void SetViewports(int count, Viewport *viewports) override;
|
||||
@ -564,9 +563,6 @@ enum class TextureState {
|
||||
|
||||
class VKTexture : public Texture {
|
||||
public:
|
||||
VKTexture(VulkanContext *vulkan) : vulkan_(vulkan), vkTex_(nullptr) {
|
||||
}
|
||||
|
||||
VKTexture(VulkanContext *vulkan, TextureType type, DataFormat format, int width, int height, int depth, int mipLevels)
|
||||
: vulkan_(vulkan), format_(format), mipLevels_(mipLevels) {
|
||||
Create(type, format, width, height, depth, mipLevels);
|
||||
@ -944,10 +940,6 @@ InputLayout *VKContext::CreateInputLayout(const InputLayoutDesc &desc) {
|
||||
return vl;
|
||||
}
|
||||
|
||||
Texture *VKContext::CreateTexture() {
|
||||
return new VKTexture(vulkan_);
|
||||
}
|
||||
|
||||
Texture *VKContext::CreateTexture(TextureType type, DataFormat format, int width, int height, int depth, int mipLevels) {
|
||||
return new VKTexture(vulkan_, type, format, width, height, depth, mipLevels);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user