2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali/graphics/vulkan/api/vulkan-api-shader-factory.h>
19 #include <dali/graphics/vulkan/api/vulkan-api-shader.h>
20 #include <dali/graphics/vulkan/vulkan-graphics.h>
21 #include <dali/graphics/vulkan/vulkan-shader.h>
30 ShaderFactory::ShaderFactory( Vulkan::Graphics& graphics ) :
35 ShaderFactory::~ShaderFactory() = default;
37 ShaderFactory& ShaderFactory::SetShaderModule( Graphics::API::ShaderDetails::PipelineStage pipelineStage,
38 Graphics::API::ShaderDetails::Language language,
39 const Graphics::API::ShaderDetails::ShaderSource& source )
41 using PipelineStage = Graphics::API::ShaderDetails::PipelineStage;
42 if( pipelineStage == PipelineStage::VERTEX )
44 mVertexShader = ShaderModuleInfo( pipelineStage, language, source );
46 else if( pipelineStage == PipelineStage::FRAGMENT )
48 mFragmentShader = ShaderModuleInfo( pipelineStage, language, source );
53 std::unique_ptr<Graphics::API::Shader> ShaderFactory::Create() const
55 if( !mVertexShader.source.IsSet() || !mFragmentShader.source.IsSet() )
60 auto retval = std::make_unique<VulkanAPI::Shader>( mGraphics );
63 retval->AddShaderModule( mVertexShader.pipelineStage, mVertexShader.language, mVertexShader.source );
65 // add fragment shader
66 retval->AddShaderModule( mFragmentShader.pipelineStage, mFragmentShader.language, mFragmentShader.source );
68 return std::move(retval);
71 } // namespace VulkanAPI
72 } // namespace Graphics