X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fgraphics%2Fgles-impl%2Fgles-graphics-types.h;h=dc90a9824b72673c80fcd41400ae03275d5789c3;hb=3945e7fc5c0a91098047c3d459e75638064f2802;hp=31b9f6dca440671991daf0dcb101d058940acc76;hpb=60b8e6be89e7869a716c7040000564d68dc2eddc;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/graphics/gles-impl/gles-graphics-types.h b/dali/internal/graphics/gles-impl/gles-graphics-types.h index 31b9f6d..dc90a98 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-types.h +++ b/dali/internal/graphics/gles-impl/gles-graphics-types.h @@ -9,6 +9,10 @@ namespace Dali::Graphics::GLES { class Buffer; +class RenderPass; +class RenderTarget; +class Framebuffer; + // Conversion functions /** * Stucture delivers format and type that can be used @@ -544,7 +548,7 @@ struct GLTextureFormatType case Graphics::Format::R16G16B16_SFLOAT: { // GLES 3.0 floating point formats. - Assign(GL_RGB, GL_HALF_FLOAT); + AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_HALF_FLOAT); // DALi uses compact internal format break; } case Graphics::Format::R16G16B16A16_UNORM: @@ -624,8 +628,7 @@ struct GLTextureFormatType } case Graphics::Format::R32G32B32_SFLOAT: { - // GLES 3.0 floating point formats. - Assign(GL_RGB, GL_FLOAT); + AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_FLOAT); // DALi uses compact internal format break; } case Graphics::Format::R32G32B32A32_UINT: @@ -703,6 +706,11 @@ struct GLTextureFormatType Assign(0, 0); break; } + case Graphics::Format::R11G11B10_UFLOAT_PACK32: + { + AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_FLOAT); + break; + } case Graphics::Format::B10G11R11_UFLOAT_PACK32: { Assign(0, 0); @@ -727,7 +735,7 @@ struct GLTextureFormatType case Graphics::Format::D32_SFLOAT: { // GLES 3.0 depth and stencil formats - Assign(GL_DEPTH_COMPONENT, GL_FLOAT); + AssignInternal(GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT32F, GL_FLOAT); break; } case Graphics::Format::S8_UINT: @@ -743,7 +751,7 @@ struct GLTextureFormatType case Graphics::Format::D24_UNORM_S8_UINT: { // GLES 3.0 depth and stencil formats - Assign(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8); + AssignInternal(GL_DEPTH_STENCIL, GL_DEPTH24_STENCIL8, GL_UNSIGNED_INT_24_8); break; } case Graphics::Format::D32_SFLOAT_S8_UINT: @@ -857,12 +865,12 @@ struct GLTextureFormatType } case Graphics::Format::ETC2_R8G8B8A8_UNORM_BLOCK: { - Assign(0, 0); + Assign(GL_COMPRESSED_RGBA8_ETC2_EAC, 0); break; } case Graphics::Format::ETC2_R8G8B8A8_SRGB_BLOCK: { - Assign(0, 0); + Assign(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, 0); break; } case Graphics::Format::EAC_R11_UNORM_BLOCK: @@ -1104,14 +1112,87 @@ struct GLTextureFormatType constexpr inline void Assign(uint32_t f, uint32_t t) { - format = f; - type = t; + format = f; + internalFormat = f; + type = t; + } + constexpr inline void AssignInternal(uint32_t f, uint32_t i, uint32_t t) + { + format = f; + internalFormat = i; + type = t; } uint32_t format{0}; + uint32_t internalFormat{0}; uint32_t type{0}; }; +struct FormatCompression +{ + /** + * Constuctor from Graphics::Format + * @param value + */ + constexpr explicit FormatCompression(Graphics::Format value) + { + switch(value) + { + case Graphics::Format::ETC2_R8G8B8_UNORM_BLOCK: + case Graphics::Format::ETC2_R8G8B8_SRGB_BLOCK: + case Graphics::Format::ETC2_R8G8B8A1_UNORM_BLOCK: + case Graphics::Format::ETC2_R8G8B8A1_SRGB_BLOCK: + case Graphics::Format::ETC2_R8G8B8A8_UNORM_BLOCK: + case Graphics::Format::ETC2_R8G8B8A8_SRGB_BLOCK: + case Graphics::Format::EAC_R11_UNORM_BLOCK: + case Graphics::Format::EAC_R11_SNORM_BLOCK: + case Graphics::Format::EAC_R11G11_UNORM_BLOCK: + case Graphics::Format::EAC_R11G11_SNORM_BLOCK: + case Graphics::Format::ASTC_4x4_UNORM_BLOCK: + case Graphics::Format::ASTC_4x4_SRGB_BLOCK: + case Graphics::Format::ASTC_5x4_UNORM_BLOCK: + case Graphics::Format::ASTC_5x4_SRGB_BLOCK: + case Graphics::Format::ASTC_5x5_UNORM_BLOCK: + case Graphics::Format::ASTC_5x5_SRGB_BLOCK: + case Graphics::Format::ASTC_6x5_UNORM_BLOCK: + case Graphics::Format::ASTC_6x5_SRGB_BLOCK: + case Graphics::Format::ASTC_6x6_UNORM_BLOCK: + case Graphics::Format::ASTC_6x6_SRGB_BLOCK: + case Graphics::Format::ASTC_8x5_UNORM_BLOCK: + case Graphics::Format::ASTC_8x5_SRGB_BLOCK: + case Graphics::Format::ASTC_8x6_UNORM_BLOCK: + case Graphics::Format::ASTC_8x6_SRGB_BLOCK: + case Graphics::Format::ASTC_8x8_UNORM_BLOCK: + case Graphics::Format::ASTC_8x8_SRGB_BLOCK: + case Graphics::Format::ASTC_10x5_UNORM_BLOCK: + case Graphics::Format::ASTC_10x5_SRGB_BLOCK: + case Graphics::Format::ASTC_10x6_UNORM_BLOCK: + case Graphics::Format::ASTC_10x6_SRGB_BLOCK: + case Graphics::Format::ASTC_10x8_UNORM_BLOCK: + case Graphics::Format::ASTC_10x8_SRGB_BLOCK: + case Graphics::Format::ASTC_10x10_UNORM_BLOCK: + case Graphics::Format::ASTC_10x10_SRGB_BLOCK: + case Graphics::Format::ASTC_12x10_UNORM_BLOCK: + case Graphics::Format::ASTC_12x10_SRGB_BLOCK: + case Graphics::Format::ASTC_12x12_UNORM_BLOCK: + case Graphics::Format::ASTC_12x12_SRGB_BLOCK: + case Graphics::Format::PVRTC1_2BPP_UNORM_BLOCK_IMG: + case Graphics::Format::PVRTC1_4BPP_UNORM_BLOCK_IMG: + case Graphics::Format::PVRTC2_2BPP_UNORM_BLOCK_IMG: + case Graphics::Format::PVRTC2_4BPP_UNORM_BLOCK_IMG: + case Graphics::Format::PVRTC1_2BPP_SRGB_BLOCK_IMG: + case Graphics::Format::PVRTC1_4BPP_SRGB_BLOCK_IMG: + case Graphics::Format::PVRTC2_2BPP_SRGB_BLOCK_IMG: + case Graphics::Format::PVRTC2_4BPP_SRGB_BLOCK_IMG: + compressed = true; + break; + default: + break; + } + } + bool compressed{false}; +}; + struct GLSamplerFilter { constexpr explicit GLSamplerFilter(Graphics::SamplerFilter filter) @@ -1331,6 +1412,76 @@ struct GLAddressMode GLenum texParameter{GL_CLAMP_TO_EDGE}; }; +struct GLCompareOp +{ + constexpr explicit GLCompareOp(Graphics::CompareOp compareOp) + { + switch(compareOp) + { + case Graphics::CompareOp::NEVER: + op = GL_NEVER; + break; + case Graphics::CompareOp::LESS: + op = GL_LESS; + break; + case Graphics::CompareOp::EQUAL: + op = GL_EQUAL; + break; + case Graphics::CompareOp::LESS_OR_EQUAL: + op = GL_LEQUAL; + break; + case Graphics::CompareOp::GREATER: + op = GL_GREATER; + break; + case Graphics::CompareOp::NOT_EQUAL: + op = GL_NOTEQUAL; + break; + case Graphics::CompareOp::GREATER_OR_EQUAL: + op = GL_GEQUAL; + break; + case Graphics::CompareOp::ALWAYS: + op = GL_ALWAYS; + break; + } + } + GLenum op{GL_LESS}; +}; + +struct GLStencilOp +{ + constexpr explicit GLStencilOp(Graphics::StencilOp stencilOp) + { + switch(stencilOp) + { + case Graphics::StencilOp::KEEP: + op = GL_KEEP; + break; + case Graphics::StencilOp::ZERO: + op = GL_ZERO; + break; + case Graphics::StencilOp::REPLACE: + op = GL_REPLACE; + break; + case Graphics::StencilOp::INCREMENT_AND_CLAMP: + op = GL_INCR; + break; + case Graphics::StencilOp::DECREMENT_AND_CLAMP: + op = GL_DECR; + break; + case Graphics::StencilOp::INVERT: + op = GL_INVERT; + break; + case Graphics::StencilOp::INCREMENT_AND_WRAP: + op = GL_INCR_WRAP; + break; + case Graphics::StencilOp::DECREMENT_AND_WRAP: + op = GL_DECR_WRAP; + break; + } + } + GLenum op{GL_KEEP}; +}; + /** * @brief Descriptor of single buffer binding within * command buffer. @@ -1376,7 +1527,7 @@ struct DrawCallDescriptor { DRAW, DRAW_INDEXED, - DRAW_INDEXED_INDIRECT + DRAW_INDEXED_INDIRECT, }; Type type{}; ///< Type of the draw call @@ -1669,6 +1820,81 @@ struct GLBlendOp glBlendOp = GL_MAX; break; } + case Graphics::BlendOp::MULTIPLY: + { + glBlendOp = GL_MULTIPLY; + break; + } + case Graphics::BlendOp::SCREEN: + { + glBlendOp = GL_SCREEN; + break; + } + case Graphics::BlendOp::OVERLAY: + { + glBlendOp = GL_OVERLAY; + break; + } + case Graphics::BlendOp::DARKEN: + { + glBlendOp = GL_DARKEN; + break; + } + case Graphics::BlendOp::LIGHTEN: + { + glBlendOp = GL_LIGHTEN; + break; + } + case Graphics::BlendOp::COLOR_DODGE: + { + glBlendOp = GL_COLORDODGE; + break; + } + case Graphics::BlendOp::COLOR_BURN: + { + glBlendOp = GL_COLORBURN; + break; + } + case Graphics::BlendOp::HARD_LIGHT: + { + glBlendOp = GL_HARDLIGHT; + break; + } + case Graphics::BlendOp::SOFT_LIGHT: + { + glBlendOp = GL_SOFTLIGHT; + break; + } + case Graphics::BlendOp::DIFFERENCE: + { + glBlendOp = GL_DIFFERENCE; + break; + } + case Graphics::BlendOp::EXCLUSION: + { + glBlendOp = GL_EXCLUSION; + break; + } + case Graphics::BlendOp::HUE: + { + glBlendOp = GL_HSL_HUE; + break; + } + case Graphics::BlendOp::SATURATION: + { + glBlendOp = GL_HSL_SATURATION; + break; + } + case Graphics::BlendOp::COLOR: + { + glBlendOp = GL_HSL_COLOR; + break; + } + case Graphics::BlendOp::LUMINOSITY: + { + glBlendOp = GL_HSL_LUMINOSITY; + break; + } } } @@ -1858,6 +2084,78 @@ struct GLTypeConversion GLType type{GLType::UNDEFINED}; }; +enum class GLESVersion +{ + GLES_20 = 20, + GLES_30 = 30, + GLES_31 = 31, + GLES_32 = 32 +}; + +/** + * @brief Types of bond texture cached in the context + */ +enum class BoundTextureType +{ + TEXTURE_2D, + TEXTURE_3D, + TEXTURE_CUBEMAP, + TEXTURE_EXTERNAL_OES +}; + +/** + * This class stores indirect pointer, used by the CommandBuffer + * to store data allocated within resizeable pool + */ +template +struct IndirectPtr +{ + uint32_t ptr; // relative pointer + void** base; // base pointer + + inline T* operator->() + { + return reinterpret_cast((reinterpret_cast(*base) + ptr)); + } + + inline T& operator*() + { + return *reinterpret_cast((reinterpret_cast(*base) + ptr)); + } + + // Returns indirect pointer casted to requested type + T* Ptr() const + { + auto val = reinterpret_cast((reinterpret_cast(*base) + ptr)); + return val; + } + + inline T& operator[](int index) + { + return reinterpret_cast((reinterpret_cast(*base) + ptr))[index]; + } + + // Fake assignment operator for void* type + inline IndirectPtr& operator=(void* p) + { + ptr = 0; + base = nullptr; + return *this; + } +}; + +/** + * The descriptor of BeginRenderPass command + */ +struct BeginRenderPassDescriptor +{ + const GLES::RenderPass* renderPass; + const GLES::RenderTarget* renderTarget; + Rect2D renderArea; + IndirectPtr clearValues; + uint32_t clearValuesCount; +}; + } // namespace Dali::Graphics::GLES #endif //DALI_GRAPHICS_API_TYPES_H