Skip to content

Commit

Permalink
[Release] fixed desc buffer and barrier (#182)
Browse files Browse the repository at this point in the history
* fixed desc buffer and barrier

* fixed result values on int returns

* changelog

* fixed examples

* restyler fix
  • Loading branch information
Agrael1 authored Oct 10, 2024
1 parent e02cea0 commit 467c65e
Show file tree
Hide file tree
Showing 19 changed files with 142 additions and 129 deletions.
4 changes: 0 additions & 4 deletions .github/.restyled.yaml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/restyled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#name: Restyled
#
#on:
# pull_request:
#
#concurrency:
# group: ${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: true
#
#jobs:
# restyled:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{ github.event.pull_request.head.ref }}
#
# - uses: restyled-io/actions/setup@v4
# - id: restyler
# uses: restyled-io/actions/run@v4
# with:
# fail-on-differences: true
#
# - if: |
# !cancelled() &&
# steps.restyler.outputs.success == 'true' &&
# github.event.pull_request.head.repo.full_name == github.repository
# uses: peter-evans/create-pull-request@v6
# with:
# base: ${{ steps.restyler.outputs.restyled-base }}
# branch: ${{ steps.restyler.outputs.restyled-head }}
# title: ${{ steps.restyler.outputs.restyled-title }}
# body: ${{ steps.restyler.outputs.restyled-body }}
# labels: "restyled"
# reviewers: ${{ github.event.pull_request.user.login }}
# delete-branch: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,6 @@ FodyWeavers.xsd
*.idb
.vscode/settings.json
/wisdom/include/wisdom/vulkan/gen/generate_functions.bat

#restyler
*.orig
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

cmake_minimum_required(VERSION 3.22)

set(WISDOM_VERSION "0.3.5")
set(WISDOM_VERSION "0.3.6")
project("Wisdom" VERSION ${WISDOM_VERSION})

set(CMAKE_DEBUG_POSTFIX d)
Expand Down
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Version History

- 0.3.6

- Fixed inconsistency with Descriptor tables (bytes vs descriptors)
- Removed non-existing barrier access Present
- Removed result value from the Descriptor Table device methods
- Fixed examples
- Preparing for refactoring of descriptor tables

- 0.3.5

- Made internal function for swapchain recreation in Vulkan accept a pNext chain
Expand Down
56 changes: 20 additions & 36 deletions bindings/wisdom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,32 +203,24 @@ extern "C" WisResult DX12DeviceCreateShaderResource(DX12Device self, DX12Texture
return WisResult{ StatusOutOfMemory, "Failed to allocate memory for wis::DX12ShaderResource." };
return reinterpret_cast<WisResult&>(res);
}
extern "C" WisResult DX12DeviceGetDescriptorTableAlignment(DX12Device self, WisDescriptorHeapType heap, uint32_t* alignment)
extern "C" uint32_t DX12DeviceGetDescriptorTableAlignment(DX12Device self, WisDescriptorHeapType heap)
{
auto* xself = reinterpret_cast<wis::DX12Device*>(self);
auto&& [res, value] = xself->GetDescriptorTableAlignment(static_cast<wis::DescriptorHeapType>(heap));

if (res.status != wis::Status::Ok)
return reinterpret_cast<WisResult&>(res);

*alignment = value;
return reinterpret_cast<WisResult&>(res);
auto res = xself->GetDescriptorTableAlignment(static_cast<wis::DescriptorHeapType>(heap));
;
return res;
}
extern "C" WisResult DX12DeviceGetDescriptorBufferUnitSize(DX12Device self, WisDescriptorHeapType heap, uint32_t* size)
extern "C" uint32_t DX12DeviceGetDescriptorBufferUnitSize(DX12Device self, WisDescriptorHeapType heap)
{
auto* xself = reinterpret_cast<wis::DX12Device*>(self);
auto&& [res, value] = xself->GetDescriptorBufferUnitSize(static_cast<wis::DescriptorHeapType>(heap));

if (res.status != wis::Status::Ok)
return reinterpret_cast<WisResult&>(res);

*size = value;
return reinterpret_cast<WisResult&>(res);
auto res = xself->GetDescriptorBufferUnitSize(static_cast<wis::DescriptorHeapType>(heap));
;
return res;
}
extern "C" WisResult DX12DeviceCreateDescriptorBuffer(DX12Device self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint32_t descriptor_count, DX12DescriptorBuffer* buffer)
extern "C" WisResult DX12DeviceCreateDescriptorBuffer(DX12Device self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint64_t size_bytes, DX12DescriptorBuffer* buffer)
{
auto* xself = reinterpret_cast<wis::DX12Device*>(self);
auto&& [res, value] = xself->CreateDescriptorBuffer(static_cast<wis::DescriptorHeapType>(heap_type), static_cast<wis::DescriptorMemory>(memory_type), descriptor_count);
auto&& [res, value] = xself->CreateDescriptorBuffer(static_cast<wis::DescriptorHeapType>(heap_type), static_cast<wis::DescriptorMemory>(memory_type), size_bytes);

if (res.status != wis::Status::Ok)
return reinterpret_cast<WisResult&>(res);
Expand Down Expand Up @@ -934,32 +926,24 @@ extern "C" WisResult VKDeviceCreateShaderResource(VKDevice self, VKTexture textu
return WisResult{ StatusOutOfMemory, "Failed to allocate memory for wis::VKShaderResource." };
return reinterpret_cast<WisResult&>(res);
}
extern "C" WisResult VKDeviceGetDescriptorTableAlignment(VKDevice self, WisDescriptorHeapType heap, uint32_t* alignment)
extern "C" uint32_t VKDeviceGetDescriptorTableAlignment(VKDevice self, WisDescriptorHeapType heap)
{
auto* xself = reinterpret_cast<wis::VKDevice*>(self);
auto&& [res, value] = xself->GetDescriptorTableAlignment(static_cast<wis::DescriptorHeapType>(heap));

if (res.status != wis::Status::Ok)
return reinterpret_cast<WisResult&>(res);

*alignment = value;
return reinterpret_cast<WisResult&>(res);
auto res = xself->GetDescriptorTableAlignment(static_cast<wis::DescriptorHeapType>(heap));
;
return res;
}
extern "C" WisResult VKDeviceGetDescriptorBufferUnitSize(VKDevice self, WisDescriptorHeapType heap, uint32_t* size)
extern "C" uint32_t VKDeviceGetDescriptorBufferUnitSize(VKDevice self, WisDescriptorHeapType heap)
{
auto* xself = reinterpret_cast<wis::VKDevice*>(self);
auto&& [res, value] = xself->GetDescriptorBufferUnitSize(static_cast<wis::DescriptorHeapType>(heap));

if (res.status != wis::Status::Ok)
return reinterpret_cast<WisResult&>(res);

*size = value;
return reinterpret_cast<WisResult&>(res);
auto res = xself->GetDescriptorBufferUnitSize(static_cast<wis::DescriptorHeapType>(heap));
;
return res;
}
extern "C" WisResult VKDeviceCreateDescriptorBuffer(VKDevice self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint32_t descriptor_count, VKDescriptorBuffer* buffer)
extern "C" WisResult VKDeviceCreateDescriptorBuffer(VKDevice self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint64_t size_bytes, VKDescriptorBuffer* buffer)
{
auto* xself = reinterpret_cast<wis::VKDevice*>(self);
auto&& [res, value] = xself->CreateDescriptorBuffer(static_cast<wis::DescriptorHeapType>(heap_type), static_cast<wis::DescriptorMemory>(memory_type), descriptor_count);
auto&& [res, value] = xself->CreateDescriptorBuffer(static_cast<wis::DescriptorHeapType>(heap_type), static_cast<wis::DescriptorMemory>(memory_type), size_bytes);

if (res.status != wis::Status::Ok)
return reinterpret_cast<WisResult&>(res);
Expand Down
83 changes: 33 additions & 50 deletions bindings/wisdom.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/** \mainpage Wisdom API Documentation
<b>Version 0.3.3</b>
<b>Version 0.3.6</b>
Copyright (c) 2024 Ilya Doroshenko. All rights reserved.
License: MIT
Expand Down Expand Up @@ -1306,9 +1306,8 @@ enum WisResourceAccessBits {
ResourceAccessShadingRate = 1 << 15, ///< Shading rate access. Used in variable shading rate.
ResourceAccessVideoDecodeRead = 1 << 16, ///< Video decode read access.
ResourceAccessVideoDecodeWrite = 1 << 17, ///< Video decode write access.
ResourceAccessPresent = 1 << 18, ///< Present access. Used fpr swapchain presentation.
ResourceAccessResolveDest = 1 << 19, ///< Resolve destination access. Used in multisampling.
ResourceAccessResolveSource = 1 << 20, ///< Resolve source access. Used in multisampling.
ResourceAccessResolveDest = 1 << 18, ///< Resolve destination access. Used in multisampling.
ResourceAccessResolveSource = 1 << 19, ///< Resolve source access. Used in multisampling.
ResourceAccessNoAccess = 1 << 31, ///< No access. Used to indicate no access throughout pipeline.
};

Expand Down Expand Up @@ -2229,33 +2228,29 @@ WISDOM_API WisResult VKDeviceCreateShaderResource(VKDevice self, VKTexture textu
* The value is used to correctly determine descriptor page alignment for descriptor buffer.
* @param self valid handle to the Device
* @param heap The type of the descriptor heap to get the alignment for.
* @param alignment The alignment of the descriptor table in bytes.
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* @return The alignment of the descriptor table in bytes.
* */
WISDOM_API WisResult VKDeviceGetDescriptorTableAlignment(VKDevice self, WisDescriptorHeapType heap, uint32_t* alignment);
WISDOM_API uint32_t VKDeviceGetDescriptorTableAlignment(VKDevice self, WisDescriptorHeapType heap);

/**
* @brief Returns the size of the descriptor buffer unit in bytes.
* @param self valid handle to the Device
* @param heap The type of the descriptor heap to get the unit size for.
* @param size The size of the descriptor buffer unit in bytes. Descriptor unit is the size of one descriptor.
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* @return The size of the descriptor buffer unit in bytes. Descriptor unit is the size of one descriptor.
* */
WISDOM_API WisResult VKDeviceGetDescriptorBufferUnitSize(VKDevice self, WisDescriptorHeapType heap, uint32_t* size);
WISDOM_API uint32_t VKDeviceGetDescriptorBufferUnitSize(VKDevice self, WisDescriptorHeapType heap);

/**
* @brief Creates a descriptor buffer object.
* @param self valid handle to the Device
* @param heap_type The type of the descriptor heap to create the descriptor buffer with.
* @param memory_type The type of the descriptor memory to create the descriptor buffer with.
* @param descriptor_count The number of descriptors to allocate in the descriptor buffer.
* @param size_bytes The number of bytes to allocate for the descriptor buffer.
* @param buffer VKDescriptorBuffer on success (StatusOk).
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* */
WISDOM_API WisResult VKDeviceCreateDescriptorBuffer(VKDevice self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint32_t descriptor_count, VKDescriptorBuffer* buffer);
WISDOM_API WisResult VKDeviceCreateDescriptorBuffer(VKDevice self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint64_t size_bytes, VKDescriptorBuffer* buffer);

/**
* @brief Queries if the device supports the feature.
Expand Down Expand Up @@ -3265,33 +3260,29 @@ WISDOM_API WisResult DX12DeviceCreateShaderResource(DX12Device self, DX12Texture
* The value is used to correctly determine descriptor page alignment for descriptor buffer.
* @param self valid handle to the Device
* @param heap The type of the descriptor heap to get the alignment for.
* @param alignment The alignment of the descriptor table in bytes.
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* @return The alignment of the descriptor table in bytes.
* */
WISDOM_API WisResult DX12DeviceGetDescriptorTableAlignment(DX12Device self, WisDescriptorHeapType heap, uint32_t* alignment);
WISDOM_API uint32_t DX12DeviceGetDescriptorTableAlignment(DX12Device self, WisDescriptorHeapType heap);

/**
* @brief Returns the size of the descriptor buffer unit in bytes.
* @param self valid handle to the Device
* @param heap The type of the descriptor heap to get the unit size for.
* @param size The size of the descriptor buffer unit in bytes. Descriptor unit is the size of one descriptor.
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* @return The size of the descriptor buffer unit in bytes. Descriptor unit is the size of one descriptor.
* */
WISDOM_API WisResult DX12DeviceGetDescriptorBufferUnitSize(DX12Device self, WisDescriptorHeapType heap, uint32_t* size);
WISDOM_API uint32_t DX12DeviceGetDescriptorBufferUnitSize(DX12Device self, WisDescriptorHeapType heap);

/**
* @brief Creates a descriptor buffer object.
* @param self valid handle to the Device
* @param heap_type The type of the descriptor heap to create the descriptor buffer with.
* @param memory_type The type of the descriptor memory to create the descriptor buffer with.
* @param descriptor_count The number of descriptors to allocate in the descriptor buffer.
* @param size_bytes The number of bytes to allocate for the descriptor buffer.
* @param buffer DX12DescriptorBuffer on success (StatusOk).
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* */
WISDOM_API WisResult DX12DeviceCreateDescriptorBuffer(DX12Device self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint32_t descriptor_count, DX12DescriptorBuffer* buffer);
WISDOM_API WisResult DX12DeviceCreateDescriptorBuffer(DX12Device self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint64_t size_bytes, DX12DescriptorBuffer* buffer);

/**
* @brief Queries if the device supports the feature.
Expand Down Expand Up @@ -4247,41 +4238,37 @@ inline WisResult WisDeviceCreateShaderResource(WisDevice self, WisTexture textur
* The value is used to correctly determine descriptor page alignment for descriptor buffer.
* @param self valid handle to the Device
* @param heap The type of the descriptor heap to get the alignment for.
* @param alignment The alignment of the descriptor table in bytes.
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* @return The alignment of the descriptor table in bytes.
* */
inline WisResult WisDeviceGetDescriptorTableAlignment(WisDevice self, WisDescriptorHeapType heap, uint32_t* alignment)
inline uint32_t WisDeviceGetDescriptorTableAlignment(WisDevice self, WisDescriptorHeapType heap)
{
return DX12DeviceGetDescriptorTableAlignment(self, heap, alignment);
return DX12DeviceGetDescriptorTableAlignment(self, heap);
}

/**
* @brief Returns the size of the descriptor buffer unit in bytes.
* @param self valid handle to the Device
* @param heap The type of the descriptor heap to get the unit size for.
* @param size The size of the descriptor buffer unit in bytes. Descriptor unit is the size of one descriptor.
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* @return The size of the descriptor buffer unit in bytes. Descriptor unit is the size of one descriptor.
* */
inline WisResult WisDeviceGetDescriptorBufferUnitSize(WisDevice self, WisDescriptorHeapType heap, uint32_t* size)
inline uint32_t WisDeviceGetDescriptorBufferUnitSize(WisDevice self, WisDescriptorHeapType heap)
{
return DX12DeviceGetDescriptorBufferUnitSize(self, heap, size);
return DX12DeviceGetDescriptorBufferUnitSize(self, heap);
}

/**
* @brief Creates a descriptor buffer object.
* @param self valid handle to the Device
* @param heap_type The type of the descriptor heap to create the descriptor buffer with.
* @param memory_type The type of the descriptor memory to create the descriptor buffer with.
* @param descriptor_count The number of descriptors to allocate in the descriptor buffer.
* @param size_bytes The number of bytes to allocate for the descriptor buffer.
* @param buffer WisDescriptorBuffer on success (StatusOk).
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* */
inline WisResult WisDeviceCreateDescriptorBuffer(WisDevice self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint32_t descriptor_count, WisDescriptorBuffer* buffer)
inline WisResult WisDeviceCreateDescriptorBuffer(WisDevice self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint64_t size_bytes, WisDescriptorBuffer* buffer)
{
return DX12DeviceCreateDescriptorBuffer(self, heap_type, memory_type, descriptor_count, buffer);
return DX12DeviceCreateDescriptorBuffer(self, heap_type, memory_type, size_bytes, buffer);
}

/**
Expand Down Expand Up @@ -5429,41 +5416,37 @@ inline WisResult WisDeviceCreateShaderResource(WisDevice self, WisTexture textur
* The value is used to correctly determine descriptor page alignment for descriptor buffer.
* @param self valid handle to the Device
* @param heap The type of the descriptor heap to get the alignment for.
* @param alignment The alignment of the descriptor table in bytes.
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* @return The alignment of the descriptor table in bytes.
* */
inline WisResult WisDeviceGetDescriptorTableAlignment(WisDevice self, WisDescriptorHeapType heap, uint32_t* alignment)
inline uint32_t WisDeviceGetDescriptorTableAlignment(WisDevice self, WisDescriptorHeapType heap)
{
return VKDeviceGetDescriptorTableAlignment(self, heap, alignment);
return VKDeviceGetDescriptorTableAlignment(self, heap);
}

/**
* @brief Returns the size of the descriptor buffer unit in bytes.
* @param self valid handle to the Device
* @param heap The type of the descriptor heap to get the unit size for.
* @param size The size of the descriptor buffer unit in bytes. Descriptor unit is the size of one descriptor.
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* @return The size of the descriptor buffer unit in bytes. Descriptor unit is the size of one descriptor.
* */
inline WisResult WisDeviceGetDescriptorBufferUnitSize(WisDevice self, WisDescriptorHeapType heap, uint32_t* size)
inline uint32_t WisDeviceGetDescriptorBufferUnitSize(WisDevice self, WisDescriptorHeapType heap)
{
return VKDeviceGetDescriptorBufferUnitSize(self, heap, size);
return VKDeviceGetDescriptorBufferUnitSize(self, heap);
}

/**
* @brief Creates a descriptor buffer object.
* @param self valid handle to the Device
* @param heap_type The type of the descriptor heap to create the descriptor buffer with.
* @param memory_type The type of the descriptor memory to create the descriptor buffer with.
* @param descriptor_count The number of descriptors to allocate in the descriptor buffer.
* @param size_bytes The number of bytes to allocate for the descriptor buffer.
* @param buffer WisDescriptorBuffer on success (StatusOk).
* @return Result with StatusOk on success.
* Error in WisResult::error otherwise.
* */
inline WisResult WisDeviceCreateDescriptorBuffer(WisDevice self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint32_t descriptor_count, WisDescriptorBuffer* buffer)
inline WisResult WisDeviceCreateDescriptorBuffer(WisDevice self, WisDescriptorHeapType heap_type, WisDescriptorMemory memory_type, uint64_t size_bytes, WisDescriptorBuffer* buffer)
{
return VKDeviceCreateDescriptorBuffer(self, heap_type, memory_type, descriptor_count, buffer);
return VKDeviceCreateDescriptorBuffer(self, heap_type, memory_type, size_bytes, buffer);
}

/**
Expand Down
7 changes: 5 additions & 2 deletions examples/custom/cross_device/work_node.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "work_node.h"
#include "work_node.h"
#include "lut_loader.h"
#include <fstream>

Expand Down Expand Up @@ -299,11 +300,13 @@ CreateWorkNode(wis::Adapter&& adapter)

// Create Descriptor Buffers
{
auto [res, hdesc] = node.work_device.CreateDescriptorBuffer(wis::DescriptorHeapType::Descriptor, wis::DescriptorMemory::ShaderVisible, 2);
auto desc_increment = node.work_device.GetDescriptorBufferUnitSize(wis::DescriptorHeapType::Descriptor);
auto [res, hdesc] = node.work_device.CreateDescriptorBuffer(wis::DescriptorHeapType::Descriptor, wis::DescriptorMemory::ShaderVisible, 2 * desc_increment);
if (res.status != wis::Status::Ok)
return std::unexpected(res.error);

auto [res2, hdesc2] = node.work_device.CreateDescriptorBuffer(wis::DescriptorHeapType::Sampler, wis::DescriptorMemory::ShaderVisible, 1);
auto sampler_increment = node.work_device.GetDescriptorBufferUnitSize(wis::DescriptorHeapType::Sampler);
auto [res2, hdesc2] = node.work_device.CreateDescriptorBuffer(wis::DescriptorHeapType::Sampler, wis::DescriptorMemory::ShaderVisible, 1 * sampler_increment);
if (res2.status != wis::Status::Ok)
return std::unexpected(res2.error);

Expand Down
Loading

0 comments on commit 467c65e

Please sign in to comment.