// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Graphics/Textures/GPUTexture.h" #include "GPUDeviceOGL.h" #include "GPUResourceOGL.h" #include "GPUTextureViewOGL.h" #if GRAPHICS_API_OPENGL /// /// Texture object for OpenGL /// class GPUTextureOGL : public GPUResourceOGL { private: GPUTextureViewOGL _uav; GPUTextureViewOGL _handleArray; GPUTextureViewOGL _handleVolume; Array _handlesPerSlice; // [slice] Array> _handlesPerMip; // [slice][mip] public: /// /// Initializes a new instance of the class. /// /// The device. /// The name. GPUTextureOGL(GPUDeviceOGL* device, const String& name); /// /// Finalizes an instance of the class. /// ~GPUTextureOGL() { } public: GLuint TextureID = 0; GLenum Target = 0; GLenum FormatGL = 0; GPUTextureViewOGL* HandleUAV() const { ASSERT((GetDescription().Flags & GPUTextureFlags::UnorderedAccess) != 0); return (GPUTextureViewOGL*)&_uav; } private: void initHandles(); public: // [GPUTexture] GPUTextureView* Handle(int32 arrayOrDepthIndex) const override { return (GPUTextureView*)&_handlesPerSlice[arrayOrDepthIndex]; } GPUTextureView* Handle(int32 arrayOrDepthIndex, int32 mipMapIndex) const override { return (GPUTextureView*)&_handlesPerMip[arrayOrDepthIndex][mipMapIndex]; } GPUTextureView* ViewArray() const override { ASSERT(ArraySize() > 1); return (GPUTextureView*)&_handleArray; } GPUTextureView* ViewVolume() const override { ASSERT(IsVolume()); return (GPUTextureView*)&_handleVolume; } bool GetData(int32 arrayOrDepthSliceIndex, int32 mipMapIndex, TextureData::MipData& data, uint32 mipRowPitch) override; protected: // [GPUTexture] bool OnInit() override; void onResidentMipsChanged() override; void OnReleaseGPU() override; }; #endif