#include <dali/internal/graphics/gles-impl/gles-graphics-shader.h>
#include <dali/internal/graphics/gles-impl/gles-graphics-texture.h>
#include <dali/internal/graphics/gles-impl/gles-graphics-types.h>
+#include <dali/internal/graphics/gles-impl/gles3-graphics-memory.h>
#include <dali/public-api/common/dali-common.h>
#include "gles-graphics-program.h"
// in case when the buffer is not there yet
ProcessCreateQueues();
- return Graphics::UniquePtr<Memory>(new GLES::Memory(mapInfo, *this));
+ if(GetGLESVersion() < GLES::GLESVersion::GLES_30)
+ {
+ return Graphics::UniquePtr<Memory>(new GLES::Memory2(mapInfo, *this));
+ }
+ else
+ {
+ return Graphics::UniquePtr<Memory>(new GLES::Memory3(mapInfo, *this));
+ }
}
bool EglGraphicsController::GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData)
// INTERNAL INCLUDES
#include "gles-context.h"
#include "gles-graphics-buffer.h"
-#include "gles-graphics-memory.h"
#include "gles-graphics-pipeline-cache.h"
#include "gles-graphics-pipeline.h"
#include "gles-graphics-reflection.h"
#include "gles-graphics-sampler.h"
#include "gles-graphics-texture.h"
+#include "gles-graphics-types.h"
+#include "gles2-graphics-memory.h"
namespace Dali
{
*/
[[nodiscard]] GLES::PipelineCache& GetPipelineCache() const;
+ /**
+ * @brief Returns runtime supported GLES version
+ *
+ * @return GLES version enum
+ */
+ GLES::GLESVersion GetGLESVersion() const
+ {
+ // TODO: return proper version but for now we can
+ // test fallbacks
+ return GLES::GLESVersion::GLES_20;
+ }
+
private:
Integration::GlAbstraction* mGlAbstraction{nullptr};
Integration::GlSyncAbstraction* mGlSyncAbstraction{nullptr};
${adaptor_graphics_dir}/gles-impl/gles-graphics-command-buffer.cpp
${adaptor_graphics_dir}/gles-impl/gles-graphics-debug.cpp
${adaptor_graphics_dir}/gles-impl/gles-graphics-framebuffer.cpp
- ${adaptor_graphics_dir}/gles-impl/gles-graphics-memory.cpp
+ ${adaptor_graphics_dir}/gles-impl/gles2-graphics-memory.cpp
+ ${adaptor_graphics_dir}/gles-impl/gles3-graphics-memory.cpp
${adaptor_graphics_dir}/gles-impl/gles-graphics-pipeline.cpp
${adaptor_graphics_dir}/gles-impl/gles-graphics-program.cpp
${adaptor_graphics_dir}/gles-impl/gles-graphics-reflection.cpp
GLType type{GLType::UNDEFINED};
};
+enum class GLESVersion
+{
+ GLES_20 = 20,
+ GLES_30 = 30,
+ GLES_31 = 31,
+ GLES_32 = 32
+};
+
} // namespace Dali::Graphics::GLES
#endif //DALI_GRAPHICS_API_TYPES_H
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "gles2-graphics-memory.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/gl-abstraction.h>
+#include <dali/integration-api/gl-defines.h>
+
+// INTERNAL INCLUDES
+#include "egl-graphics-controller.h"
+#include "gles-graphics-buffer.h"
+
+namespace Dali::Graphics::GLES
+{
+Memory2::Memory2(const Graphics::MapBufferInfo& mapInfo, EglGraphicsController& controller)
+: mController(controller)
+{
+ mMapBufferInfo = mapInfo;
+ mMapObjectType = MapObjectType::BUFFER;
+}
+
+Memory2::Memory2(const Graphics::MapTextureInfo& mapInfo, EglGraphicsController& controller)
+: mController(controller)
+{
+ mMapTextureInfo = mapInfo;
+ mMapObjectType = MapObjectType::TEXTURE;
+}
+
+Memory2::~Memory2()
+{
+ //Unlock(true);
+}
+
+void* Memory2::LockRegion(uint32_t offset, uint32_t size)
+{
+ // allocate temporary buffer (reading back may not be supported)
+ // emulated buffer is always mapped from beginning
+ if(mMapObjectType == MapObjectType::BUFFER)
+ {
+ auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
+ if(buffer->IsCPUAllocated())
+ {
+ using Ptr = char*;
+ mMappedPointer = Ptr(buffer->GetCPUAllocatedAddress()) + offset;
+ mIsAllocatedLocally = false;
+ }
+ else
+ {
+ auto retval = malloc(size);
+ mMappedPointer = retval;
+ mIsAllocatedLocally = true;
+ }
+ }
+
+ return mMappedPointer;
+}
+
+void Memory2::Unlock(bool flush)
+{
+ auto gl = mController.GetGL();
+
+ // for buffer...
+ if(mMapObjectType == MapObjectType::BUFFER&& mMappedPointer)
+ {
+ auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
+ if(!buffer->IsCPUAllocated())
+ {
+ buffer->Bind(BufferUsage::VERTEX_BUFFER);
+ gl->BufferSubData(GL_ARRAY_BUFFER, mMapBufferInfo.offset, mMapBufferInfo.size, mMappedPointer);
+ }
+ }
+
+ if(mIsAllocatedLocally)
+ {
+ free(mMappedPointer);
+ mMappedPointer = nullptr;
+ }
+
+ if(flush)
+ {
+ Flush();
+ }
+}
+
+void Memory2::Flush()
+{
+ // TODO:
+}
+
+} // namespace Dali::Graphics::GLES
\ No newline at end of file
class EglGraphicsController;
namespace GLES
{
-class Memory : public Dali::Graphics::Memory
+class Memory2 : public Dali::Graphics::Memory
{
public:
- Memory(const Graphics::MapBufferInfo& mapInfo, EglGraphicsController& controller);
+ Memory2(const Graphics::MapBufferInfo& mapInfo, EglGraphicsController& controller);
- Memory(const Graphics::MapTextureInfo& mapInfo, EglGraphicsController& controller);
+ Memory2(const Graphics::MapTextureInfo& mapInfo, EglGraphicsController& controller);
- ~Memory() override;
+ ~Memory2() override;
void* LockRegion(uint32_t offset, uint32_t size) override;
};
void* mMappedPointer{nullptr};
+ bool mIsAllocatedLocally{false};
};
} // namespace GLES
} // namespace Dali::Graphics
*/
// CLASS HEADER
-#include "gles-graphics-memory.h"
+#include "gles3-graphics-memory.h"
// EXTERNAL INCLUDES
#include <dali/integration-api/gl-abstraction.h>
namespace Dali::Graphics::GLES
{
-Memory::Memory(const Graphics::MapBufferInfo& mapInfo, EglGraphicsController& controller)
+Memory3::Memory3(const Graphics::MapBufferInfo& mapInfo, EglGraphicsController& controller)
: mController(controller)
{
mMapBufferInfo = mapInfo;
mMapObjectType = MapObjectType::BUFFER;
}
-Memory::Memory(const Graphics::MapTextureInfo& mapInfo, EglGraphicsController& controller)
+Memory3::Memory3(const Graphics::MapTextureInfo& mapInfo, EglGraphicsController& controller)
: mController(controller)
{
mMapTextureInfo = mapInfo;
mMapObjectType = MapObjectType::TEXTURE;
}
-Memory::~Memory()
+Memory3::~Memory3()
{
Unlock(true);
}
-void* Memory::LockRegion(uint32_t offset, uint32_t size)
+void* Memory3::LockRegion(uint32_t offset, uint32_t size)
{
auto gl = mController.GetGL();
return nullptr;
}
-void Memory::Unlock(bool flush)
+void Memory3::Unlock(bool flush)
{
auto gl = mController.GetGL();
if(mMapObjectType == MapObjectType::BUFFER && mMappedPointer)
{
auto buffer = static_cast<GLES::Buffer*>(mMapBufferInfo.buffer);
- buffer->Bind(Graphics::BufferUsage::VERTEX_BUFFER);
- gl->UnmapBuffer(GL_ARRAY_BUFFER);
+ if(!buffer->IsCPUAllocated())
+ {
+ buffer->Bind(Graphics::BufferUsage::VERTEX_BUFFER);
+ gl->UnmapBuffer(GL_ARRAY_BUFFER);
+ }
}
if(flush)
}
}
-void Memory::Flush()
+void Memory3::Flush()
{
// TODO:
}
--- /dev/null
+#ifndef DALI_GRAPHICS_GLES3_MEMORY_H
+#define DALI_GRAPHICS_GLES3_MEMORY_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/graphics-api/graphics-memory.h>
+#include <cstdint>
+
+// INTERNAL INCLUDES
+#include "gles-graphics-buffer.h"
+#include "gles-graphics-texture.h"
+
+namespace Dali::Graphics
+{
+class EglGraphicsController;
+namespace GLES
+{
+class Memory3 : public Dali::Graphics::Memory
+{
+public:
+ Memory3(const Graphics::MapBufferInfo& mapInfo, EglGraphicsController& controller);
+
+ Memory3(const Graphics::MapTextureInfo& mapInfo, EglGraphicsController& controller);
+
+ ~Memory3() override;
+
+ void* LockRegion(uint32_t offset, uint32_t size) override;
+
+ void Unlock(bool flush) override;
+
+ void Flush() override;
+
+ EglGraphicsController& mController;
+
+ enum class MapObjectType
+ {
+ NONE,
+ BUFFER,
+ TEXTURE
+ };
+
+ MapObjectType mMapObjectType{MapObjectType::NONE};
+
+ union
+ {
+ Graphics::MapTextureInfo mMapTextureInfo{};
+ Graphics::MapBufferInfo mMapBufferInfo;
+ };
+
+ void* mMappedPointer{nullptr};
+};
+} // namespace GLES
+} // namespace Dali::Graphics
+
+#endif
\ No newline at end of file