/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
const auto src = !sourcePreprocessed.empty() ? reinterpret_cast<const char*>(sourcePreprocessed.data()) : reinterpret_cast<const char*>(createInfo.sourceData);
// null-terminated char already included. So we should remove last character (null terminator) from size.
- GLint size = (!sourcePreprocessed.empty() ? GLint(sourcePreprocessed.size()) : createInfo.sourceSize) - 1u;
+ GLint size = static_cast<GLint>(!sourcePreprocessed.empty() ? static_cast<uint32_t>(sourcePreprocessed.size()) : createInfo.sourceSize) - 1;
- gl->ShaderSource(shader, 1, const_cast<const char**>(&src), &size);
- gl->CompileShader(shader);
-
- GLint status{0};
- gl->GetShaderiv(shader, GL_COMPILE_STATUS, &status);
- if(status != GL_TRUE)
+ if(src != nullptr && size >= 0)
+ {
+ gl->ShaderSource(shader, 1, const_cast<const char**>(&src), &size);
+ gl->CompileShader(shader);
+
+ GLint status{0};
+ gl->GetShaderiv(shader, GL_COMPILE_STATUS, &status);
+ if(status != GL_TRUE)
+ {
+ char output[4096];
+ GLsizei outputSize{0u};
+ gl->GetShaderInfoLog(shader, 4096, &outputSize, output);
+ DALI_LOG_ERROR("Code: %.*s\n", size, reinterpret_cast<const char*>(src));
+ DALI_LOG_ERROR("glCompileShader() failed: \n%s\n", output);
+ gl->DeleteShader(shader);
+ return false;
+ }
+ glShader = shader;
+ }
+ else
{
- char output[4096];
- GLsizei outputSize{0u};
- gl->GetShaderInfoLog(shader, 4096, &outputSize, output);
- DALI_LOG_ERROR("Code: %.*s\n", size, reinterpret_cast<const char*>(src));
- DALI_LOG_ERROR("glCompileShader() failed: \n%s\n", output);
- gl->DeleteShader(shader);
+ DALI_LOG_ERROR("glCompileShader() failed: source is nullptr, or size is negative! src : %p, size : %d\n", src, size);
return false;
}
- glShader = shader;
}
return true;
}
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
{
DALI_LOG_INFO(gVulkanFilter, Debug::General, "Unable to allocate memory for the buffer of size %d!", int(requirements.size));
- mMemory = nullptr;
+ mMemory.reset();
}
// Bind
auto device = mDevice.GetLogicalDevice();
device.destroyBuffer(mBuffer, mDevice.GetAllocator());
- mMemory.reset();
mBuffer = nullptr;
- mMemory = nullptr;
+ mMemory.reset();
}
Graphics::MemoryRequirements BufferImpl::GetMemoryRequirements()
#define DALI_GRAPHICS_VULKAN_COMMAND_BUFFER_IMPL_H
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
std::vector<DeferredUniformBinding> mDeferredUniformBindings;
// Deferred pipeline to bind if dynamic states not supported
- Vulkan::Pipeline* mDeferredPipelineToBind;
+ Vulkan::Pipeline* mDeferredPipelineToBind{nullptr};
// Dynamic depth/stencil states for deferred pipeline binding if API < 1.3
// TODO: check API version
if(result != vk::Result::eSuccess)
{
DALI_LOG_INFO(gVulkanFilter, Debug::General, "Unable to allocate memory for the image of size %d!", int(requirements.size));
+
+ mMemory.reset();
}
- else if(mMemory) // bind the allocated memory to the image
+
+ if(mMemory) // bind the allocated memory to the image
{
VkAssert(mDevice.GetLogicalDevice().bindImageMemory(mImage, mMemory->GetVkHandle(), 0));
}
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
bool success = true;
if(createInfo.sourceMode == ShaderSourceMode::TEXT)
{
- SPIRVGeneratorInfo info;
- info.pipelineStage = createInfo.pipelineStage;
- auto shaderCode = std::string_view(reinterpret_cast<char*>(sourcePreprocessed.data()));
- info.shaderCode = shaderCode;
+ const auto src = !sourcePreprocessed.empty() ? reinterpret_cast<const char*>(sourcePreprocessed.data()) : reinterpret_cast<const char*>(createInfo.sourceData);
- spirv = std::make_unique<SPIRVGenerator>(info);
+ // null-terminated char already included. So we should remove last character (null terminator) from size.
+ int32_t size = static_cast<int32_t>(!sourcePreprocessed.empty() ? static_cast<uint32_t>(sourcePreprocessed.size()) : createInfo.sourceSize) - 1;
- spirv->Generate();
- if(spirv->IsValid())
+ if(src != nullptr && size >= 0)
{
- // substitute data and size with compiled code
- createInfo.sourceSize = spirv->Get().size() * 4u;
- createInfo.sourceData = spirv->Get().data();
+ SPIRVGeneratorInfo info;
+ info.pipelineStage = createInfo.pipelineStage;
+ auto shaderCode = std::string_view(src, size);
+ info.shaderCode = shaderCode;
+
+ spirv = std::make_unique<SPIRVGenerator>(info);
+
+ spirv->Generate();
+ if(spirv->IsValid())
+ {
+ // substitute data and size with compiled code
+ createInfo.sourceSize = spirv->Get().size() * 4u;
+ createInfo.sourceData = spirv->Get().data();
+ }
+ else
+ {
+ success = false;
+ }
}
else
{
#define DALI_GRAPHICS_VULKAN_SPIRV_H
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
*/
struct SPIRVGeneratorInfo
{
- std::string shaderCode;
- PipelineStage pipelineStage;
+ std::string shaderCode{};
+ PipelineStage pipelineStage{PipelineStage::TOP_OF_PIPELINE}; ///< Invalid stage
- struct SPIRVGeneratorExtraInfo* extraInfo; ///< Reserved
+ struct SPIRVGeneratorExtraInfo* extraInfo{nullptr}; ///< Reserved
};
/**
/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
return false;
}
- auto it = std::find_if(COLOR_CONVERSION_TABLE.begin(), COLOR_CONVERSION_TABLE.end(), [&](auto& item)
- { return item.oldFormat == mConvertFromFormat; });
+ auto it = std::find_if(COLOR_CONVERSION_TABLE.begin(), COLOR_CONVERSION_TABLE.end(), [&](auto& item) { return item.oldFormat == mConvertFromFormat; });
// No suitable format, return empty array
if(it == COLOR_CONVERSION_TABLE.end())
return false;
}
- auto it = std::find_if(COLOR_CONVERSION_TABLE.begin(), COLOR_CONVERSION_TABLE.end(), [&](auto& item)
- { return item.oldFormat == mConvertFromFormat; });
+ auto it = std::find_if(COLOR_CONVERSION_TABLE.begin(), COLOR_CONVERSION_TABLE.end(), [&](auto& item) { return item.oldFormat == mConvertFromFormat; });
// No suitable format, return empty array
if(it == COLOR_CONVERSION_TABLE.end())
return;
}
+ uint8_t* srcPtr = nullptr;
+ if(sourceInfo.sourceType == Dali::Graphics::TextureUpdateSourceInfo::Type::MEMORY)
+ {
+ srcPtr = reinterpret_cast<uint8_t*>(sourceInfo.memorySource.memory);
+ }
+ else if(sourceInfo.sourceType == Dali::Graphics::TextureUpdateSourceInfo::Type::PIXEL_DATA)
+ {
+ auto pixelBufferData = Dali::Integration::GetPixelDataBuffer(sourceInfo.pixelDataSource.pixelData);
+ srcPtr = pixelBufferData.buffer + info.srcOffset;
+ }
+ else
+ {
+ // TODO: other sources NOT support yet.
+ return;
+ }
+
// try to initialise resource
InitializeImageView();
auto dstRowLength = subresourceLayout.rowPitch;
auto dstPtr = ptr + int(dstRowLength) * info.dstOffset2D.y + sizeInBytes * info.dstOffset2D.x;
- uint8_t* srcPtr = nullptr;
- if(sourceInfo.sourceType == Dali::Graphics::TextureUpdateSourceInfo::Type::MEMORY)
- {
- srcPtr = reinterpret_cast<uint8_t*>(sourceInfo.memorySource.memory);
- }
- else if(sourceInfo.sourceType == Dali::Graphics::TextureUpdateSourceInfo::Type::PIXEL_DATA)
- {
- auto pixelBufferData = Dali::Integration::GetPixelDataBuffer(sourceInfo.pixelDataSource.pixelData);
- srcPtr = pixelBufferData.buffer + info.srcOffset;
- }
-
auto srcRowLength = int(info.srcExtent2D.width) * sizeInBytes;
if(formatInfo.compressed)
// if format isn't supported, see whether suitable conversion is implemented
if(!formatFlags)
{
- auto it = std::find_if(COLOR_CONVERSION_TABLE.begin(), COLOR_CONVERSION_TABLE.end(), [&](auto& item)
- { return item.oldFormat == sourceFormat; });
+ auto it = std::find_if(COLOR_CONVERSION_TABLE.begin(), COLOR_CONVERSION_TABLE.end(), [&](auto& item) { return item.oldFormat == sourceFormat; });
// No suitable format, return empty array
if(it != COLOR_CONVERSION_TABLE.end())