Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler errors on newer vulkan implementations #71

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
3 changes: 1 addition & 2 deletions src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,11 @@ namespace vuh {
, vk::PipelineCache pipe_cache
, const vk::PipelineShaderStageCreateInfo& shader_stage_info
, vk::PipelineCreateFlags flags
)-> vk::Pipeline
)-> vk::ResultValue<vk::Pipeline>
{
auto pipelineCI = vk::ComputePipelineCreateInfo(flags
, shader_stage_info, pipe_layout);
return createComputePipeline(pipe_cache, pipelineCI, nullptr);

}

/// Detach the current compute command buffer for sync operations and create the new one.
Expand Down
1 change: 1 addition & 0 deletions src/include/vuh/delayed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <vuh/resource.hpp>

#include <cassert>
#include <memory>

namespace vuh {
namespace detail{
Expand Down
4 changes: 2 additions & 2 deletions src/include/vuh/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ namespace vuh {
, vk::PipelineCache pipe_cache
, const vk::PipelineShaderStageCreateInfo& shader_stage_info
, vk::PipelineCreateFlags flags={}
)-> vk::Pipeline;
)-> vk::ResultValue<vk::Pipeline>;
auto instance()-> vuh::Instance& { return _instance; }
auto releaseComputeCmdBuffer()-> vk::CommandBuffer;

private: // helpers
explicit Device(vuh::Instance& instance, vk::PhysicalDevice physdevice
, const std::vector<vk::QueueFamilyProperties>& families);
Expand Down
23 changes: 15 additions & 8 deletions src/include/vuh/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ namespace vuh {
o._shader = nullptr; //
}

/// Move assignment. Releases resources allocated for current instance before taking
/// Move assignment. Releases resources allocated for current instance before taking
/// ownership over those of the other instance.
ProgramBase& operator= (ProgramBase&& o) noexcept {
release();
Expand All @@ -193,12 +193,12 @@ namespace vuh {
_dsclayout = o._dsclayout;
_dscpool = o._dscpool;
_dscset = o._dscset;
_pipecache = o._pipecache;
_pipecache = o._pipecache;
_pipelayout = o._pipelayout;
_pipeline = o._pipeline;
_device = o._device;
_batch = o._batch;
_batch = o._batch;

o._shader = nullptr;
return *this;
}
Expand Down Expand Up @@ -318,7 +318,7 @@ namespace vuh {

/// Initialize the pipeline.
/// Specialization constants interface is defined here.
auto init_pipeline()-> void {
auto init_pipeline()-> vk::Result {
auto specEntries = specs2mapentries(_specs);
auto specInfo = vk::SpecializationInfo(uint32_t(specEntries.size()), specEntries.data()
, sizeof(_specs), &_specs);
Expand All @@ -327,7 +327,11 @@ namespace vuh {
auto stageCI = vk::PipelineShaderStageCreateInfo(vk::PipelineShaderStageCreateFlags()
, vk::ShaderStageFlagBits::eCompute
, _shader, "main", &specInfo);
_pipeline = _device.createPipeline(_pipelayout, _pipecache, stageCI);

VUH_TRY(_device.createPipeline(_pipelayout, _pipecache, stageCI), pipeline);
_pipeline = std::move(pipeline);

return vk::Result::eSuccess;
}
protected:
std::tuple<Spec_Ts...> _specs; ///< hold the state of specialization constants between call to specs() and actual pipeline creation
Expand All @@ -353,12 +357,15 @@ namespace vuh {
{}

/// Initialize the pipeline with empty specialialization constants interface.
auto init_pipeline()-> void {
auto init_pipeline()-> vk::Result {
auto stageCI = vk::PipelineShaderStageCreateInfo(vk::PipelineShaderStageCreateFlags()
, vk::ShaderStageFlagBits::eCompute
, _shader, "main", nullptr);

_pipeline = _device.createPipeline(_pipelayout, _pipecache, stageCI);
VUH_TRY(_device.createPipeline(_pipelayout, _pipecache, stageCI), pipeline);
_pipeline = std::move(pipeline);

return vk::Result::eSuccess;
}
}; // class SpecsBase
} // namespace detail
Expand Down
7 changes: 7 additions & 0 deletions src/include/vuh/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
#include <stdint.h>
#include <vector>

#define VUH_TRY(expression, identifier) \
auto maybe_##identifier = (expression); \
if((maybe_##identifier).result != vk::Result::eSuccess) \
return (maybe_##identifier).result; \
auto identifier = std::move((maybe_##identifier).value)


namespace vuh {
/// Typelist. That is all about it.
template<class... Ts> struct typelist{};
Expand Down