Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Pipeline {
const Shader* GetShader() const { return shader_; }

void SetEntryPoint(const std::string& ep) { entry_point_ = ep; }
std::string GetEntryPoint() const { return entry_point_; }
const std::string& GetEntryPoint() const { return entry_point_; }

void SetShaderType(ShaderType type) { shader_type_ = type; }
ShaderType GetShaderType() const { return shader_type_; }
Expand Down
12 changes: 12 additions & 0 deletions src/vulkan/engine_vulkan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ Result EngineVulkan::CreatePipeline(amber::Pipeline* pipeline) {

info.vk_pipeline = std::move(vk_pipeline);

// Set the entry point names for the pipeline.
for (const auto& shader_info : pipeline->GetShaders()) {
VkShaderStageFlagBits stage = VK_SHADER_STAGE_FLAG_BITS_MAX_ENUM;
r = ToVkShaderStage(shader_info.GetShaderType(), &stage);
if (!r.IsSuccess())
return r;
const auto& name = shader_info.GetEntryPoint();
if (!name.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is empty, it would be better to just return an error here?

if (name.empty())
  return Result("Vulkan: pipeline entry point is empty");
info.vk_pipeline->SetEntryPointName(stage, name);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is valid to not set an entry name if you plan to use the default name.

info.vk_pipeline->SetEntryPointName(stage, name);
}
}

for (const auto& vtex_info : pipeline->GetVertexBuffers()) {
auto fmt = vtex_info.buffer->GetFormat();
if (!device_->IsFormatSupportedByPhysicalDevice(*fmt, vtex_info.buffer))
Expand Down
75 changes: 75 additions & 0 deletions tests/cases/non_default_entry_point.amber
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!amber
# Copyright 2019 The Amber Authors.
#
# 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
#
# https://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.

SHADER compute my_shader SPIRV-ASM
OpCapability Shader
OpExtension "SPV_KHR_storage_buffer_storage_class"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %18 "foo"
OpSource OpenCL_C 120
OpDecorate %11 SpecId 0
OpDecorate %12 SpecId 1
OpDecorate %13 SpecId 2
OpDecorate %_runtimearr_uint ArrayStride 4
OpMemberDecorate %_struct_3 0 Offset 0
OpDecorate %_struct_3 Block
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
OpDecorate %16 DescriptorSet 0
OpDecorate %16 Binding 0
OpDecorate %17 DescriptorSet 0
OpDecorate %17 Binding 1
%uint = OpTypeInt 32 0
%_runtimearr_uint = OpTypeRuntimeArray %uint
%_struct_3 = OpTypeStruct %_runtimearr_uint
%_ptr_StorageBuffer__struct_3 = OpTypePointer StorageBuffer %_struct_3
%void = OpTypeVoid
%6 = OpTypeFunction %void
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
%v3uint = OpTypeVector %uint 3
%_ptr_Private_v3uint = OpTypePointer Private %v3uint
%uint_0 = OpConstant %uint 0
%11 = OpSpecConstant %uint 1
%12 = OpSpecConstant %uint 1
%13 = OpSpecConstant %uint 1
%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %11 %12 %13
%15 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize
%16 = OpVariable %_ptr_StorageBuffer__struct_3 StorageBuffer
%17 = OpVariable %_ptr_StorageBuffer__struct_3 StorageBuffer
%18 = OpFunction %void None %6
%19 = OpLabel
%20 = OpAccessChain %_ptr_StorageBuffer_uint %16 %uint_0 %uint_0
%21 = OpAccessChain %_ptr_StorageBuffer_uint %17 %uint_0 %uint_0
%22 = OpLoad %uint %20
OpStore %21 %22
OpReturn
OpFunctionEnd

END

BUFFER in_buf DATA_TYPE uint32 DATA
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future note, this could have been a single line:

BUFFER in_buf DATA_TYPE uint32 DATA 9 END

9
END
BUFFER out_buf DATA_TYPE uint32 SIZE 1 FILL 0

PIPELINE compute my_pipeline
ATTACH my_shader ENTRY_POINT foo
BIND BUFFER in_buf AS storage DESCRIPTOR_SET 0 BINDING 0
BIND BUFFER out_buf AS storage DESCRIPTOR_SET 0 BINDING 1
END

RUN my_pipeline 1 1 1

EXPECT out_buf EQ_BUFFER in_buf
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, nice to see EQ_BUFFER being useful for tests. @hevrard

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to see this too! 👍