• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Amber Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "src/vulkan/pipeline.h"
16 
17 #include "gtest/gtest.h"
18 #include "src/pipeline.h"
19 #include "src/vulkan/compute_pipeline.h"
20 
21 namespace amber {
22 namespace vulkan {
23 
24 using VulkanPipelineTest = testing::Test;
25 
TEST_F(VulkanPipelineTest,AddBufferDescriptorAddPushConstant)26 TEST_F(VulkanPipelineTest, AddBufferDescriptorAddPushConstant) {
27   amber::Pipeline amber_pipeline(PipelineType::kCompute);
28   std::vector<VkPipelineShaderStageCreateInfo> create_infos;
29   ComputePipeline pipeline(nullptr, 0, create_infos);
30 
31   auto cmd = MakeUnique<BufferCommand>(BufferCommand::BufferType::kPushConstant,
32                                        &amber_pipeline);
33   // Push constant buffers should not be passed to AddBufferDescriptor().
34   Result r = pipeline.AddBufferDescriptor(cmd.get());
35   ASSERT_FALSE(r.IsSuccess());
36 }
37 
TEST_F(VulkanPipelineTest,AddBufferDescriptorAddBufferTwice)38 TEST_F(VulkanPipelineTest, AddBufferDescriptorAddBufferTwice) {
39   amber::Pipeline amber_pipeline(PipelineType::kCompute);
40   std::vector<VkPipelineShaderStageCreateInfo> create_infos;
41   ComputePipeline pipeline(nullptr, 0, create_infos);
42 
43   auto cmd = MakeUnique<BufferCommand>(BufferCommand::BufferType::kUniform,
44                                        &amber_pipeline);
45   Result r = pipeline.AddBufferDescriptor(cmd.get());
46   ASSERT_TRUE(r.IsSuccess()) << r.Error();
47   // Adding same buffer again should fail.
48   r = pipeline.AddBufferDescriptor(cmd.get());
49   ASSERT_FALSE(r.IsSuccess());
50 }
51 
52 }  // namespace vulkan
53 }  // namespace amber
54