From 21af49b91295d34d84873dff933680d8f320dfe7 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 13 Sep 2026 17:07:16 +0000 Subject: [PATCH 01/11] Restyled by astyle --- examples/backend/sdl_backend_c.c | 14 +- examples/compute_particles_c/entry_main.c | 115 +-- examples/hello_triangle/entry_main.c | 23 +- examples/hello_triangle/entry_main.cpp | 10 +- generator/bitmask.cpp | 110 +-- generator/entry_main.cpp | 10 +- generator/enum.cpp | 84 +- generator/function.cpp | 186 ++-- generator/generator.cpp | 352 +++---- generator/generator.hpp | 18 +- generator/handle.cpp | 130 +-- generator/struct.cpp | 38 +- generator/types.hpp | 56 +- generator/validation.cpp | 2 +- generator/variant.cpp | 40 +- src/include/wisdom/bridge/span.hpp | 72 +- .../wisdom/dx12/detail/dx12_detail.hpp | 77 +- .../wisdom/dx12/dx12_adapter_query.cpp | 32 +- .../wisdom/dx12/dx12_command_allocator.cpp | 12 +- src/include/wisdom/dx12/dx12_command_list.cpp | 112 +-- .../wisdom/dx12/dx12_descriptor_heap.cpp | 54 +- src/include/wisdom/dx12/dx12_device.cpp | 326 +++---- src/include/wisdom/dx12/dx12_impl.cpp | 30 +- src/include/wisdom/dx12/dx12_instance.cpp | 22 +- .../wisdom/dx12/dx12_resource_allocator.cpp | 86 +- src/include/wisdom/dx12/dx12_swapchain.cpp | 10 +- src/include/wisdom/generated/cpp_api.hpp | 878 ++++++++++-------- src/include/wisdom/generated/dx12_convert.hpp | 28 +- src/include/wisdom/generated/vk_convert.hpp | 12 +- src/include/wisdom/global/internal.hpp | 12 +- .../wisdom/vulkan/detail/vk_detail.hpp | 52 +- src/include/wisdom/vulkan/detail/vk_ext1.hpp | 42 +- .../wisdom/vulkan/vk_adapter_query.cpp | 87 +- .../wisdom/vulkan/vk_command_allocator.cpp | 8 +- src/include/wisdom/vulkan/vk_command_list.cpp | 152 +-- .../wisdom/vulkan/vk_descriptor_heap.cpp | 26 +- src/include/wisdom/vulkan/vk_device.cpp | 466 +++++----- src/include/wisdom/vulkan/vk_extensions.cpp | 48 +- src/include/wisdom/vulkan/vk_extensions.hpp | 44 +- src/include/wisdom/vulkan/vk_impl.cpp | 16 +- src/include/wisdom/vulkan/vk_instance.cpp | 58 +- .../wisdom/vulkan/vk_pipeline_cache.cpp | 6 +- .../wisdom/vulkan/vk_resource_allocator.cpp | 32 +- src/include/wisdom/vulkan/vk_swapchain.cpp | 70 +- src/include/wisdom/vulkan/vk_tables.hpp | 12 +- src/include/wisdom/wisdom.hpp | 20 +- .../wisdom_platform/generated/cpp_api.hpp | 120 ++- .../vulkan/vk_platform_wayland.cpp | 4 +- .../vulkan/vk_platform_win32.cpp | 4 +- .../vulkan/vk_platform_xcb.cpp | 4 +- .../vulkan/vk_platform_xlib.cpp | 4 +- test_package/main.cpp | 10 +- tests/basic/platform_check.cpp | 12 +- 53 files changed, 2259 insertions(+), 1989 deletions(-) diff --git a/examples/backend/sdl_backend_c.c b/examples/backend/sdl_backend_c.c index fe878967e..6f6b6d9fd 100644 --- a/examples/backend/sdl_backend_c.c +++ b/examples/backend/sdl_backend_c.c @@ -53,7 +53,7 @@ WisSurface CreateSurface(const SDLPlatform* platform, SDL_Window* window) case SDL_PLATFORM_EXTENSION_WIN32: { WisWin32Extension* win32_extension = (WisWin32Extension*)platform->platform_extension; HWND hwnd = (HWND) - SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); + SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); if (hwnd) { WisWin32WindowDesc desc = { .hinstance = GetModuleHandle(NULL), @@ -68,9 +68,9 @@ WisSurface CreateSurface(const SDLPlatform* platform, SDL_Window* window) #elif defined(SDL_PLATFORM_LINUX) case SDL_PLATFORM_EXTENSION_X11: { void* xdisplay = (void*) - SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_X11_DISPLAY_POINTER, NULL); + SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_X11_DISPLAY_POINTER, NULL); uint64_t xwindow = (uint64_t) - SDL_GetNumberProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0); + SDL_GetNumberProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0); if (xdisplay && xwindow) { WisXlibWindowDesc desc = { .display = xdisplay, @@ -85,9 +85,9 @@ WisSurface CreateSurface(const SDLPlatform* platform, SDL_Window* window) case SDL_PLATFORM_EXTENSION_WAYLAND: { WisWaylandExtension* wayland_extension = (WisWaylandExtension*)platform->platform_extension; struct wl_display* display = (struct wl_display*) - SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, NULL); + SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, NULL); struct wl_surface* surface = (struct wl_surface*) - SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, NULL); + SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, NULL); if (display && surface) { WisWaylandWindowDesc desc = { .display = display, @@ -104,7 +104,9 @@ WisSurface CreateSurface(const SDLPlatform* platform, SDL_Window* window) break; } - return (WisSurface){0}; + return (WisSurface) { + 0 + }; } void DestroyPlatform(SDLPlatform* platform) diff --git a/examples/compute_particles_c/entry_main.c b/examples/compute_particles_c/entry_main.c index e59925581..6473292df 100644 --- a/examples/compute_particles_c/entry_main.c +++ b/examples/compute_particles_c/entry_main.c @@ -268,10 +268,10 @@ void ResizeDepth(BasicRenderer* renderer, uint32_t width, uint32_t height) .memory_flags = WisMemoryFlagsNone, }; WisResult result = wisResourceAllocatorCreateTexture( - &renderer->allocator, - &depth_desc, - &renderer->depth_texture[i] - ); + &renderer->allocator, + &depth_desc, + &renderer->depth_texture[i] + ); printf( "CreateDepthTexture[%u] result: %d, platform_code: %d, error: %s\n", i, @@ -285,7 +285,7 @@ void ResizeDepth(BasicRenderer* renderer, uint32_t width, uint32_t height) .array_layer_count = 1, }; wisViewHeapWriteDepthStencil(&renderer->dsv_heap, &renderer->depth_texture[i], &dsv_desc, i); - barriers[i] = (WisTextureBarrier){ + barriers[i] = (WisTextureBarrier) { .sync_before = WisBarrierSyncNone, .sync_after = WisBarrierSyncNone, .access_before = WisResourceAccessNone, @@ -311,10 +311,10 @@ void ResizeDepth(BasicRenderer* renderer, uint32_t width, uint32_t height) // insert a fence result = wisCommandQueueSignalFence( - &renderer->gfx_queue, - wisGetFenceView(&renderer->aux_fence), - ++renderer->aux_fence_value - ); + &renderer->gfx_queue, + wisGetFenceView(&renderer->aux_fence), + ++renderer->aux_fence_value + ); result = wisFenceWait(&renderer->aux_fence, renderer->aux_fence_value, UINT64_MAX); } @@ -403,11 +403,11 @@ void InitRenderer(BasicRenderer* renderer, SDL_Window* window) WisInstanceExtensionHeader* extensions[] = {platform.platform_extension}; WisInstance instance = {0}; WisResult result = wisCreateInstance( - &debug_desc, - extensions, - sizeof(extensions) / sizeof(WisInstanceExtensionHeader*), - &instance - ); + &debug_desc, + extensions, + sizeof(extensions) / sizeof(WisInstanceExtensionHeader*), + &instance + ); printf( "CreateInstance result: %d, platform_code: %d, error: %s\n", result.status, @@ -433,10 +433,10 @@ void InitRenderer(BasicRenderer* renderer, SDL_Window* window) // Query format support and choose swapchain format bool present_support = wisDeviceGetFormatPresentationSupport( - &renderer->device, - wisGetSurfaceView(&surface), - WisDataFormatRGB10A2Unorm - ); + &renderer->device, + wisGetSurfaceView(&surface), + WisDataFormatRGB10A2Unorm + ); if (present_support) { renderer->swapchain_format = WisDataFormatRGB10A2Unorm; printf("Surface supports the desired swapchain format.\n"); @@ -458,12 +458,12 @@ void InitRenderer(BasicRenderer* renderer, SDL_Window* window) .composite_alpha = WisCompositeAlphaOpaque, }; result = wisDeviceCreateSwapchain( - &renderer->device, - &surface, - &renderer->gfx_queue, - &swapchain_desc, - &renderer->swapchain - ); + &renderer->device, + &surface, + &renderer->gfx_queue, + &swapchain_desc, + &renderer->swapchain + ); // Destroy instance as we no longer need it wisDestroySurface(&surface); @@ -489,10 +489,10 @@ void InitRenderer(BasicRenderer* renderer, SDL_Window* window) for (uint32_t i = 0; i < FRAMES_IN_FLIGHT; ++i) { result = wisDeviceCreateCommandAllocator( - &renderer->device, - WisCommandQueueTypeGraphics, - &renderer->frames[i].command_allocator - ); + &renderer->device, + WisCommandQueueTypeGraphics, + &renderer->frames[i].command_allocator + ); printf( "CreateCommandAllocator[%u] result: %d, platform_code: %d, error: %s\n", i, @@ -502,9 +502,9 @@ void InitRenderer(BasicRenderer* renderer, SDL_Window* window) ); result = wisCommandAllocatorCreateCommandList( - &renderer->frames[i].command_allocator, - &renderer->frames[i].command_list - ); + &renderer->frames[i].command_allocator, + &renderer->frames[i].command_list + ); printf( "CreateCommandList[%u] result: %d, platform_code: %d, error: %s\n", i, @@ -578,10 +578,10 @@ void DestoyRenderer(BasicRenderer* renderer) { if (renderer->next_fence_value > 0) { WisResult result = wisCommandQueueSignalFence( - &renderer->gfx_queue, - wisGetFenceView(&renderer->fence), - ++renderer->next_fence_value - ); + &renderer->gfx_queue, + wisGetFenceView(&renderer->fence), + ++renderer->next_fence_value + ); printf( "Flush SignalFence result: %d, platform_code: %d, error: %s\n", result.status, @@ -626,10 +626,10 @@ void DestoyRenderer(BasicRenderer* renderer) void WaitForFinish(BasicRenderer* renderer) { WisResult result = wisCommandQueueSignalFence( - &renderer->gfx_queue, - wisGetFenceView(&renderer->fence), - renderer->next_fence_value - ); + &renderer->gfx_queue, + wisGetFenceView(&renderer->fence), + renderer->next_fence_value + ); printf( "WaitForFinish SignalFence result: %d, platform_code: %d, error: %s\n", result.status, @@ -667,10 +667,10 @@ void InitRenderTask(BasicRenderTask* task, BasicRenderer* renderer) .push_descriptor_count = 1, }; WisResult result = wisDeviceCreateRootSignature( - &renderer->device, - &compute_root_signature_desc, - &task->compute_signature - ); + &renderer->device, + &compute_root_signature_desc, + &task->compute_signature + ); printf( "CreateRootSignature for ComputeShader result: %d, platform_code: %d, error: %s\n", result.status, @@ -797,10 +797,10 @@ void InitResourceContainer(ResourceContainer* container, BasicRenderer* renderer .memory_type = WisMemoryTypeDeviceLocal, }; WisResult result = wisResourceAllocatorCreateBuffer( - &renderer->allocator, - &particle_buffer_desc, - &container->particle_buffer - ); + &renderer->allocator, + &particle_buffer_desc, + &container->particle_buffer + ); printf( "Create ParticleBuffer result: %d, platform_code: %d, error: %s\n", result.status, @@ -1009,10 +1009,12 @@ void Render(BasicRenderer* renderer, const ResourceContainer* resources, const B WisRenderPassDesc render_pass_desc = { .flags = 0, .render_targets = - {{.target = swap_rt, - .load_op = WisLoadOpClear, - .store_op = WisStoreOpStore, - .clear_value = {0.5f, 1.0f, 1.0f, 1.0f}}}, + { { .target = swap_rt, + .load_op = WisLoadOpClear, + .store_op = WisStoreOpStore, + .clear_value = {0.5f, 1.0f, 1.0f, 1.0f} + } + }, .render_target_count = 1, .depth_stencil = { .target = wisViewHeapGetViewAddress(&renderer->dsv_heap, renderer->frame_index), @@ -1086,10 +1088,10 @@ void Render(BasicRenderer* renderer, const ResourceContainer* resources, const B frame->fence_value = renderer->next_fence_value; result = wisCommandQueueSignalFence( - &renderer->gfx_queue, - wisGetFenceView(&renderer->fence), - renderer->next_fence_value - ); + &renderer->gfx_queue, + wisGetFenceView(&renderer->fence), + renderer->next_fence_value + ); print_info( "Frame[%u] SignalFence result: %d, platform_code: %d, error: %s\n", renderer->frame_index, @@ -1155,7 +1157,8 @@ void HandleEvents(bool* running, BasicRenderer* renderer) ResizeDepth(renderer, update_desc.width, update_desc.height); - } break; + } + break; default: break; } diff --git a/examples/hello_triangle/entry_main.c b/examples/hello_triangle/entry_main.c index 0bb39ee2b..45ef4f6da 100644 --- a/examples/hello_triangle/entry_main.c +++ b/examples/hello_triangle/entry_main.c @@ -238,8 +238,8 @@ static bool init_app(HelloTriangleApp* app, SDL_Window* window) wisGetSurfaceView(&surface), WisDataFormatRGB10A2Unorm ) - ? WisDataFormatRGB10A2Unorm - : WisDataFormatBGRA8Unorm; + ? WisDataFormatRGB10A2Unorm + : WisDataFormatBGRA8Unorm; WisSwapchainDesc swapchain_desc = { .width = app->width, @@ -273,10 +273,10 @@ static bool init_app(HelloTriangleApp* app, SDL_Window* window) for (uint32_t i = 0; i < FRAMES_IN_FLIGHT; ++i) { result = wisDeviceCreateCommandAllocator( - &app->device, - WisCommandQueueTypeGraphics, - &app->frames[i].command_allocator - ); + &app->device, + WisCommandQueueTypeGraphics, + &app->frames[i].command_allocator + ); if (!check_result(result, "wisDeviceCreateCommandAllocator")) { return false; } @@ -453,11 +453,12 @@ static void draw_frame(HelloTriangleApp* app, float angle) WisRenderPassDesc render_pass = { .render_targets = {{ - .target = target_rtv, - .load_op = WisLoadOpClear, - .store_op = WisStoreOpStore, - .clear_value = {0.1f, 0.1f, 0.15f, 1.0f}, - }}, + .target = target_rtv, + .load_op = WisLoadOpClear, + .store_op = WisStoreOpStore, + .clear_value = {0.1f, 0.1f, 0.15f, 1.0f}, + } + }, .render_target_count = 1, }; diff --git a/examples/hello_triangle/entry_main.cpp b/examples/hello_triangle/entry_main.cpp index 1f03d8e7f..5bc1ef167 100644 --- a/examples/hello_triangle/entry_main.cpp +++ b/examples/hello_triangle/entry_main.cpp @@ -33,14 +33,14 @@ struct HelloTriangleApp { uint64_t next_fence_value = 1; wis::Swapchain swapchain{}; - wis::Texture swapchain_textures[SWAPCHAIN_FRAMES]{}; + wis::Texture swapchain_textures[SWAPCHAIN_FRAMES] {}; wis::ViewHeap rtv_heap{}; wis::DataFormat swapchain_format = wis::DataFormat::BGRA8Unorm; wis::RootSignature root_signature{}; wis::Pipeline pipeline{}; - FrameContext frames[FRAMES_IN_FLIGHT]{}; + FrameContext frames[FRAMES_IN_FLIGHT] {}; uint32_t frame_index = 0; uint32_t width = 800; @@ -206,8 +206,8 @@ static bool init_app(HelloTriangleApp* app, SDL_Window* window) } app->swapchain_format = app->device.GetFormatPresentationSupport(surface.GetView(), wis::DataFormat::RGB10A2Unorm) - ? wis::DataFormat::RGB10A2Unorm - : wis::DataFormat::BGRA8Unorm; + ? wis::DataFormat::RGB10A2Unorm + : wis::DataFormat::BGRA8Unorm; wis::SwapchainDesc swapchain_desc = { .width = app->width, @@ -340,7 +340,7 @@ static void draw_frame(HelloTriangleApp* app, float angle) wis::Texture& target_texture = app->swapchain_textures[swapchain_index]; uint64_t target_rtv = app->rtv_heap.GetViewAddress(swapchain_index); - wis::TextureBarrier barriers[2]{}; + wis::TextureBarrier barriers[2] {}; barriers[0].sync_before = wis::BarrierSync::None; barriers[0].sync_after = wis::BarrierSync::RenderTarget; barriers[0].access_before = wis::ResourceAccess::None; diff --git a/generator/bitmask.cpp b/generator/bitmask.cpp index 2692c5cac..0c529fed6 100644 --- a/generator/bitmask.cpp +++ b/generator/bitmask.cpp @@ -53,7 +53,7 @@ void Generator::ParseBitmask(tinyxml2::XMLElement* type) } for (auto* impl_type = type->FirstChildElement("impl_type"); impl_type; - impl_type = impl_type->NextSiblingElement("impl_type")) { + impl_type = impl_type->NextSiblingElement("impl_type")) { auto impl_for = impl_type->FindAttribute("for")->Value(); auto backend = ParseBackend(impl_for); auto impl_name = impl_type->FindAttribute("name")->Value(); @@ -114,11 +114,11 @@ std::string Generator::MakeCBitmask(const WisBitmask& s, DocKind kind) for (auto& m : s.values) { if (m.is_bit) { st_decl += MakeValueDocumentation( - s, - m, - std::format(" Wis{}{} = (1u << {}),", s.name, m.name, m.value_or_bit), - kind - ); + s, + m, + std::format(" Wis{}{} = (1u << {}),", s.name, m.name, m.value_or_bit), + kind + ); continue; } st_decl += MakeValueDocumentation(s, m, std::format(" Wis{}{} = {},", s.name, m.name, m.value_or_bit), kind); @@ -139,11 +139,11 @@ std::string Generator::MakeCPPBitmask(const WisBitmask& s, DocKind kind) for (auto& m : s.values) { if (m.is_bit) { st_decl += MakeValueDocumentation( - s, - m, - std::format(" {} = (1u << {}),", m.name, m.value_or_bit), - kind - ); + s, + m, + std::format(" {} = (1u << {}),", m.name, m.value_or_bit), + kind + ); continue; } st_decl += MakeValueDocumentation(s, m, std::format(" {} = {},", m.name, m.value_or_bit), kind); @@ -210,19 +210,19 @@ std::string Generator::MakeBitmaskConverter(const WisBitmask& s, Backend backend if (cvt.direct) { converters = std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", - cvt.value, - backend_tag, - GetCFullTypename(s.name, backend), - cvt.value - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", + cvt.value, + backend_tag, + GetCFullTypename(s.name, backend), + cvt.value + ); } else { converters = std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n", - cvt.value, - backend_tag, - GetCFullTypename(s.name, backend) - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n", + cvt.value, + backend_tag, + GetCFullTypename(s.name, backend) + ); // Start with default value converters += std::format(" {} result = static_cast<{}>(0);\n", cvt.value, cvt.value); @@ -233,12 +233,12 @@ std::string Generator::MakeBitmaskConverter(const WisBitmask& s, Backend backend continue; } converters += std::format( - " if (value & {}{}) {{ result = static_cast<{}>(result | {}); }}\n", - GetCFullTypename(s.name, backend), - m.name, - cvt.value, - convert_value - ); + " if (value & {}{}) {{ result = static_cast<{}>(result | {}); }}\n", + GetCFullTypename(s.name, backend), + m.name, + cvt.value, + convert_value + ); } } else { for (auto& m : s.values) { @@ -247,11 +247,11 @@ std::string Generator::MakeBitmaskConverter(const WisBitmask& s, Backend backend continue; } converters += std::format( - " if (value & {}{}) {{ result |= {}; }}\n", - GetCFullTypename(s.name, backend), - m.name, - convert_value - ); + " if (value & {}{}) {{ result |= {}; }}\n", + GetCFullTypename(s.name, backend), + m.name, + convert_value + ); } } @@ -261,19 +261,19 @@ std::string Generator::MakeBitmaskConverter(const WisBitmask& s, Backend backend if (cvt.convert_back) { if (cvt.direct) { converters += std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", - wisdom_type, - backend_tag, - cvt.value, - wisdom_type - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", + wisdom_type, + backend_tag, + cvt.value, + wisdom_type + ); } else { converters += std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n", - wisdom_type, - backend_tag, - cvt.value - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n", + wisdom_type, + backend_tag, + cvt.value + ); converters += std::format(" {} result = static_cast<{}>(0);\n", wisdom_type, wisdom_type); for (auto& m : s.values) { @@ -282,12 +282,12 @@ std::string Generator::MakeBitmaskConverter(const WisBitmask& s, Backend backend continue; } converters += std::format( - " if (value & {}) {{ result = static_cast<{}>(result | {}{}); }}\n", - convert_value, - wisdom_type, - wisdom_type, - m.name - ); + " if (value & {}) {{ result = static_cast<{}>(result | {}{}); }}\n", + convert_value, + wisdom_type, + wisdom_type, + m.name + ); } converters += std::format(" return result;\n}}\n\n"); @@ -310,11 +310,11 @@ void Generator::WriteBitmaskDocumentation(std::filesystem::path enum_output_path files.push_back(enum_file_path); std::string enum_template_content = std::format( - " * C version:\n```c\n{}```\n" - "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", - MakeCBitmask(enum_ref, DocKind::VersionOnly), - MakeCPPBitmask(enum_ref, DocKind::VersionOnly) - ); + " * C version:\n```c\n{}```\n" + "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", + MakeCBitmask(enum_ref, DocKind::VersionOnly), + MakeCPPBitmask(enum_ref, DocKind::VersionOnly) + ); std::string enum_description = std::format(" * {}", MakeBitmaskDescription(enum_ref)); std::string enum_refs = GetRefs(enum_name); ReplaceAll(enum_template_content, "\n", "\n * "); diff --git a/generator/entry_main.cpp b/generator/entry_main.cpp index 5e0c425b5..5d47afa08 100644 --- a/generator/entry_main.cpp +++ b/generator/entry_main.cpp @@ -49,10 +49,10 @@ int main(int argc, char** argv) std::string_view arg = argv[1]; if (arg == "-h" || arg == "--help") { std::cout - << "Usage: " << argv[0] << " [module_name,...]\n" - << "If module_name is provided, generates API for that platform module. Otherwise, generates core API.\n" - << "Modules are stored in xml folder. For example, if module_name is 'platform', the generator will look " - "for 'xml/platform.xml' and generate API for it.\n"; + << "Usage: " << argv[0] << " [module_name,...]\n" + << "If module_name is provided, generates API for that platform module. Otherwise, generates core API.\n" + << "Modules are stored in xml folder. For example, if module_name is 'platform', the generator will look " + "for 'xml/platform.xml' and generate API for it.\n"; return 0; } @@ -64,7 +64,7 @@ int main(int argc, char** argv) size_t next_comma = arg.find(',', i); std::string_view platform_module_name = arg.substr(i, next_comma - i); auto module_path = std::filesystem::path(input_file).parent_path() - / (std::string(platform_module_name) + std::string(".xml")); + / (std::string(platform_module_name) + std::string(".xml")); g.ParseFile(module_path); g.WriteModuleAPI(); diff --git a/generator/enum.cpp b/generator/enum.cpp index a301b5cdd..e5933d53b 100644 --- a/generator/enum.cpp +++ b/generator/enum.cpp @@ -53,7 +53,7 @@ void Generator::ParseEnum(tinyxml2::XMLElement* type) } for (auto* impl_type = type->FirstChildElement("impl_type"); impl_type; - impl_type = impl_type->NextSiblingElement("impl_type")) { + impl_type = impl_type->NextSiblingElement("impl_type")) { auto impl_for = impl_type->FindAttribute("for")->Value(); auto backend = ParseBackend(impl_for); auto impl_name = impl_type->FindAttribute("name")->Value(); @@ -145,11 +145,11 @@ void Generator::WriteEnumDocumentation(std::filesystem::path enum_output_path) files.push_back(enum_file_path); std::string enum_template_content = std::format( - " * C version:\n```c\n{}```\n" - "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", - MakeCEnum(enum_ref, DocKind::VersionOnly), - MakeCPPEnum(enum_ref, DocKind::VersionOnly) - ); + " * C version:\n```c\n{}```\n" + "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", + MakeCEnum(enum_ref, DocKind::VersionOnly), + MakeCPPEnum(enum_ref, DocKind::VersionOnly) + ); std::string enum_description = std::format(" * {}", MakeEnumDescription(enum_ref)); std::string enum_refs = GetRefs(enum_name); ReplaceAll(enum_template_content, "\n", "\n * "); @@ -192,11 +192,11 @@ std::string Generator::MakeEnumDescription(const WisEnum& s) } translates += std::format( - "{} `{}` for {} implementation", - has_translate ? ", and" : "", - cvt.value, - impl_names[i] - ); + "{} `{}` for {} implementation", + has_translate ? ", and" : "", + cvt.value, + impl_names[i] + ); has_translate = true; } if (has_translate) { @@ -223,29 +223,29 @@ std::string Generator::MakeEnumConverter(const WisEnum& s, Backend backend) if (cvt.direct) { converters = std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", - cvt.value, - backend_tag, - GetCFullTypename(s.name, backend), - cvt.value - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", + cvt.value, + backend_tag, + GetCFullTypename(s.name, backend), + cvt.value + ); } else { converters = std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n switch(value) {{\n", - cvt.value, - backend_tag, - GetCFullTypename(s.name, backend) - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n switch(value) {{\n", + cvt.value, + backend_tag, + GetCFullTypename(s.name, backend) + ); for (auto& m : s.values) { auto convert_value = m.converts[static_cast(backend)]; if (convert_value.empty()) { continue; } converters += std::format( - " case {}: return {};\n", - std::format("{}{}", GetCFullTypename(s.name, backend), m.name), - convert_value - ); + " case {}: return {};\n", + std::format("{}{}", GetCFullTypename(s.name, backend), m.name), + convert_value + ); } if (!cvt.default_value.empty()) { @@ -258,19 +258,19 @@ std::string Generator::MakeEnumConverter(const WisEnum& s, Backend backend) if (cvt.convert_back) { if (cvt.direct) { converters += std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", - wisdom_type, - backend_tag, - cvt.value, - wisdom_type - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", + wisdom_type, + backend_tag, + cvt.value, + wisdom_type + ); } else { converters += std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n", - wisdom_type, - backend_tag, - cvt.value - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n", + wisdom_type, + backend_tag, + cvt.value + ); for (auto& m : s.values) { auto convert_value = m.converts[static_cast(backend)]; @@ -278,11 +278,11 @@ std::string Generator::MakeEnumConverter(const WisEnum& s, Backend backend) continue; } converters += std::format( - " if (value == {}) {{ return {}{}; }}\n", - convert_value, - wisdom_type, - m.name - ); + " if (value == {}) {{ return {}{}; }}\n", + convert_value, + wisdom_type, + m.name + ); } converters += std::format(" return static_cast<{}>(0);\n}}\n\n", wisdom_type); diff --git a/generator/function.cpp b/generator/function.cpp index d2a0a4a4b..6f3005ad7 100644 --- a/generator/function.cpp +++ b/generator/function.cpp @@ -196,8 +196,8 @@ std::string Generator::MakeCFunctionProto( } else if (func.return_type.has_result) { full_return_type = GetCFullTypename("Result", Backend::Any); std::string arg_name = func.return_type.opt_name.empty() - ? std::format("out_{}", MakeSnakeCase(func.return_type.type)) - : std::string(func.return_type.opt_name); + ? std::format("out_{}", MakeSnakeCase(func.return_type.type)) + : std::string(func.return_type.opt_name); std::string prefix = ""; size_t length = full_return_type.size() + 1 + pre_decl.size() + 1 + function_full_name.size(); @@ -262,14 +262,14 @@ std::string Generator::MakeCFunctionProto( } return std::format( - "{}{} {}({}{}{});\n", - pre_decl, - full_return_type, - function_full_name, - this_arg, - params.empty() && !post_return.empty() ? ",\n" : params.c_str(), - post_return - ); + "{}{} {}({}{}{});\n", + pre_decl, + full_return_type, + function_full_name, + this_arg, + params.empty() && !post_return.empty() ? ",\n" : params.c_str(), + post_return + ); } //---------------------------------------------------------------------------------------------------------------------- @@ -305,23 +305,23 @@ std::string Generator::MakeCPPFunctionProto( break; case Direct: full_return_type = GetMemberTypeString( - func.return_type, - type != ProtoType::Universal ? backend : Backend::Any - ); + func.return_type, + type != ProtoType::Universal ? backend : Backend::Any + ); break; case ResultOnly: full_return_type = "wis::Result"; break; case ResultAndValue: full_return_type = GetMemberTypeString( - func.return_type, - type != ProtoType::Universal ? backend : Backend::Any - ); + func.return_type, + type != ProtoType::Universal ? backend : Backend::Any + ); // Add out parameter for result { std::string prefix = ""; size_t length = full_return_type.size() + 1 + pre_decl.size() + 1 + func.name.size() + func_prefix.size() - + xclass_code.size(); + + xclass_code.size(); if (func.parameters.size() > 0) { prefix = ",\n" + std::string(length, ' '); } @@ -336,7 +336,7 @@ std::string Generator::MakeCPPFunctionProto( } size_t length = full_return_type.size() + 1 + pre_decl.size() + 1 + func.name.size() + func_prefix.size() - + xclass_code.size(); + + xclass_code.size(); size_t max_arg_length = post_return_length; // account for spans @@ -390,27 +390,27 @@ std::string Generator::MakeCPPFunctionProto( } if ((func.modifier & Modifier::Construct) != 0) { return std::format( - "{}{}{}{}({}{}){} noexcept;\n", - func_prefix, - xclass_code, - func_prefix, - std::string_view(xclass_code.begin(), xclass_code.end() - 2), - params, - post_return, - func.modifier & Modifier::Const ? " const" : "" - ); + "{}{}{}{}({}{}){} noexcept;\n", + func_prefix, + xclass_code, + func_prefix, + std::string_view(xclass_code.begin(), xclass_code.end() - 2), + params, + post_return, + func.modifier & Modifier::Const ? " const" : "" + ); } return std::format( - "{}{} {}{}{}({}{}){} noexcept;\n", - pre_decl, - full_return_type, - func_prefix, - xclass_code, - func.name, - params, - post_return, - func.modifier & Modifier::Const ? " const" : "" - ); + "{}{} {}{}{}({}{}){} noexcept;\n", + pre_decl, + full_return_type, + func_prefix, + xclass_code, + func.name, + params, + post_return, + func.modifier & Modifier::Const ? " const" : "" + ); } //---------------------------------------------------------------------------------------------------------------------- @@ -482,17 +482,17 @@ std::string Generator::MakeCPPFunctionImpl( switch (func.return_type.GetKind()) { case ReturnTypeKind::ResultAndValue: { auto ret_value_name = func.return_type.opt_name.empty() - ? std::format("out_{}", MakeSnakeCase(func.return_type.type)) - : std::string(func.return_type.opt_name); + ? std::format("out_{}", MakeSnakeCase(func.return_type.type)) + : std::string(func.return_type.opt_name); // Prepare out parameter body += std::format(" {} {}{{}};\n", GetMemberTypeString(func.return_type, backend), ret_value_name); body += std::format( - " const WisResult wis_result = ::{}({}", - c_name, - func.this_type.empty() ? "" : "&_impl_storage" - ); + " const WisResult wis_result = ::{}({}", + c_name, + func.this_type.empty() ? "" : "&_impl_storage" + ); if (func.parameters.size() > 0 && !func.this_type.empty()) { body += arg_prefix; @@ -506,21 +506,22 @@ std::string Generator::MakeCPPFunctionImpl( body += std::format(", {}.GetStorage());\n", ret_value_name); } else { body += std::format( - ", reinterpret_cast<{}*>(&{}));\n", - GetMemberTypeString(func.return_type, backend), - ret_value_name - ); + ", reinterpret_cast<{}*>(&{}));\n", + GetMemberTypeString(func.return_type, backend), + ret_value_name + ); } body += " out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, " "wis_result.error };\n"; body += std::format(" return {};\n", ret_value_name); - } break; + } + break; case ReturnTypeKind::ResultOnly: { body += std::format( - " const WisResult wis_result = ::{}({}", - c_name, - func.this_type.empty() ? "" : "&_impl_storage" - ); + " const WisResult wis_result = ::{}({}", + c_name, + func.this_type.empty() ? "" : "&_impl_storage" + ); constexpr static std::string_view arg_prefix = ",\n "; if (func.parameters.size() > 0 && !func.this_type.empty()) { body += arg_prefix; @@ -529,7 +530,8 @@ std::string Generator::MakeCPPFunctionImpl( body += ");\n"; body += " return wis::Result{ static_cast(wis_result.status), wis_result.platform_code, " "wis_result.error };\n"; - } break; + } + break; case ReturnTypeKind::Direct: { auto ret_type = GetType(func.return_type.type); std::string return_cast; @@ -547,25 +549,26 @@ std::string Generator::MakeCPPFunctionImpl( break; default: return_cast = std::format( - "reinterpret_cast<{}>", - GetMemberTypeString(func.return_type, backend) - ); + "reinterpret_cast<{}>", + GetMemberTypeString(func.return_type, backend) + ); break; } body += std::format( - " return {}(::{}({}", - return_cast, - c_name, - func.this_type.empty() ? "" : "&_impl_storage" - ); + " return {}(::{}({}", + return_cast, + c_name, + func.this_type.empty() ? "" : "&_impl_storage" + ); constexpr static std::string_view arg_prefix = ",\n "; if (func.parameters.size() > 0 && !func.this_type.empty()) { body += arg_prefix; } body += GetFunctionCallParameters(func, backend); body += "));\n"; - } break; + } + break; case ReturnTypeKind::Void: { body += std::format(" ::{}({}", c_name, func.this_type.empty() ? "" : "&_impl_storage"); constexpr static std::string_view arg_prefix = ",\n "; @@ -574,7 +577,8 @@ std::string Generator::MakeCPPFunctionImpl( } body += GetFunctionCallParameters(func, backend); body += ");\n"; - } break; + } + break; default: break; } @@ -615,18 +619,18 @@ std::string Generator::MakeFunctionDescription(const WisFunction& s) if (!s.this_type.empty()) { if (s.modifier & Modifier::Construct) { description += std::format( - "- **this** `self` is a pointer to uninitialized {{{}::}} instance memory. It will be initialized by " - "this function.\n", - s.this_type - ); + "- **this** `self` is a pointer to uninitialized {{{}::}} instance memory. It will be initialized by " + "this function.\n", + s.this_type + ); // There must also be a note about the destroy function in the description description += std::format("**note** The corresponding destroy function is `wisDestroy{}`.\n", s.this_type); } else { description += std::format( - "- **this** `self` self is a pointer to the valid {{{}::}} instance.\n", - s.this_type - ); + "- **this** `self` self is a pointer to the valid {{{}::}} instance.\n", + s.this_type + ); } } @@ -637,21 +641,21 @@ std::string Generator::MakeFunctionDescription(const WisFunction& s) switch (s.return_type.GetKind()) { case ReturnTypeKind::Direct: description += std::format( - "\n- **return** {}\n", - s.return_type.doc.empty() ? "No description." : s.return_type.doc - ); + "\n- **return** {}\n", + s.return_type.doc.empty() ? "No description." : s.return_type.doc + ); break; case ReturnTypeKind::ResultOnly: description += std::format("\n- **return** denoting the outcome of operation.\n"); break; case ReturnTypeKind::ResultAndValue: { std::string arg_name = s.return_type.opt_name.empty() ? std::format("out_{}", MakeSnakeCase(s.return_type.type)) - : std::string(s.return_type.opt_name); + : std::string(s.return_type.opt_name); description += std::format( - "- `{}` {}\n", - s.return_type.opt_name.empty() ? "value" : s.return_type.opt_name, - s.return_type.doc.empty() ? "No description." : s.return_type.doc - ); + "- `{}` {}\n", + s.return_type.opt_name.empty() ? "value" : s.return_type.opt_name, + s.return_type.doc.empty() ? "No description." : s.return_type.doc + ); description += std::format("\n- **return** denoting the outcome of operation.\n"); break; } @@ -680,10 +684,10 @@ void Generator::WriteFunctionDocumentation(std::filesystem::path func_output_pat for (auto& func_name : function_names) { auto& func_def = function_map[func_name]; std::string full_func_name = std::format( - "wis{}{}", - func_def.modifier & (Destroy | Construct) ? "" : func_def.this_type, - func_def.name - ); + "wis{}{}", + func_def.modifier & (Destroy | Construct) ? "" : func_def.this_type, + func_def.name + ); auto func_doc_path = func_output_path / std::format("{}_function.h", MakeSnakeCase(full_func_name.substr(3))); files.push_back(func_doc_path); @@ -701,18 +705,18 @@ void Generator::WriteFunctionDocumentation(std::filesystem::path func_output_pat } std::string vk_code_cpp = func_def.modifier & Modifier::Destroy || !supports_vk - ? "" - : MakeCPPFunctionImpl(func_def, Backend::Vulkan, "", DocKind::VersionOnly); + ? "" + : MakeCPPFunctionImpl(func_def, Backend::Vulkan, "", DocKind::VersionOnly); std::string dx_code_cpp = func_def.modifier & Modifier::Destroy || !supports_dx - ? "" - : MakeCPPFunctionImpl(func_def, Backend::DX12, "", DocKind::VersionOnly); + ? "" + : MakeCPPFunctionImpl(func_def, Backend::DX12, "", DocKind::VersionOnly); std::string regular_code_cpp = func_def.modifier & Modifier::Destroy || !(supports_vk && supports_dx) - ? "" - : MakeCPPFunctionImpl(func_def, Backend::Any, "", DocKind::VersionOnly); + ? "" + : MakeCPPFunctionImpl(func_def, Backend::Any, "", DocKind::VersionOnly); std::string cpp_code = regular_code_cpp; std::string cpp_impl_code = func_def.modifier & Modifier::Destroy || !(supports_vk && supports_dx) - ? "" - : vk_code_cpp + '\n' + dx_code_cpp; + ? "" + : vk_code_cpp + '\n' + dx_code_cpp; if (cpp_code.empty()) { cpp_code = !vk_code_cpp.empty() ? vk_code_cpp : dx_code_cpp; } @@ -745,7 +749,7 @@ void Generator::WriteDelegateDocumentation(std::filesystem::path func_output_pat for (auto& delegate_name : module_map.at(active_module_name).delegates_in_order) { auto full_delegate_name = GetCFullTypename(delegate_name, Backend::Any); auto delegate_doc_path = func_output_path - / std::format("{}_delegate.h", MakeSnakeCase(full_delegate_name.substr(3))); + / std::format("{}_delegate.h", MakeSnakeCase(full_delegate_name.substr(3))); auto& delegate_def = delegate_map[delegate_name]; files.push_back(delegate_doc_path); diff --git a/generator/generator.cpp b/generator/generator.cpp index 057c04c85..9048e3007 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp @@ -18,7 +18,7 @@ void Generator::ParseFile(std::filesystem::path file) bool has_modules = false; for (auto* module_node = root->FirstChildElement("module"); module_node; - module_node = module_node->NextSiblingElement("module")) { + module_node = module_node->NextSiblingElement("module")) { has_modules = true; auto* module_attr = module_node->FindAttribute("name"); @@ -140,7 +140,7 @@ void Generator::ParseRegistrySections(tinyxml2::XMLElement* root) void Generator::ParseIncludes(tinyxml2::XMLElement* includes) { for (auto* include = includes->FirstChildElement("include"); include; - include = include->NextSiblingElement("include")) { + include = include->NextSiblingElement("include")) { auto file = include->GetText(); auto rpath = std::filesystem::path(INPUT_FILE).parent_path() / file; auto absolute = std::filesystem::absolute(rpath); @@ -185,8 +185,8 @@ void Generator::WriteCAPI(std::filesystem::path dir) auto& module = module_map.at(active_module_name); bool has_independent_api = !module.enums_in_order.empty() || !module.bitmasks_in_order.empty() - || !module.structs_in_order.empty() || !module.constants_in_order.empty() - || !module.delegates_in_order.empty() || !module.functions_in_order.empty(); + || !module.structs_in_order.empty() || !module.constants_in_order.empty() + || !module.delegates_in_order.empty() || !module.functions_in_order.empty(); auto path = dir / "c_api.h"; if (!has_independent_api) { @@ -207,7 +207,7 @@ void Generator::WriteCAPI(std::filesystem::path dir) #include #include )" - : R"(#include + : R"(#include #include "wisdom_exports.h" )"; @@ -228,8 +228,8 @@ extern "C" {{ if (!module.enums_in_order.empty() || !module.bitmasks_in_order.empty()) { file << "\n//==============================================================\n" - "// Enums\n" - "//==============================================================\n\n"; + "// Enums\n" + "//==============================================================\n\n"; // Write enums for (auto& enum_name : module.enums_in_order) { @@ -248,8 +248,8 @@ extern "C" {{ if (!module.delegates_in_order.empty()) { file << "\n//==============================================================\n" - "// Delegates\n" - "//==============================================================\n\n"; + "// Delegates\n" + "//==============================================================\n\n"; // Write delegates (before structs, as structs may reference delegates) for (auto& delegate_name : module.delegates_in_order) { auto& delegate_def = delegate_map[delegate_name]; @@ -260,8 +260,8 @@ extern "C" {{ if (!module.structs_in_order.empty()) { file << "\n//==============================================================\n" - "// Structs\n" - "//==============================================================\n\n"; + "// Structs\n" + "//==============================================================\n\n"; // Write structs for (auto& struct_name : module.structs_in_order) { auto& struct_def = struct_map[struct_name]; @@ -272,8 +272,8 @@ extern "C" {{ if (!module.constants_in_order.empty()) { file << "\n//==============================================================\n" - "// Constants\n" - "//==============================================================\n\n"; + "// Constants\n" + "//==============================================================\n\n"; // Write constants for (auto& const_name : module.constants_in_order) { auto& const_def = constant_map[const_name]; @@ -367,8 +367,8 @@ void Generator::WriteCPPAPI(std::filesystem::path dir) { auto& module = module_map.at(active_module_name); bool has_independent_api = !module.enums_in_order.empty() || !module.bitmasks_in_order.empty() - || !module.structs_in_order.empty() || !module.constants_in_order.empty() - || !module.delegates_in_order.empty() || !module.functions_in_order.empty(); + || !module.structs_in_order.empty() || !module.constants_in_order.empty() + || !module.delegates_in_order.empty() || !module.functions_in_order.empty(); auto path = dir / "cpp_api.hpp"; if (!has_independent_api) { @@ -389,7 +389,7 @@ void Generator::WriteCPPAPI(std::filesystem::path dir) #include #include "c_api.h" )" - : R"(#include + : R"(#include #include "wisdom_exports.h" #include "c_api.h" )"; @@ -411,8 +411,8 @@ namespace wis {{ if (!module.enums_in_order.empty() || !module.bitmasks_in_order.empty()) { file << "\n//==============================================================\n" - "// Enums\n" - "//==============================================================\n\n"; + "// Enums\n" + "//==============================================================\n\n"; // Write enums for (auto& enum_name : module.enums_in_order) { @@ -431,8 +431,8 @@ namespace wis {{ if (!module.delegates_in_order.empty()) { file << "\n//==============================================================\n" - "// Delegates\n" - "//==============================================================\n\n"; + "// Delegates\n" + "//==============================================================\n\n"; // Write delegates (before structs, as structs may reference delegates) for (auto& delegate_name : module.delegates_in_order) { auto& delegate_def = delegate_map[delegate_name]; @@ -443,8 +443,8 @@ namespace wis {{ if (!module.structs_in_order.empty()) { file << "\n//==============================================================\n" - "// Structs\n" - "//==============================================================\n\n"; + "// Structs\n" + "//==============================================================\n\n"; // Write structs for (auto& struct_name : module.structs_in_order) { auto& struct_def = struct_map[struct_name]; @@ -455,8 +455,8 @@ namespace wis {{ if (!module.constants_in_order.empty()) { file << "\n//==============================================================\n" - "// Constants\n" - "//==============================================================\n\n"; + "// Constants\n" + "//==============================================================\n\n"; // Write constants for (auto& const_name : module.constants_in_order) { auto& const_def = constant_map[const_name]; @@ -466,7 +466,7 @@ namespace wis {{ } file << std::format( - R"( + R"( }} // namespace wis #ifdef WISDOM_DX12 @@ -474,8 +474,8 @@ namespace wis {{ namespace wis {{ )", - include_root - ); + include_root + ); // Write Views for handles for (auto& handle_name : module.views_in_order) { @@ -516,7 +516,7 @@ namespace wis {{ } file << std::format( - R"( + R"( }} // namespace wis #endif // WISDOM_DX12 @@ -525,8 +525,8 @@ namespace wis {{ namespace wis {{ )", - include_root - ); + include_root + ); // Write Views for handles for (auto& handle_name : module.views_in_order) { @@ -584,14 +584,14 @@ void Generator::WriteCIndependentAPI(std::filesystem::path dir) auto& module = module_map.at(active_module_name); auto independent_name = module.name == "Core" ? std::string("wisdom") - : std::format("wisdom_{}", MakeSnakeCase(module.name)); + : std::format("wisdom_{}", MakeSnakeCase(module.name)); auto module_folder = std::filesystem::path(module.gen_path).filename().generic_string(); if (module_folder.empty()) { module_folder = std::filesystem::path(module.gen_path).parent_path().filename().generic_string(); } auto backend_include = module_folder == "wisdom" ? std::string("generated/c_api.h") - : std::format("../{}/generated/c_api.h", module_folder); + : std::format("../{}/generated/c_api.h", module_folder); auto header_guard = std::format("WISDOM_{}_H", MakeUpperSnakeCase(module.name)); std::filesystem::path path_w = dir / (independent_name + ".h"); @@ -604,7 +604,7 @@ void Generator::WriteCIndependentAPI(std::filesystem::path dir) // Write header file_w << std::format( - R"(// This file is generated. Do not edit directly. + R"(// This file is generated. Do not edit directly. #ifndef {0} #define {0} @@ -624,9 +624,9 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); #if defined(WISDOM_DX12) && !FORCEVK_SWITCH )", - header_guard, - backend_include - ); + header_guard, + backend_include + ); constexpr static auto impl_dx = GetBackendSuffix(Backend::DX12); constexpr static auto impl_vk = GetBackendSuffix(Backend::Vulkan); @@ -660,18 +660,18 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); if (dx_has_handles) { file_w << "\n\n//==============================================================\n" - "// Handles\n" - "//==============================================================\n\n"; + "// Handles\n" + "//==============================================================\n\n"; // Write handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::DX12)) { file_w << std::format( - "typedef struct {} {};\n", - GetCFullTypename(handle_def.name, Backend::DX12), - GetCFullTypename(handle_def.name) - ); + "typedef struct {} {};\n", + GetCFullTypename(handle_def.name, Backend::DX12), + GetCFullTypename(handle_def.name) + ); } } @@ -680,46 +680,46 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); auto& handle_def = handle_map[handle_name]; if (handle_def.GetViewSize(Backend::DX12) > 0) { file_w << std::format( - "typedef struct {}View {}View;\n", - GetCFullTypename(handle_def.name, Backend::DX12), - GetCFullTypename(handle_def.name) - ); + "typedef struct {}View {}View;\n", + GetCFullTypename(handle_def.name, Backend::DX12), + GetCFullTypename(handle_def.name) + ); } } } if (dx_has_variants) { file_w << "\n\n//==============================================================\n" - "// Variants\n" - "//==============================================================\n\n"; + "// Variants\n" + "//==============================================================\n\n"; // Write variants for (auto& variant_name : module.variants_in_order) { auto& variant_def = variant_map[variant_name]; if (has(variant_def.backend, Backend::DX12)) { file_w << std::format( - "typedef struct {} {};\n", - GetCFullTypename(variant_def.name, Backend::DX12), - GetCFullTypename(variant_def.name) - ); + "typedef struct {} {};\n", + GetCFullTypename(variant_def.name, Backend::DX12), + GetCFullTypename(variant_def.name) + ); } } } file_w << "\n\n//==============================================================\n" - "// Functions\n" - "//==============================================================\n\n"; + "// Functions\n" + "//==============================================================\n\n"; // Write view getters for handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::DX12) && handle_def.GetViewSize(Backend::DX12) > 0) { file_w << std::format( - "#define wisGet{}View wisGet{}{}View\n", - handle_def.name, - GetBackendSuffix(Backend::DX12), - handle_def.name - ); + "#define wisGet{}View wisGet{}{}View\n", + handle_def.name, + GetBackendSuffix(Backend::DX12), + handle_def.name + ); } } @@ -728,10 +728,10 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); auto& func_def = function_map[func_name]; if (has(func_def.backend, Backend::DX12)) { file_w << std::format( - "#define {} {}\n", - GetCFullFunctionName(func_name), - GetCFullFunctionName(func_name, Backend::DX12) - ); + "#define {} {}\n", + GetCFullFunctionName(func_name), + GetCFullFunctionName(func_name, Backend::DX12) + ); } } @@ -769,18 +769,18 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); if (vk_has_handles) { file_w << "\n\n//==============================================================\n" - "// Handles\n" - "//==============================================================\n\n"; + "// Handles\n" + "//==============================================================\n\n"; // Write handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::Vulkan)) { file_w << std::format( - "typedef struct {} {};\n", - GetCFullTypename(handle_def.name, Backend::Vulkan), - GetCFullTypename(handle_def.name) - ); + "typedef struct {} {};\n", + GetCFullTypename(handle_def.name, Backend::Vulkan), + GetCFullTypename(handle_def.name) + ); } } @@ -789,46 +789,46 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); auto& handle_def = handle_map[handle_name]; if (handle_def.GetViewSize(Backend::Vulkan) > 0) { file_w << std::format( - "typedef struct {}View {}View;\n", - GetCFullTypename(handle_def.name, Backend::Vulkan), - GetCFullTypename(handle_def.name) - ); + "typedef struct {}View {}View;\n", + GetCFullTypename(handle_def.name, Backend::Vulkan), + GetCFullTypename(handle_def.name) + ); } } } if (vk_has_variants) { file_w << "\n\n//==============================================================\n" - "// Variants\n" - "//==============================================================\n\n"; + "// Variants\n" + "//==============================================================\n\n"; // Write variants for (auto& variant_name : module.variants_in_order) { auto& variant_def = variant_map[variant_name]; if (has(variant_def.backend, Backend::Vulkan)) { file_w << std::format( - "typedef struct {} {};\n", - GetCFullTypename(variant_def.name, Backend::Vulkan), - GetCFullTypename(variant_def.name) - ); + "typedef struct {} {};\n", + GetCFullTypename(variant_def.name, Backend::Vulkan), + GetCFullTypename(variant_def.name) + ); } } } file_w << "\n\n//==============================================================\n" - "// Functions\n" - "//==============================================================\n\n"; + "// Functions\n" + "//==============================================================\n\n"; // Write view getters for handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::Vulkan) && handle_def.GetViewSize(Backend::Vulkan) > 0) { file_w << std::format( - "#define wisGet{}View wisGet{}{}View\n", - handle_def.name, - GetBackendSuffix(Backend::Vulkan), - handle_def.name - ); + "#define wisGet{}View wisGet{}{}View\n", + handle_def.name, + GetBackendSuffix(Backend::Vulkan), + handle_def.name + ); } } @@ -837,10 +837,10 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); auto& func_def = function_map[func_name]; if (has(func_def.backend, Backend::Vulkan)) { file_w << std::format( - "#define {} {}\n", - GetCFullFunctionName(func_name), - GetCFullFunctionName(func_name, Backend::Vulkan) - ); + "#define {} {}\n", + GetCFullFunctionName(func_name), + GetCFullFunctionName(func_name, Backend::Vulkan) + ); } } @@ -868,14 +868,14 @@ void Generator::WriteCPPIndependentAPI(std::filesystem::path dir) auto& module = module_map.at(active_module_name); auto independent_name = module.name == "Core" ? std::string("wisdom") - : std::format("wisdom_{}", MakeSnakeCase(module.name)); + : std::format("wisdom_{}", MakeSnakeCase(module.name)); auto module_folder = std::filesystem::path(module.gen_path).filename().generic_string(); if (module_folder.empty()) { module_folder = std::filesystem::path(module.gen_path).parent_path().filename().generic_string(); } auto backend_include = module_folder == "wisdom" ? std::string("generated/cpp_api.hpp") - : std::format("../{}/generated/cpp_api.hpp", module_folder); + : std::format("../{}/generated/cpp_api.hpp", module_folder); auto header_guard = std::format("WISDOM_{}_HPP", MakeUpperSnakeCase(module.name)); std::filesystem::path path_w = dir / (independent_name + ".hpp"); @@ -888,7 +888,7 @@ void Generator::WriteCPPIndependentAPI(std::filesystem::path dir) // Write header file_w << std::format( - R"(// This file is generated. Do not edit directly. + R"(// This file is generated. Do not edit directly. #ifndef {0} #define {0} @@ -910,9 +910,9 @@ void Generator::WriteCPPIndependentAPI(std::filesystem::path dir) namespace wis {{ )", - header_guard, - backend_include - ); + header_guard, + backend_include + ); if (module.name == "Core") { file_w << "static constexpr wis::ShaderIntermediate shader_intermediate = wis::ShaderIntermediate::DXIL;\n"; @@ -953,18 +953,18 @@ namespace wis {{ if (dx_has_handles) { file_w << "\n\n//==============================================================\n" - "// Handles\n" - "//==============================================================\n\n"; + "// Handles\n" + "//==============================================================\n\n"; // Write handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::DX12)) { file_w << std::format( - "using {} = {};\n", - handle_def.name, - GetCPPFullTypename(handle_def.name, Backend::DX12) - ); + "using {} = {};\n", + handle_def.name, + GetCPPFullTypename(handle_def.name, Backend::DX12) + ); } } @@ -973,36 +973,36 @@ namespace wis {{ auto& handle_def = handle_map[handle_name]; if (handle_def.GetViewSize(Backend::DX12) > 0) { file_w << std::format( - "using {}View = {};\n", - handle_def.name, - GetCPPFullTypename(handle_def.name, Backend::DX12) + "View" - ); + "using {}View = {};\n", + handle_def.name, + GetCPPFullTypename(handle_def.name, Backend::DX12) + "View" + ); } } } if (dx_has_variants) { file_w << "\n\n//==============================================================\n" - "// Variants\n" - "//==============================================================\n\n"; + "// Variants\n" + "//==============================================================\n\n"; // Write variants for (auto& variant_name : module.variants_in_order) { auto& variant_def = variant_map[variant_name]; if (has(variant_def.backend, Backend::DX12)) { file_w << std::format( - "using {} = {};\n", - variant_def.name, - GetCPPFullTypename(variant_def.name, Backend::DX12) - ); + "using {} = {};\n", + variant_def.name, + GetCPPFullTypename(variant_def.name, Backend::DX12) + ); } } } if (dx_has_functions) { file_w << "\n\n//==============================================================\n" - "// Functions\n" - "//==============================================================\n\n"; + "// Functions\n" + "//==============================================================\n\n"; // Write functions for (auto& func_name : module.free_functions_in_order) { @@ -1062,18 +1062,18 @@ namespace wis { if (vk_has_handles) { file_w << "\n\n//==============================================================\n" - "// Handles\n" - "//==============================================================\n\n"; + "// Handles\n" + "//==============================================================\n\n"; // Write handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::Vulkan)) { file_w << std::format( - "using {} = {};\n", - handle_def.name, - GetCPPFullTypename(handle_def.name, Backend::Vulkan) - ); + "using {} = {};\n", + handle_def.name, + GetCPPFullTypename(handle_def.name, Backend::Vulkan) + ); } } @@ -1082,36 +1082,36 @@ namespace wis { auto& handle_def = handle_map[handle_name]; if (handle_def.GetViewSize(Backend::Vulkan) > 0) { file_w << std::format( - "using {}View = {};\n", - handle_def.name, - GetCPPFullTypename(handle_def.name, Backend::Vulkan) + "View" - ); + "using {}View = {};\n", + handle_def.name, + GetCPPFullTypename(handle_def.name, Backend::Vulkan) + "View" + ); } } } if (vk_has_variants) { file_w << "\n\n//==============================================================\n" - "// Variants\n" - "//==============================================================\n\n"; + "// Variants\n" + "//==============================================================\n\n"; // Write variants for (auto& variant_name : module.variants_in_order) { auto& variant_def = variant_map[variant_name]; if (has(variant_def.backend, Backend::Vulkan)) { file_w << std::format( - "using {} = {};\n", - variant_def.name, - GetCPPFullTypename(variant_def.name, Backend::Vulkan) - ); + "using {} = {};\n", + variant_def.name, + GetCPPFullTypename(variant_def.name, Backend::Vulkan) + ); } } } if (vk_has_functions) { file_w << "\n\n//==============================================================\n" - "// Functions\n" - "//==============================================================\n\n"; + "// Functions\n" + "//==============================================================\n\n"; // Write functions for (auto& func_name : module.free_functions_in_order) { @@ -1119,7 +1119,7 @@ namespace wis { auto& func_def = function_map[key]; if (has(func_def.backend, Backend::Vulkan)) { file_w - << MakeCPPFunctionImpl(func_def, Backend::Vulkan, "inline ", DocKind::Full, ProtoType::Universal); + << MakeCPPFunctionImpl(func_def, Backend::Vulkan, "inline ", DocKind::Full, ProtoType::Universal); file_w << '\n'; } } @@ -1160,7 +1160,7 @@ void Generator::WriteConversions(std::filesystem::path dir) // Write header file_dx << std::format( - R"(// This file is generated. Do not edit directly. + R"(// This file is generated. Do not edit directly. #ifndef WISDOM_{0}_CPP_DX12_CONVERT_HPP #define WISDOM_{0}_CPP_DX12_CONVERT_HPP #ifndef __cplusplus @@ -1173,10 +1173,10 @@ void Generator::WriteConversions(std::filesystem::path dir) namespace wis{{ namespace detail {{ )", - header_guard - ); + header_guard + ); file_vk << std::format( - R"(// This file is generated. Do not edit directly. + R"(// This file is generated. Do not edit directly. #ifndef WISDOM_{0}_CPP_VK_CONVERT_HPP #define WISDOM_{0}_CPP_VK_CONVERT_HPP #ifndef __cplusplus @@ -1189,8 +1189,8 @@ namespace wis{{ namespace detail {{ namespace wis{{ namespace detail {{ )", - header_guard - ); + header_guard + ); // Write enums for (auto& enum_name : module.enums_in_order) { @@ -1211,19 +1211,19 @@ namespace wis{{ namespace detail {{ // Write footer file_dx << std::format( - R"( + R"( }}}} #endif // WISDOM_{}_CPP_DX12_CONVERT_HPP )", - header_guard - ); + header_guard + ); file_vk << std::format( - R"( + R"( }}}} #endif // WISDOM_{}_CPP_VK_CONVERT_HPP )", - header_guard - ); + header_guard + ); } void Generator::WriteDocumentation( @@ -1246,9 +1246,9 @@ void Generator::WriteDocumentation( if (!file_exists) { std::string xenum = std::vformat( - doc_template, - std::make_format_args(object_name, code, desc, active_module_name) - ); + doc_template, + std::make_format_args(object_name, code, desc, active_module_name) + ); enum_file << FinalizeCDocumentation(xenum, object_name); enum_file.close(); @@ -1278,22 +1278,22 @@ void Generator::WriteDocumentation( // Replace the references section if (ref_start != std::string::npos && ref_end != std::string::npos && ref_end > ref_start) { existing_content = existing_content.substr(0, ref_start) + "\\cond WIS_GEN_REFS\n" + std::string(refs) - + existing_content.substr(ref_end); + + existing_content.substr(ref_end); } // Replace the vuids section if (vuid_start != std::string::npos && vuid_end != std::string::npos && vuid_end > vuid_start) { existing_content = existing_content.substr(0, vuid_start) + "\\cond WIS_GEN_WIS_IDS\n" + std::string(vuids) - + existing_content.substr(vuid_end); + + existing_content.substr(vuid_end); } // Replace the description section if (desc_start != std::string::npos && desc_end != std::string::npos && desc_end > desc_start) { existing_content = existing_content.substr(0, desc_start) + "\\cond WIS_GEN_DESC\n" + std::string(desc) - + existing_content.substr(desc_end); + + existing_content.substr(desc_end); } // Replace the generated section if (gen_start != std::string::npos && gen_end != std::string::npos && gen_end > gen_start) { existing_content = existing_content.substr(0, gen_start) + "\\cond WIS_GEN_CODE\n" + std::string(code) - + existing_content.substr(gen_end); + + existing_content.substr(gen_end); } // Write back to file @@ -1359,7 +1359,9 @@ void Generator::TryMakeRef(std::string_view type, std::string_view ref) } } -void Generator::TryMakeRef(std::string_view type, FunctionKey ref) { dependency_tree[type].functions.push_back(ref); } +void Generator::TryMakeRef(std::string_view type, FunctionKey ref) { + dependency_tree[type].functions.push_back(ref); +} std::string Generator::GetCFullTypename(std::string_view type, Backend backend) { @@ -1458,35 +1460,35 @@ std::string Generator::FinalizeCDocumentation(std::string doc, std::string_view auto& x = enum_map.at(this_type_view); auto evalue = x.HasValue(value); replacement = evalue ? std::format("`{}{}`", GetCFullTypename(x.name, backend), evalue->name) - : GetCFullTypename(x.name, backend); + : GetCFullTypename(x.name, backend); break; } case TypeKind::Bitmask: { auto& b = bitmask_map.at(this_type_view); auto evalue = b.HasValue(value); replacement = evalue ? std::format("`{}{}`", GetCFullTypename(b.name, backend), evalue->name) - : GetCFullTypename(b.name, backend); + : GetCFullTypename(b.name, backend); break; } case TypeKind::Struct: { auto& s = struct_map.at(this_type_view); auto member = s.HasValue(value); replacement = member ? std::format("`{}::{}`", GetCFullTypename(s.name, backend), member->name) - : GetCFullTypename(s.name, backend); + : GetCFullTypename(s.name, backend); break; } case TypeKind::Variant: { auto& v = variant_map.at(this_type_view); auto m = v.HasValue(value); replacement = m ? std::format("`{}::{}`", GetCFullTypename(v.name, backend), m->name) - : GetCFullTypename(v.name, backend); + : GetCFullTypename(v.name, backend); break; } case TypeKind::FuncPointer: { auto& d = delegate_map.at(this_type_view); auto m = d.HasValue(value); replacement = m ? std::format("`{}::{}`", GetCFullTypename(d.name, backend), m->name) - : GetCFullTypename(d.name, backend); + : GetCFullTypename(d.name, backend); break; } case TypeKind::Handle: { @@ -1575,35 +1577,35 @@ std::string Generator::FinalizeCPPDocumentation(std::string doc, std::string_vie auto& x = enum_map.at(this_type_view); auto evalue = x.HasValue(value); replacement = evalue ? std::format("`{}::{}`", GetCPPFullTypename(x.name, backend), evalue->name) - : GetCPPFullTypename(x.name, backend); + : GetCPPFullTypename(x.name, backend); break; } case TypeKind::Bitmask: { auto& b = bitmask_map.at(this_type_view); auto evalue = b.HasValue(value); replacement = evalue ? std::format("`{}::{}`", GetCPPFullTypename(b.name, backend), evalue->name) - : GetCPPFullTypename(b.name, backend); + : GetCPPFullTypename(b.name, backend); break; } case TypeKind::Struct: { auto& s = struct_map.at(this_type_view); auto member = s.HasValue(value); replacement = member ? std::format("`{}::{}`", GetCPPFullTypename(s.name, backend), member->name) - : GetCPPFullTypename(s.name, backend); + : GetCPPFullTypename(s.name, backend); break; } case TypeKind::Variant: { auto& v = variant_map.at(this_type_view); auto m = v.HasValue(value); replacement = m ? std::format("`{}::{}`", GetCPPFullTypename(v.name, backend), m->name) - : GetCPPFullTypename(v.name, backend); + : GetCPPFullTypename(v.name, backend); break; } case TypeKind::FuncPointer: { auto& d = delegate_map.at(this_type_view); auto m = d.HasValue(value); replacement = m ? std::format("`{}::{}`", GetCPPFullTypename(d.name, backend), m->name) - : GetCPPFullTypename(d.name, backend); + : GetCPPFullTypename(d.name, backend); break; } case TypeKind::Handle: { @@ -1675,9 +1677,9 @@ std::string Generator::GetSpecificationCode( if (!c_impl_code.empty()) { // append a details section template_content_c += std::format( - "
\nC Implementation Specific Version:\n```c\n{}```\n
\n", - c_impl_code - ); + "
\nC Implementation Specific Version:\n```c\n{}```\n
\n", + c_impl_code + ); } } @@ -1687,10 +1689,10 @@ std::string Generator::GetSpecificationCode( if (!cpp_impl_code.empty()) { // append a details section template_content_cpp += std::format( - "
\nC++ Implementation Specific Version:\n```cpp\nnamespace " - "wis{{\n{}}}\n```\n
\n", - cpp_impl_code - ); + "
\nC++ Implementation Specific Version:\n```cpp\nnamespace " + "wis{{\n{}}}\n```\n
\n", + cpp_impl_code + ); } } @@ -1940,11 +1942,11 @@ std::string Generator::GetFunctionCallParameters(const WisFunction& func, Backen if (p.modifier & Modifier::Span) { body += std::format( - "reinterpret_cast<{}>({}.data()), {}.size()", - GetMemberTypeString(p, backend), - p.name, - p.name - ); + "reinterpret_cast<{}>({}.data()), {}.size()", + GetMemberTypeString(p, backend), + p.name, + p.name + ); i++; // skip next parameter (the size) if (i < func.parameters.size() - 1) { body += arg_prefix; diff --git a/generator/generator.hpp b/generator/generator.hpp index ed81b818c..0f12a353f 100644 --- a/generator/generator.hpp +++ b/generator/generator.hpp @@ -25,7 +25,9 @@ class Generator void ParseFile(std::filesystem::path file); void WriteModuleAPI(); void WriteModuleAPIDoc(std::string_view module_name = {}); - auto GetFiles() const { return std::span{files}; } + auto GetFiles() const { + return std::span {files}; + } public: void ParseIncludes(tinyxml2::XMLElement* includes); @@ -253,7 +255,7 @@ class Generator } } return pre_doc ? std::format(" {}\n {}\n", documentation, value_decl) - : std::format("{}{}\n", value_decl, documentation); + : std::format("{}{}\n", value_decl, documentation); } template @@ -267,9 +269,9 @@ class Generator // This arg if (!type.this_type.empty()) { args += std::format( - "@param self is a pointer to the valid {{{}::}} instance.\n", - type.this_type - ); + "@param self is a pointer to the valid {{{}::}} instance.\n", + type.this_type + ); } // Function arguments @@ -354,9 +356,9 @@ class Generator } if (member.modifier & Modifier::Span) { return std::format( - "wis::span<{}>", - attributes_pre + GetCPPFullTypename(member.type, backend) + attributes_inter - ); + "wis::span<{}>", + attributes_pre + GetCPPFullTypename(member.type, backend) + attributes_inter + ); } return attributes_pre + GetCPPFullTypename(member.type, backend) + attributes_inter; } else { diff --git a/generator/handle.cpp b/generator/handle.cpp index e4fb52d6d..2d55414b6 100644 --- a/generator/handle.cpp +++ b/generator/handle.cpp @@ -169,10 +169,10 @@ std::string Generator::MakeCHandle(const WisHandle& s, Backend backend, DocKind auto impl_string = GetBackendSuffix(backend); auto extends_macro = s.extends == Extends::None - ? std::string("WIS_DEFINE_HANDLE") - : (s.extends == Extends::Instance - ? std::format("WIS_DEFINE_{}_INSTANCE_EXT_HANDLE", impl_string) - : std::format("WIS_DEFINE_{}_DEVICE_EXT_HANDLE", impl_string)); + ? std::string("WIS_DEFINE_HANDLE") + : (s.extends == Extends::Instance + ? std::format("WIS_DEFINE_{}_INSTANCE_EXT_HANDLE", impl_string) + : std::format("WIS_DEFINE_{}_DEVICE_EXT_HANDLE", impl_string)); auto full_name = GetCFullTypename(s.name, backend); @@ -191,12 +191,12 @@ std::string Generator::MakeCHandle(const WisHandle& s, Backend backend, DocKind auto view_name = s.view_override.empty() ? full_name : GetCFullTypename(s.view_override, backend); st_decl += std::format( - "\nstatic inline {}View wisGet{}{}View(const {}* handle){{\n", - view_name, - impl_string, - s.name, - full_name - ); + "\nstatic inline {}View wisGet{}{}View(const {}* handle){{\n", + view_name, + impl_string, + s.name, + full_name + ); st_decl += std::format(" {}View v;\n", view_name); st_decl += " memcpy(&v, handle, sizeof(v));\n" " return v;\n}\n"; @@ -212,23 +212,23 @@ std::string Generator::MakeCPPHandle(const WisHandle& s, Backend backend, DocKin auto full_name = GetCFullTypename(s.name, backend); std::string deleter = std::format( - "struct {}{}Deleter {{\n " - "void operator()({}* handle) noexcept {{\n ", - impl_string, - s.name, - full_name - ); + "struct {}{}Deleter {{\n " + "void operator()({}* handle) noexcept {{\n ", + impl_string, + s.name, + full_name + ); std::string st_decl = std::format( - "class {}{} : public wis::impl::Implements{{\npublic:\n", - impl_string, - s.name, - impl_string, - s.name, - full_name, - impl_string, - s.name - ); + "class {}{} : public wis::impl::Implements{{\npublic:\n", + impl_string, + s.name, + impl_string, + s.name, + full_name, + impl_string, + s.name + ); if (!s.doc.empty()) { std::string xdoc = MakeTypeDocumentation(s, kind); @@ -246,25 +246,25 @@ std::string Generator::MakeCPPHandle(const WisHandle& s, Backend backend, DocKin // Strict aliasing rules prevent us from doing a simple cast, so we have to memcpy the data to a new view struct auto view_name = s.view_override.empty() ? s.name : s.view_override; st_decl2 += std::format( - " WIS_NODISCARD {}{}View GetView() const noexcept {{\n" - " {}{}View v;\n" - " std::memcpy(&v, &_impl_storage, sizeof(v));\n" - " return v;\n" - " }}\n", - impl_string, - view_name, - impl_string, - view_name - ); + " WIS_NODISCARD {}{}View GetView() const noexcept {{\n" + " {}{}View v;\n" + " std::memcpy(&v, &_impl_storage, sizeof(v));\n" + " return v;\n" + " }}\n", + impl_string, + view_name, + impl_string, + view_name + ); // add conversion operator to view st_decl2 += std::format( - " WIS_NODISCARD operator {}{}View() const noexcept {{\n" - " return GetView();\n" - " }}\n", - impl_string, - view_name - ); + " WIS_NODISCARD operator {}{}View() const noexcept {{\n" + " return GetView();\n" + " }}\n", + impl_string, + view_name + ); } // Add all the functions @@ -272,11 +272,11 @@ std::string Generator::MakeCPPHandle(const WisHandle& s, Backend backend, DocKin FunctionKey func_key{s.name, func_name}; auto& func_ref = function_map[func_key]; auto c_name = std::format( - "wis{}{}{}", - impl_string, - func_ref.modifier & (Destroy | Construct) ? "" : func_ref.this_type, - func_ref.name - ); + "wis{}{}{}", + impl_string, + func_ref.modifier & (Destroy | Construct) ? "" : func_ref.this_type, + func_ref.name + ); if (func_ref.modifier & Modifier::Destroy) { deleter += std::format(" ::{}(handle);\n", c_name); continue; @@ -315,17 +315,17 @@ std::string Generator::MakeCPPHandle(const WisHandle& s, Backend backend, DocKin } ctor_decl += std::format( - " {}{}({}) noexcept\n" - " :ImplType(wis::in_place)\n" - " {{\n" - " ::{}({});\n" - " }}\n", - impl_string, - s.name, - params, - c_name, - args - ); + " {}{}({}) noexcept\n" + " :ImplType(wis::in_place)\n" + " {{\n" + " ::{}({});\n" + " }}\n", + impl_string, + s.name, + params, + c_name, + args + ); continue; } @@ -334,14 +334,14 @@ std::string Generator::MakeCPPHandle(const WisHandle& s, Backend backend, DocKin if (s.extends != Extends::None) { auto header = s.extends == Extends::Instance ? GetCPPFullTypename("InstanceExtensionHeader", backend) - : GetCPPFullTypename("DeviceExtensionHeader", backend); + : GetCPPFullTypename("DeviceExtensionHeader", backend); ctor_decl += std::format( - " // Operator & overload\n" - "{}* operator&() noexcept {{\n" - " return &GetMutableInternal().header;\n" - "}}\n", - header - ); + " // Operator & overload\n" + "{}* operator&() noexcept {{\n" + " return &GetMutableInternal().header;\n" + "}}\n", + header + ); } deleter += " }\n};\n"; @@ -372,7 +372,7 @@ void Generator::WriteHandleDocumentation(std::filesystem::path handle_output_pat // Make a folder for enums starting with this letter std::filesystem::create_directories(handle_output_path); std::filesystem::path handle_file_path = handle_output_path - / std::format("{}_handle.h", MakeSnakeCase(handle_name)); + / std::format("{}_handle.h", MakeSnakeCase(handle_name)); auto& handle_ref = handle_map[handle_name]; files.push_back(handle_file_path); diff --git a/generator/struct.cpp b/generator/struct.cpp index 8a4cbd3f1..514eb8c61 100644 --- a/generator/struct.cpp +++ b/generator/struct.cpp @@ -91,10 +91,10 @@ std::string Generator::MakeCStruct(const WisStruct& s, DocKind kind) { auto full_name = GetCFullTypename(s.name, Backend::Any); std::string st_decl = std::format( - "typedef struct {} {} {{\n", - s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD" : "", - full_name - ); + "typedef struct {} {} {{\n", + s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD" : "", + full_name + ); if (!s.doc.empty()) { std::string xdoc = MakeTypeDocumentation(s, kind); st_decl = std::format("{}\n{}", xdoc, st_decl); @@ -118,10 +118,10 @@ std::string Generator::MakeCStruct(const WisStruct& s, DocKind kind) std::string Generator::MakeCPPStruct(const WisStruct& s, DocKind kind) { std::string st_decl = std::format( - "struct {} {} {{\n", - s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD" : "", - s.name - ); + "struct {} {} {{\n", + s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD" : "", + s.name + ); if (!s.doc.empty()) { std::string xdoc = MakeTypeDocumentation(s, kind); st_decl = std::format("{}\n{}", xdoc, st_decl); @@ -142,11 +142,11 @@ std::string Generator::MakeCPPStruct(const WisStruct& s, DocKind kind) } st_decl += MakeValueDocumentation( - s, - m, - MakeCPPMemberDeclaration(m, max_type_length, Backend::Any), - kind - ); + s, + m, + MakeCPPMemberDeclaration(m, max_type_length, Backend::Any), + kind + ); prev_span = m.modifier & Modifier::Span; } st_decl += "};\n"; @@ -213,16 +213,16 @@ void Generator::WriteStructDocumentation(std::filesystem::path struct_output_pat for (const auto& struct_name : struct_names) { // Make a folder for enums starting with this letter std::filesystem::path struct_file_path = struct_output_path - / std::format("{}_struct.h", MakeSnakeCase(struct_name)); + / std::format("{}_struct.h", MakeSnakeCase(struct_name)); auto& struct_ref = struct_map[struct_name]; files.push_back(struct_file_path); std::string struct_template_content = std::format( - " * C version:\n```c\n{}```\n" - "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", - MakeCStruct(struct_ref, DocKind::VersionOnly), - MakeCPPStruct(struct_ref, DocKind::VersionOnly) - ); + " * C version:\n```c\n{}```\n" + "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", + MakeCStruct(struct_ref, DocKind::VersionOnly), + MakeCPPStruct(struct_ref, DocKind::VersionOnly) + ); std::string struct_description = std::format(" * {}", MakeStructDescription(struct_ref)); std::string struct_refs = GetRefs(struct_name); diff --git a/generator/types.hpp b/generator/types.hpp index dfe6932c6..5d99f4cbd 100644 --- a/generator/types.hpp +++ b/generator/types.hpp @@ -41,7 +41,9 @@ constexpr Backend operator&(Backend a, Backend b) { return static_cast(static_cast(a) & static_cast(b)); } -constexpr bool has(Backend a, Backend b) { return (a & b) == b; } +constexpr bool has(Backend a, Backend b) { + return (a & b) == b; +} enum class ImplOs { None, @@ -118,8 +120,11 @@ struct WisEnum { public: std::optional HasValue(std::string_view name) const noexcept { - auto enum_value = std::find_if(values.begin(), values.end(), [&](auto& v) { return v.name == name; }); - return enum_value != values.end() ? std::optional{*enum_value} : std::nullopt; + auto enum_value = std::find_if(values.begin(), values.end(), [&](auto& v) { + return v.name == name; + }); + return enum_value != values.end() ? std::optional {*enum_value} : + std::nullopt; } }; @@ -142,8 +147,11 @@ struct WisBitmask { public: std::optional HasValue(std::string_view name) const noexcept { - auto enum_value = std::find_if(values.begin(), values.end(), [&](auto& v) { return v.name == name; }); - return enum_value != values.end() ? std::optional{*enum_value} : std::nullopt; + auto enum_value = std::find_if(values.begin(), values.end(), [&](auto& v) { + return v.name == name; + }); + return enum_value != values.end() ? std::optional {*enum_value} : + std::nullopt; } }; @@ -174,10 +182,14 @@ struct WisStruct { return {}; } - auto enum_value = std::find_if(members.begin(), members.end(), [&](auto& v) { return v.name == name; }); + auto enum_value = std::find_if(members.begin(), members.end(), [&](auto& v) { + return v.name == name; + }); return *enum_value; } - void FilterBackend(Backend b) { backend = backend & b; } + void FilterBackend(Backend b) { + backend = backend & b; + } }; //---------------------------------------------------------------------------------------------------------------------- @@ -256,10 +268,18 @@ struct WisReturnType { return ReturnTypeKind::ResultAndValue; } - bool IsVoid() const noexcept { return type.empty() && !has_result; } - bool IsRV() const noexcept { return has_result && !type.empty(); } - bool IsDirect() const noexcept { return !has_result && !type.empty(); } - bool IsResultOnly() const noexcept { return has_result && type.empty(); } + bool IsVoid() const noexcept { + return type.empty() && !has_result; + } + bool IsRV() const noexcept { + return has_result && !type.empty(); + } + bool IsDirect() const noexcept { + return !has_result && !type.empty(); + } + bool IsResultOnly() const noexcept { + return has_result && type.empty(); + } }; struct WisFunction { std::string_view name; @@ -278,7 +298,9 @@ struct WisFunction { if (name.empty()) { return {}; } - auto enum_value = std::find_if(parameters.begin(), parameters.end(), [&](auto& v) { return v.name == name; }); + auto enum_value = std::find_if(parameters.begin(), parameters.end(), [&](auto& v) { + return v.name == name; + }); if (enum_value == parameters.end()) { // it can be return value if (return_type.opt_name == name) { @@ -296,9 +318,13 @@ struct WisFunction { } // constructor or destructor - bool IsCD() const noexcept { return modifier & (Modifier::Construct | Modifier::Destroy); } + bool IsCD() const noexcept { + return modifier & (Modifier::Construct | Modifier::Destroy); + } - void FilterBackend(Backend b) { backend = backend & b; } + void FilterBackend(Backend b) { + backend = backend & b; + } }; static inline constexpr Severity from_chars(std::string_view input) noexcept @@ -342,7 +368,7 @@ template <> struct hash { std::size_t operator()(const FunctionKey& k) const noexcept { - return std::hash{}(k.first) ^ (std::hash{}(k.second) << 1); + return std::hash {}(k.first) ^ (std::hash {}(k.second) << 1); } }; } // namespace std diff --git a/generator/validation.cpp b/generator/validation.cpp index 33388eed5..640e7ef31 100644 --- a/generator/validation.cpp +++ b/generator/validation.cpp @@ -4,7 +4,7 @@ void Generator::ParseValidations(tinyxml2::XMLElement* validations) { for (auto* validation = validations->FirstChildElement("validation"); validation; - validation = validation->NextSiblingElement("validation")) { + validation = validation->NextSiblingElement("validation")) { auto name = validation->FindAttribute("for")->Value(); auto& ref = validation_map[name]; diff --git a/generator/variant.cpp b/generator/variant.cpp index 2b7deb445..fc5affd39 100644 --- a/generator/variant.cpp +++ b/generator/variant.cpp @@ -91,10 +91,10 @@ std::string Generator::MakeCVariant(const WisStruct& s, Backend backend, DocKind auto impl_suffix = GetBackendSuffix(backend); auto full_name = GetCFullTypename(s.name, backend); std::string st_decl = std::format( - "typedef struct {}{} {{\n", - s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD " : "", - full_name - ); + "typedef struct {}{} {{\n", + s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD " : "", + full_name + ); if (!s.doc.empty()) { std::string xdoc = MakeTypeDocumentation(s, kind); st_decl = std::format("{}\n{}", xdoc, st_decl); @@ -123,11 +123,11 @@ std::string Generator::MakeCPPVariant(const WisStruct& s, Backend backend, DocKi auto impl_suffix = GetBackendSuffix(backend); std::string st_decl = std::format( - "struct {}{}{} {{\n", - s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD " : "", - impl_suffix, - s.name - ); + "struct {}{}{} {{\n", + s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD " : "", + impl_suffix, + s.name + ); if (!s.doc.empty()) { std::string xdoc = MakeTypeDocumentation(s, kind); st_decl = std::format("{}\n{}", xdoc, st_decl); @@ -171,7 +171,7 @@ void Generator::WriteVariantDocumentation(std::filesystem::path struct_output_pa for (const auto& variant_name : variant_names) { // Make a folder for enums starting with this letter std::filesystem::path variant_file_path = struct_output_path - / std::format("{}_struct.h", MakeSnakeCase(variant_name)); + / std::format("{}_struct.h", MakeSnakeCase(variant_name)); auto& variant_ref = variant_map[variant_name]; files.push_back(variant_file_path); @@ -181,8 +181,8 @@ void Generator::WriteVariantDocumentation(std::filesystem::path struct_output_pa std::string vk_code = supports_vk ? MakeCVariant(variant_ref, Backend::Vulkan, DocKind::VersionOnly) : ""; std::string dx_code = supports_dx ? MakeCVariant(variant_ref, Backend::DX12, DocKind::VersionOnly) : ""; std::string regular_code = supports_vk && supports_dx - ? MakeCVariant(variant_ref, Backend::Any, DocKind::VersionOnly) - : ""; + ? MakeCVariant(variant_ref, Backend::Any, DocKind::VersionOnly) + : ""; std::string c_code = regular_code; std::string cimpl_code = supports_vk && supports_dx ? (vk_code + '\n' + dx_code) : ""; @@ -191,18 +191,18 @@ void Generator::WriteVariantDocumentation(std::filesystem::path struct_output_pa } std::string vk_cpp = variant_ref.modifier & Modifier::COnly || !supports_vk - ? "" - : MakeCPPVariant(variant_ref, Backend::Vulkan, DocKind::VersionOnly); + ? "" + : MakeCPPVariant(variant_ref, Backend::Vulkan, DocKind::VersionOnly); std::string dx_cpp = variant_ref.modifier & Modifier::COnly || !supports_dx - ? "" - : MakeCPPVariant(variant_ref, Backend::DX12, DocKind::VersionOnly); + ? "" + : MakeCPPVariant(variant_ref, Backend::DX12, DocKind::VersionOnly); std::string regular_code_cpp = variant_ref.modifier & Modifier::COnly || !(supports_vk && supports_dx) - ? "" - : MakeCPPVariant(variant_ref, Backend::Any, DocKind::VersionOnly); + ? "" + : MakeCPPVariant(variant_ref, Backend::Any, DocKind::VersionOnly); std::string cpp_code = regular_code_cpp; std::string cimpl_code_cpp = variant_ref.modifier & Modifier::COnly || !(supports_vk && supports_dx) - ? "" - : vk_cpp + '\n' + dx_cpp; + ? "" + : vk_cpp + '\n' + dx_cpp; if (cpp_code.empty()) { cpp_code = !vk_cpp.empty() ? vk_cpp : dx_cpp; } diff --git a/src/include/wisdom/bridge/span.hpp b/src/include/wisdom/bridge/span.hpp index 71587b128..8e85d9cc2 100644 --- a/src/include/wisdom/bridge/span.hpp +++ b/src/include/wisdom/bridge/span.hpp @@ -73,7 +73,9 @@ struct contract_violation_error : std::logic_error { {} }; -inline void contract_violation(const char* msg) { throw contract_violation_error(msg); } +inline void contract_violation(const char* msg) { + throw contract_violation_error(msg); +} #elif defined(TCB_SPAN_TERMINATE_ON_CONTRACT_VIOLATION) [[noreturn]] inline void contract_violation( @@ -254,12 +256,12 @@ struct has_size_and_data : std::false_type {}; template struct has_size_and_data< T, - void_t())), decltype(detail::data(std::declval()))>> : std::true_type {}; +void_t())), decltype(detail::data(std::declval()))>> : std::true_type {}; template > struct is_container { static constexpr bool value = !is_span::value && !is_std_array::value && !std::is_array::value - && has_size_and_data::value; + && has_size_and_data::value; }; template @@ -273,9 +275,9 @@ struct is_container_element_type_compatible< T, E, typename std::enable_if< - !std::is_same()))>::type, void>::value - && std::is_convertible()))> (*)[], E (*)[]>::value>:: - type> : std::true_type {}; +!std::is_same()))>::type, void>::value +&& std::is_convertible()))> (*)[], E (*)[]>::value>:: +type> : std::true_type {}; template struct is_complete : std::false_type {}; @@ -319,7 +321,7 @@ class span // [span.cons], span constructors, copy, assignment, and destructor template ::type = 0> - constexpr span() noexcept + constexpr span() noexcept {} TCB_SPAN_CONSTEXPR11 span(pointer ptr, size_type count) @@ -339,7 +341,7 @@ class span std::size_t E = Extent, typename std::enable_if< (E == dynamic_extent || N == E) - && detail::is_container_element_type_compatible::value, + && detail::is_container_element_type_compatible::value, int>::type = 0> constexpr span(element_type (&arr)[N]) noexcept : storage_(arr, N) @@ -351,7 +353,7 @@ class span std::size_t E = Extent, typename std::enable_if< (E == dynamic_extent || N == E) - && detail::is_container_element_type_compatible&, ElementType>::value, + && detail::is_container_element_type_compatible&, ElementType>::value, int>::type = 0> TCB_SPAN_ARRAY_CONSTEXPR span(std::array& arr) noexcept : storage_(arr.data(), N) @@ -363,7 +365,7 @@ class span std::size_t E = Extent, typename std::enable_if< (E == dynamic_extent || N == E) - && detail::is_container_element_type_compatible&, ElementType>::value, + && detail::is_container_element_type_compatible&, ElementType>::value, int>::type = 0> TCB_SPAN_ARRAY_CONSTEXPR span(const std::array& arr) noexcept : storage_(arr.data(), N) @@ -374,7 +376,7 @@ class span std::size_t E = Extent, typename std::enable_if< E == dynamic_extent && detail::is_container::value - && detail::is_container_element_type_compatible::value, + && detail::is_container_element_type_compatible::value, int>::type = 0> constexpr span(Container& cont) : storage_(detail::data(cont), detail::size(cont)) @@ -385,7 +387,7 @@ class span std::size_t E = Extent, typename std::enable_if< E == dynamic_extent && detail::is_container::value - && detail::is_container_element_type_compatible::value, + && detail::is_container_element_type_compatible::value, int>::type = 0> constexpr span(const Container& cont) : storage_(detail::data(cont), detail::size(cont)) @@ -398,7 +400,7 @@ class span std::size_t OtherExtent, typename std::enable_if< (Extent == dynamic_extent || OtherExtent == dynamic_extent || Extent == OtherExtent) - && std::is_convertible::value, + && std::is_convertible::value, int>::type = 0> constexpr span(const span& other) noexcept : storage_(other.data(), other.size()) @@ -432,10 +434,10 @@ class span TCB_SPAN_CONSTEXPR11 subspan_return_t subspan() const { TCB_SPAN_EXPECT(Offset <= size() && (Count == dynamic_extent || Offset + Count <= size())); - return {data() + Offset, Count != dynamic_extent ? Count : size() - Offset}; + return {data() + Offset, Count != dynamic_extent ? Count : size() - Offset}; } - TCB_SPAN_CONSTEXPR11 span first(size_type count) const + TCB_SPAN_CONSTEXPR11 span first(size_type count) const { TCB_SPAN_EXPECT(count <= size()); return {data(), count}; @@ -457,11 +459,17 @@ class span } // [span.obs], span observers - constexpr size_type size() const noexcept { return storage_.size; } + constexpr size_type size() const noexcept { + return storage_.size; + } - constexpr size_type size_bytes() const noexcept { return size() * sizeof(element_type); } + constexpr size_type size_bytes() const noexcept { + return size() * sizeof(element_type); + } - TCB_SPAN_NODISCARD constexpr bool empty() const noexcept { return size() == 0; } + TCB_SPAN_NODISCARD constexpr bool empty() const noexcept { + return size() == 0; + } // [span.elem], span element access TCB_SPAN_CONSTEXPR11 reference operator[](size_type idx) const @@ -482,16 +490,26 @@ class span return WIS_UNSAFE_BUFFERS(*(data() + (size() - 1))); } - constexpr pointer data() const noexcept { return storage_.ptr; } + constexpr pointer data() const noexcept { + return storage_.ptr; + } // [span.iterators], span iterator support - constexpr iterator begin() const noexcept { return data(); } + constexpr iterator begin() const noexcept { + return data(); + } - constexpr iterator end() const noexcept { return WIS_UNSAFE_BUFFERS(data() + size()); } + constexpr iterator end() const noexcept { + return WIS_UNSAFE_BUFFERS(data() + size()); + } - TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } + TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rbegin() const noexcept { + return reverse_iterator(end()); + } - TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } + TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rend() const noexcept { + return reverse_iterator(begin()); + } private: storage_type storage_{}; @@ -558,7 +576,7 @@ constexpr span make_span(const Container& template span as_bytes( span s -) noexcept + ) noexcept { return {reinterpret_cast(s.data()), s.size_bytes()}; } @@ -566,7 +584,7 @@ span::value, int>::type = 0> span as_writable_bytes( span s -) noexcept + ) noexcept { return {reinterpret_cast(s.data()), s.size_bytes()}; } @@ -587,8 +605,8 @@ class tuple_size> : public in template class tuple_size>; // not defined + ElementType, + TCB_SPAN_NAMESPACE_NAME::dynamic_extent>>; // not defined template class tuple_element> diff --git a/src/include/wisdom/dx12/detail/dx12_detail.hpp b/src/include/wisdom/dx12/detail/dx12_detail.hpp index 262d5ad8b..71d982f3a 100644 --- a/src/include/wisdom/dx12/detail/dx12_detail.hpp +++ b/src/include/wisdom/dx12/detail/dx12_detail.hpp @@ -57,11 +57,11 @@ struct DX12DebugLayerThunk final : public IUnknownImplRegisterMessageCallback( - DX12CallbackThunk, - D3D12_MESSAGE_CALLBACK_FLAG_NONE, - this, - &cookie - ); + DX12CallbackThunk, + D3D12_MESSAGE_CALLBACK_FLAG_NONE, + this, + &cookie + ); // Debug layer creation failure is allowed to silently fail (void)hr; } @@ -136,18 +136,18 @@ struct DX12RootSignatureKey { //---------------------------------------------------------------------------------------------------------------------- struct DX12ShaderHeader { - uint64_t hash[2]{}; // Hash of the shader bytecode, used for caching and identification purposes. + uint64_t hash[2] {}; // Hash of the shader bytecode, used for caching and identification purposes. std::size_t size = 0; // Size of the shader bytecode in bytes. // bytecode follows immediately after the header in memory. wis::span GetBytecode() const noexcept { - return wis::span{reinterpret_cast(this + 1), size}; + return wis::span {reinterpret_cast(this + 1), size}; } wis::span GetMutableBytecode() noexcept { - return wis::span{reinterpret_cast(this + 1), size}; + return wis::span {reinterpret_cast(this + 1), size}; } }; @@ -244,7 +244,7 @@ inline constexpr uint32_t DX12GetCopyPlaneSlice(WisBarrierFlags flags, uint16_t //---------------------------------------------------------------------------------------------------------------------- // Barrier helper constants constexpr static uint32_t dx12_max_barrier_size = std::max( - {sizeof(D3D12_BUFFER_BARRIER), sizeof(D3D12_TEXTURE_BARRIER), sizeof(D3D12_GLOBAL_BARRIER)} +{sizeof(D3D12_BUFFER_BARRIER), sizeof(D3D12_TEXTURE_BARRIER), sizeof(D3D12_GLOBAL_BARRIER)} ); constexpr static uint32_t dx12_static_size = wis::TransientMaxBarrierCount * dx12_max_barrier_size; @@ -268,8 +268,8 @@ inline std::array, 3> DX12AllocateBarriers( { std::array, 3> spans; std::size_t needed_size = barriers.buffer_barrier_count * sizeof(D3D12_BUFFER_BARRIER) - + barriers.texture_barrier_count * sizeof(D3D12_TEXTURE_BARRIER) - + barriers.global_barrier_count * sizeof(D3D12_GLOBAL_BARRIER); + + barriers.texture_barrier_count * sizeof(D3D12_TEXTURE_BARRIER) + + barriers.global_barrier_count * sizeof(D3D12_GLOBAL_BARRIER); if (needed_size <= dx12_static_size) { spans[0] = {local_scratch, barriers.buffer_barrier_count * sizeof(D3D12_BUFFER_BARRIER)}; @@ -403,7 +403,7 @@ inline void DX12InsertBarriers( return; } - uint8_t local_scratch[dx12_static_size]{}; + uint8_t local_scratch[dx12_static_size] {}; auto [buffer_span, texture_span, global_span] = DX12AllocateBarriers(impl, local_scratch, *barriers); @@ -444,13 +444,13 @@ inline void DX12InsertBarriers( bool release_barrier = qfot_barrier && src.queue_type_before == queue_type; auto layout_before = DX12GetOptimalBarrierLayout( - queue_type, - acquire_barrier ? WisTextureStateCommon : src.state_before - ); + queue_type, + acquire_barrier ? WisTextureStateCommon : src.state_before + ); auto layout_after = DX12GetOptimalBarrierLayout( - queue_type, - release_barrier ? WisTextureStateCommon : src.state_after - ); + queue_type, + release_barrier ? WisTextureStateCommon : src.state_after + ); texture_barriers_span[i] = D3D12_TEXTURE_BARRIER{ .SyncBefore = DX12Convert(src.sync_before), @@ -461,16 +461,16 @@ inline void DX12InsertBarriers( .LayoutAfter = layout_after, .pResource = std::bit_cast(src.texture), .Subresources = - { - .IndexOrFirstMipLevel = src.subresource_range.base_mip_level, - .NumMipLevels = src.subresource_range.mip_level_count, - .FirstArraySlice = src.subresource_range.base_array_layer, - .NumArraySlices = src.subresource_range.array_layer_count, - .FirstPlane = src.flags & WisBarrierFlagsPlanarImage ? src.subresource_range.plane_slice : 0u, - .NumPlanes = src.flags & WisBarrierFlagsPlanarImage ? src.subresource_range.plane_slice_count : 1u, - }, + { + .IndexOrFirstMipLevel = src.subresource_range.base_mip_level, + .NumMipLevels = src.subresource_range.mip_level_count, + .FirstArraySlice = src.subresource_range.base_array_layer, + .NumArraySlices = src.subresource_range.array_layer_count, + .FirstPlane = src.flags & WisBarrierFlagsPlanarImage ? src.subresource_range.plane_slice : 0u, + .NumPlanes = src.flags & WisBarrierFlagsPlanarImage ? src.subresource_range.plane_slice_count : 1u, + }, .Flags = src.state_before == WisTextureStateUndefined ? D3D12_TEXTURE_BARRIER_FLAG_DISCARD - : D3D12_TEXTURE_BARRIER_FLAG_NONE, + : D3D12_TEXTURE_BARRIER_FLAG_NONE, }; } @@ -488,16 +488,19 @@ inline void DX12InsertBarriers( }; } - D3D12_BARRIER_GROUP groups[]{ - {.Type = D3D12_BARRIER_TYPE_BUFFER, - .NumBarriers = real_buffer_barrier_count, - .pBufferBarriers = buffer_barriers_span.data()}, - {.Type = D3D12_BARRIER_TYPE_TEXTURE, - .NumBarriers = static_cast(barriers->texture_barrier_count), - .pTextureBarriers = texture_barriers_span.data()}, - {.Type = D3D12_BARRIER_TYPE_GLOBAL, - .NumBarriers = static_cast(barriers->global_barrier_count), - .pGlobalBarriers = global_barriers_span.data()} + D3D12_BARRIER_GROUP groups[] { + { .Type = D3D12_BARRIER_TYPE_BUFFER, + .NumBarriers = real_buffer_barrier_count, + .pBufferBarriers = buffer_barriers_span.data() + }, + { .Type = D3D12_BARRIER_TYPE_TEXTURE, + .NumBarriers = static_cast(barriers->texture_barrier_count), + .pTextureBarriers = texture_barriers_span.data() + }, + { .Type = D3D12_BARRIER_TYPE_GLOBAL, + .NumBarriers = static_cast(barriers->global_barrier_count), + .pGlobalBarriers = global_barriers_span.data() + } }; list->Barrier(std::size(groups), groups); } diff --git a/src/include/wisdom/dx12/dx12_adapter_query.cpp b/src/include/wisdom/dx12/dx12_adapter_query.cpp index c3724275e..b60934b51 100644 --- a/src/include/wisdom/dx12/dx12_adapter_query.cpp +++ b/src/include/wisdom/dx12/dx12_adapter_query.cpp @@ -112,11 +112,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12AdapterQueryCreateDevice( } wis::com_ptr device_ref; auto hr = D3D12CreateDevice( - impl.physical_devices[index], - D3D_FEATURE_LEVEL_12_0, - IID_ID3D12Device10, - reinterpret_cast(device_ref.put_void_unchecked()) - ); + impl.physical_devices[index], + D3D_FEATURE_LEVEL_12_0, + IID_ID3D12Device10, + reinterpret_cast(device_ref.put_void_unchecked()) + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -124,8 +124,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12AdapterQueryCreateDevice( D3D12_FEATURE_DATA_D3D12_OPTIONS12 options12 = {}; bool EnhancedBarriersSupported = false; if (wis::detail::succeeded( - device_ref->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12, &options12, sizeof(options12)) - )) { + device_ref->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12, &options12, sizeof(options12)) + )) { EnhancedBarriersSupported = options12.EnhancedBarriersSupported; } if (!EnhancedBarriersSupported) { @@ -136,10 +136,10 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12AdapterQueryCreateDevice( if (impl.debug_layer && impl.debug_layer->callback) { wis::com_ptr info_queue; if (auto hr2 = device_ref->QueryInterface( - IID_ID3D12InfoQueue1, - reinterpret_cast(info_queue.put_void_unchecked()) - ); - wis::detail::succeeded(hr2)) { + IID_ID3D12InfoQueue1, + reinterpret_cast(info_queue.put_void_unchecked()) + ); + wis::detail::succeeded(hr2)) { const wis::com_ptr thunk{ new wis::detail::DX12DebugLayerThunk( info_queue.get(), @@ -189,7 +189,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12AdapterQueryCreateDevice( const auto& desc = requirements->queue_descs[i]; if (desc.type >= WisCommandQueueTypeCount || desc.type < 0) { return wis::detail:: - make_result(E_INVALIDARG); + make_result(E_INVALIDARG); } if (desc.priority > WisCommandQueuePriorityNormal) { @@ -199,17 +199,17 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12AdapterQueryCreateDevice( .Priority = static_cast(wis::detail::DX12Convert(desc.priority)), }; device_impl.device - ->CheckFeatureSupport(D3D12_FEATURE_COMMAND_QUEUE_PRIORITY, &queue_priority, sizeof(queue_priority)); + ->CheckFeatureSupport(D3D12_FEATURE_COMMAND_QUEUE_PRIORITY, &queue_priority, sizeof(queue_priority)); device_impl.queue_priorities[desc.type] = queue_priority.PriorityForTypeIsSupported - ? desc.priority - : WisCommandQueuePriorityNormal; + ? desc.priority + : WisCommandQueuePriorityNormal; } device_impl.queue_priorities[desc.type] |= 1 << 7; // set support bit for this queue type } for (auto* ext : - wis::span{requirements->extensions, requirements->extension_count}) { + wis::span {requirements->extensions, requirements->extension_count}) { if (auto* table = wis::from_handle(ext); table && table->init_fptr) { if (const auto xres = table->init_fptr(table, device_impl); xres.status != WisStatusOk) { res.status = WisStatusPartial; // mark as partial success if any extension fails diff --git a/src/include/wisdom/dx12/dx12_command_allocator.cpp b/src/include/wisdom/dx12/dx12_command_allocator.cpp index 1651629f8..3ed03d7b4 100644 --- a/src/include/wisdom/dx12/dx12_command_allocator.cpp +++ b/src/include/wisdom/dx12/dx12_command_allocator.cpp @@ -40,12 +40,12 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12CommandAllocatorCreateCommandList( wis::com_ptr command_list; auto hr = device->CreateCommandList1( - 0, - wis::detail::DX12Convert(type), - D3D12_COMMAND_LIST_FLAG_NONE, - IID_ID3D12GraphicsCommandList9, - command_list.put_void_unchecked() - ); + 0, + wis::detail::DX12Convert(type), + D3D12_COMMAND_LIST_FLAG_NONE, + IID_ID3D12GraphicsCommandList9, + command_list.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); diff --git a/src/include/wisdom/dx12/dx12_command_list.cpp b/src/include/wisdom/dx12/dx12_command_list.cpp index 8e8b42ff2..239e0a4de 100644 --- a/src/include/wisdom/dx12/dx12_command_list.cpp +++ b/src/include/wisdom/dx12/dx12_command_list.cpp @@ -21,7 +21,7 @@ inline D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS* DX12Alloc if (new_size > impl.rp_memory_size) { delete[] impl.render_pass_memory; impl.render_pass_memory = new (std::nothrow) - D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS[new_size]; + D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS[new_size]; impl.rp_memory_size = impl.render_pass_memory ? new_size : 0; } return impl.render_pass_memory; @@ -84,17 +84,17 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListSetDescriptorHeaps( uint32_t heap_count = (resource_heap != 0) + (sampler_heap != 0); ID3D12DescriptorHeap* heaps[] = { resource_heap ? wis::from_handle(resource_heap)->descriptor_heap - : nullptr, + : nullptr, sampler_heap ? wis::from_handle(sampler_heap)->descriptor_heap - : nullptr, + : nullptr, }; impl.descriptor_handle = resource_heap - ? wis::from_handle(resource_heap)->gpu_handle - : D3D12_GPU_DESCRIPTOR_HANDLE{0}; + ? wis::from_handle(resource_heap)->gpu_handle + : D3D12_GPU_DESCRIPTOR_HANDLE{0}; impl.sampler_handle = sampler_heap - ? wis::from_handle(sampler_heap)->gpu_handle - : D3D12_GPU_DESCRIPTOR_HANDLE{0}; + ? wis::from_handle(sampler_heap)->gpu_handle + : D3D12_GPU_DESCRIPTOR_HANDLE{0}; if (heap_count > 0) { impl.list->SetDescriptorHeaps(heap_count, heaps + heap_offset); @@ -134,12 +134,12 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListSetPushConstants( default: case WisPipelineTypeGraphics: impl.list - ->SetGraphicsRoot32BitConstants(data->root_index, data->data_size / 4, data->data, data->push_offset / 4); + ->SetGraphicsRoot32BitConstants(data->root_index, data->data_size / 4, data->data, data->push_offset / 4); break; case WisPipelineTypeRayTracing: case WisPipelineTypeCompute: impl.list - ->SetComputeRoot32BitConstants(data->root_index, data->data_size / 4, data->data, data->push_offset / 4); + ->SetComputeRoot32BitConstants(data->root_index, data->data_size / 4, data->data, data->push_offset / 4); } } @@ -347,12 +347,12 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( render_targets[i] = { .cpuDescriptor = aux ? aux->handle : D3D12_CPU_DESCRIPTOR_HANDLE{src.target}, .BeginningAccess = - { - .Type = wis::detail::DX12Convert(src.load_op), - }, + { + .Type = wis::detail::DX12Convert(src.load_op), + }, .EndingAccess = { .Type = src.resolve_desc ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE - : wis::detail::DX12Convert(src.store_op), + : wis::detail::DX12Convert(src.store_op), }, }; if (src.load_op == WisLoadOpClear) { @@ -380,8 +380,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( // Encode the other parameters .pSubresourceParameters = static_cast< - const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>( - static_cast(dst) + const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>( + static_cast(dst) ), .Format = static_cast(dst->format), .ResolveMode = wis::detail::DX12Convert(resolve.mode), @@ -397,36 +397,36 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( bool ignore_stencil = (desc->depth_stencil.flags & WisDepthStencilFlagsIgnoreStencil); flags |= (desc->depth_stencil.flags & WisDepthStencilFlagsReadOnlyDepth) && !ignore_depth - ? D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_DEPTH - : D3D12_RENDER_PASS_FLAG_NONE; + ? D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_DEPTH + : D3D12_RENDER_PASS_FLAG_NONE; flags |= (desc->depth_stencil.flags & WisDepthStencilFlagsReadOnlyStencil) && !ignore_stencil - ? D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_STENCIL - : D3D12_RENDER_PASS_FLAG_NONE; + ? D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_STENCIL + : D3D12_RENDER_PASS_FLAG_NONE; auto& src = desc->depth_stencil; auto* aux = wis::detail::DX12DecodeViewAddress(src.target); depth_stencil = { .cpuDescriptor = aux ? aux->handle : D3D12_CPU_DESCRIPTOR_HANDLE{src.target}, .DepthBeginningAccess = - { - .Type = ignore_depth ? D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS - : wis::detail::DX12Convert(src.load_op_depth), - }, + { + .Type = ignore_depth ? D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS + : wis::detail::DX12Convert(src.load_op_depth), + }, .StencilBeginningAccess = - { - .Type = ignore_stencil ? D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS - : wis::detail::DX12Convert(src.load_op_stencil), - }, + { + .Type = ignore_stencil ? D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS + : wis::detail::DX12Convert(src.load_op_stencil), + }, .DepthEndingAccess = - { - .Type = ignore_depth ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS - : src.resolve_depth_desc ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE - : wis::detail::DX12Convert(src.store_op_depth), - }, + { + .Type = ignore_depth ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS + : src.resolve_depth_desc ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE + : wis::detail::DX12Convert(src.store_op_depth), + }, .StencilEndingAccess = { .Type = ignore_stencil ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS - : src.resolve_stencil_desc ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE - : wis::detail::DX12Convert(src.store_op_stencil), + : src.resolve_stencil_desc ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE + : wis::detail::DX12Convert(src.store_op_stencil), }, }; @@ -449,8 +449,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( // Encode the other parameters .pSubresourceParameters = static_cast< - const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>( - static_cast(dst) + const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>( + static_cast(dst) ), .Format = static_cast(dst->format), .ResolveMode = wis::detail::DX12Convert(resolve.mode), @@ -476,8 +476,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( .SubresourceCount = layer_count, // Encode the other parameters .pSubresourceParameters = static_cast< - const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>( - static_cast(dst) + const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>( + static_cast(dst) ), .Format = static_cast(dst->format), .ResolveMode = wis::detail::DX12Convert(resolve.mode), @@ -502,8 +502,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( auto& dst = render_targets[i].EndingAccess.Resolve; auto* src_aux = wis::detail::DX12DecodeViewAddress(src.target); auto* dst_aux = reinterpret_cast( - dst.pSubresourceParameters - ); + dst.pSubresourceParameters + ); wis::span subresource_params{ subresources + offset, @@ -539,8 +539,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( if (src.resolve_depth_desc) { auto& dst_depth = depth_stencil.DepthEndingAccess.Resolve; auto* dst_depth_aux = reinterpret_cast( - dst_depth.pSubresourceParameters - ); + dst_depth.pSubresourceParameters + ); wis::span subresource_params{ subresources + offset, @@ -551,7 +551,7 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( subresource_params[j] = { .SrcSubresource = aux->base_subresource + j * aux->subresource_stride, .DstSubresource = (dst_depth_aux ? dst_depth_aux->base_subresource : 0) - + j * (dst_depth_aux ? dst_depth_aux->subresource_stride : 0), + + j * (dst_depth_aux ? dst_depth_aux->subresource_stride : 0), .SrcRect = { .left = 0, .top = 0, @@ -571,8 +571,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( auto& dst_stencil = depth_stencil.StencilEndingAccess.Resolve; auto* dst_stencil_aux = reinterpret_cast( - dst_stencil.pSubresourceParameters - ); + dst_stencil.pSubresourceParameters + ); wis::span subresource_params{ subresources + offset, @@ -583,7 +583,7 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( subresource_params[j] = { .SrcSubresource = aux->base_stencil_subresource + j * aux->subresource_stride, .DstSubresource = (dst_stencil_aux ? dst_stencil_aux->base_stencil_subresource : 0) - + j * (dst_stencil_aux ? dst_stencil_aux->subresource_stride : 0), + + j * (dst_stencil_aux ? dst_stencil_aux->subresource_stride : 0), .SrcRect = { .left = 0, .top = 0, @@ -688,7 +688,7 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListCopyBufferToTexture( uint32_t plane_slice = wis::detail::DX12GetCopyPlaneSlice(region.texture_region.flags, subresource.plane_slice); uint32_t dst_subresource = subresource.mip_level + subresource.array_layer * texture_desc.MipLevels - + plane_slice * texture_desc.MipLevels * texture_desc.DepthOrArraySize; + + plane_slice * texture_desc.MipLevels * texture_desc.DepthOrArraySize; D3D12_TEXTURE_COPY_LOCATION dst_location{ .pResource = dst, .Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, @@ -755,7 +755,7 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListCopyTextureToBuffer( uint32_t plane_slice = wis::detail::DX12GetCopyPlaneSlice(region.texture_region.flags, subresource.plane_slice); uint32_t src_subresource = subresource.mip_level + subresource.array_layer * texture_desc.MipLevels - + plane_slice * texture_desc.MipLevels * texture_desc.DepthOrArraySize; + + plane_slice * texture_desc.MipLevels * texture_desc.DepthOrArraySize; D3D12_TEXTURE_COPY_LOCATION src_location{ .pResource = src, .Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, @@ -830,18 +830,18 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListCopyTexture( const auto& dst_subresource = region.dst_region.target_subresource; uint32_t src_plane_slice = wis::detail::DX12GetCopyPlaneSlice( - region.src_region.flags, - src_subresource.plane_slice - ); + region.src_region.flags, + src_subresource.plane_slice + ); uint32_t src_subresource_index = src_subresource.mip_level + src_subresource.array_layer * src_desc.MipLevels - + src_plane_slice * src_desc.MipLevels * src_desc.DepthOrArraySize; + + src_plane_slice * src_desc.MipLevels * src_desc.DepthOrArraySize; uint32_t dst_plane_slice = wis::detail::DX12GetCopyPlaneSlice( - region.dst_region.flags, - dst_subresource.plane_slice - ); + region.dst_region.flags, + dst_subresource.plane_slice + ); uint32_t dst_subresource_index = dst_subresource.mip_level + dst_subresource.array_layer * dst_desc.MipLevels - + dst_plane_slice * dst_desc.MipLevels * dst_desc.DepthOrArraySize; + + dst_plane_slice * dst_desc.MipLevels * dst_desc.DepthOrArraySize; D3D12_TEXTURE_COPY_LOCATION dst_location{ .pResource = dst, diff --git a/src/include/wisdom/dx12/dx12_descriptor_heap.cpp b/src/include/wisdom/dx12/dx12_descriptor_heap.cpp index 4d149e42d..99139c86d 100644 --- a/src/include/wisdom/dx12/dx12_descriptor_heap.cpp +++ b/src/include/wisdom/dx12/dx12_descriptor_heap.cpp @@ -37,13 +37,13 @@ inline DXGI_FORMAT DX12GetSRVFormat(const WisTextureBinding& binding) noexcept inline uint32_t DX12GetComponentMapping(WisComponentMapping mapping) noexcept { uint32_t r = mapping.r ? wis::detail::DX12Convert(mapping.r) - : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0; + : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0; uint32_t g = mapping.g ? wis::detail::DX12Convert(mapping.g) - : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1; + : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1; uint32_t b = mapping.b ? wis::detail::DX12Convert(mapping.b) - : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2; + : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2; uint32_t a = mapping.a ? wis::detail::DX12Convert(mapping.a) - : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3; + : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3; return D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(r, g, b, a); } @@ -215,7 +215,7 @@ inline void DX12FillRTVAuxData( // even though RT can be non-array, it may be a part of array uint32_t base_subresource = render_target.mip_level + mip_levels * render_target.base_array_layer - + plane_stride * plane_slice; + + plane_stride * plane_slice; switch (render_target.layout) { default: @@ -284,7 +284,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteConstantBuffer( }; heap.device->CreateConstantBufferView( &cbv_desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -314,7 +314,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteStructuredBuffer( heap.device->CreateShaderResourceView( resource, &srv_desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -344,7 +344,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteRWStructuredBuffer( resource, nullptr, &uav_desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -359,19 +359,19 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteSampler( auto& heap = wis::from_handle_ref(self); auto min_filter = !sampler->is_anisotropic ? wis::detail::DX12Convert(sampler->min_filter) - : D3D12_FILTER_TYPE_LINEAR; + : D3D12_FILTER_TYPE_LINEAR; auto mag_filter = !sampler->is_anisotropic ? wis::detail::DX12Convert(sampler->mag_filter) - : D3D12_FILTER_TYPE_LINEAR; + : D3D12_FILTER_TYPE_LINEAR; auto reduction_mode = sampler->comparison_op != WisCompareOpNone - ? D3D12_FILTER_REDUCTION_TYPE::D3D12_FILTER_REDUCTION_TYPE_COMPARISON - : wis::detail::DX12Convert(sampler->reduction_mode); + ? D3D12_FILTER_REDUCTION_TYPE::D3D12_FILTER_REDUCTION_TYPE_COMPARISON + : wis::detail::DX12Convert(sampler->reduction_mode); auto basic_filter = D3D12_ENCODE_BASIC_FILTER( - min_filter, - mag_filter, - wis::detail::DX12Convert(sampler->mip_filter), - reduction_mode - ); + min_filter, + mag_filter, + wis::detail::DX12Convert(sampler->mip_filter), + reduction_mode + ); auto filter = D3D12_FILTER(sampler->is_anisotropic * D3D12_ANISOTROPIC_FILTERING_BIT | basic_filter); constexpr static std::array border_colors[] = { @@ -395,7 +395,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteSampler( }; heap.device->CreateSampler( &sampler_desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -414,7 +414,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteTexture( heap.device->CreateShaderResourceView( resource, &desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -434,7 +434,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteRWTexture( resource, nullptr, &desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -456,7 +456,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteAccelerationStructur heap.device->CreateShaderResourceView( nullptr, &desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -473,9 +473,9 @@ WIS_EXTERN_C WISDOM_API void wisDX12DescriptorHeapCopyDescriptors( auto& heap = wis::from_handle_ref(self); heap.device->CopyDescriptorsSimple( count, - {heap.cpu_handle.ptr + static_cast(dst_index) * heap.descriptor_size}, - {std::bit_cast(src_ptr) + static_cast(src_index) * heap.descriptor_size}, - heap.type + {heap.cpu_handle.ptr + static_cast(dst_index) * heap.descriptor_size}, + {std::bit_cast(src_ptr) + static_cast(src_index) * heap.descriptor_size}, + heap.type ); } @@ -681,9 +681,9 @@ WIS_EXTERN_C WISDOM_API void wisDX12ViewHeapCopyViews( heap.device->CopyDescriptorsSimple( count, - {heap.cpu_handle.ptr + static_cast(dst_index) * heap.descriptor_size}, - {src_handle_ptr}, - heap.type + {heap.cpu_handle.ptr + static_cast(dst_index) * heap.descriptor_size}, + {src_handle_ptr}, + heap.type ); // copy aux data if present diff --git a/src/include/wisdom/dx12/dx12_device.cpp b/src/include/wisdom/dx12/dx12_device.cpp index 8a190fb0e..2b904064a 100644 --- a/src/include/wisdom/dx12/dx12_device.cpp +++ b/src/include/wisdom/dx12/dx12_device.cpp @@ -45,8 +45,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateCommandQueue( bool supported = (device.queue_priorities[type] & ~0x7fu) != 0; if (!supported) { return wis::detail::make_result< - wis::detail::Func(), - "Requested command queue type is not supported or not enabled by the device">(E_INVALIDARG); + wis::detail::Func(), + "Requested command queue type is not supported or not enabled by the device">(E_INVALIDARG); } D3D12_COMMAND_QUEUE_DESC desc{ @@ -81,10 +81,10 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateCommandAllocator( wis::com_ptr allocator; auto hr = device.device->CreateCommandAllocator( - wis::detail::DX12Convert(type), - IID_ID3D12CommandAllocator, - allocator.put_void_unchecked() - ); + wis::detail::DX12Convert(type), + IID_ID3D12CommandAllocator, + allocator.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -111,7 +111,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateFence( wis::com_ptr out_fence; auto hr = device.device - ->CreateFence(initial_value, D3D12_FENCE_FLAG_NONE, IID_ID3D12Fence, out_fence.put_void_unchecked()); + ->CreateFence(initial_value, D3D12_FENCE_FLAG_NONE, IID_ID3D12Fence, out_fence.put_void_unchecked()); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -120,8 +120,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateFence( auto event_handle = CreateEventW(nullptr, false, false, nullptr); if (!event_handle) { return wis::detail::make_result( - HRESULT_FROM_WIN32(GetLastError()) - ); + HRESULT_FROM_WIN32(GetLastError()) + ); } auto& internal = *new (fence) wis::impl::DX12FenceImpl{ @@ -167,7 +167,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateDescriptorHeap( wis::com_ptr descriptor_heap; HRESULT hr = device.device - ->CreateDescriptorHeap(&heap_desc, IID_ID3D12DescriptorHeap, descriptor_heap.put_void_unchecked()); + ->CreateDescriptorHeap(&heap_desc, IID_ID3D12DescriptorHeap, descriptor_heap.put_void_unchecked()); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -205,7 +205,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateViewHeap( wis::com_ptr descriptor_heap; HRESULT hr = device.device - ->CreateDescriptorHeap(&heap_desc, IID_ID3D12DescriptorHeap, descriptor_heap.put_void_unchecked()); + ->CreateDescriptorHeap(&heap_desc, IID_ID3D12DescriptorHeap, descriptor_heap.put_void_unchecked()); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -221,12 +221,12 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateViewHeap( && "[INTERNAL ERROR] DescriptorHandle is not aligned! Report the issue to the developers." ); - aux_data = new (std::nothrow) wis::detail::DX12RenderTargetViewAuxData[capacity]{}; + aux_data = new (std::nothrow) wis::detail::DX12RenderTargetViewAuxData[capacity] {}; if (!aux_data) { raw_heap->Release(); return wis::detail::make_result( - E_OUTOFMEMORY - ); + E_OUTOFMEMORY + ); } for (uint32_t i = 0; i < capacity; ++i) { aux_data[i].handle = {cpu_handle.ptr + static_cast(i) * descriptor_size}; @@ -262,8 +262,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( const auto& push_constant = desc->push_constants[i]; if (push_constant.size_bytes % 4 != 0) { return wis::detail::make_result( - E_INVALIDARG - ); + E_INVALIDARG + ); } push_constant_size += push_constant.size_bytes; } @@ -272,13 +272,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( // Check limits if (push_constant_size + 2 * desc->push_descriptor_count + desc->descriptor_table_count > max_root_parameters) { return wis::detail::make_result( - E_INVALIDARG - ); + E_INVALIDARG + ); } D3D12_ROOT_PARAMETER1 root_parameters[max_root_parameters]; std::size_t num_root_parameters = desc->push_constant_count + desc->push_descriptor_count - + desc->descriptor_table_count; + + desc->descriptor_table_count; wis::span root_parameters_span{root_parameters, num_root_parameters}; // Push constants @@ -287,11 +287,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( root_parameters_span[i] = { .ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS, .Constants = - { - .ShaderRegister = static_cast(src.bind_register), - .RegisterSpace = static_cast(src.bind_space), - .Num32BitValues = static_cast(src.size_bytes / 4), - }, + { + .ShaderRegister = static_cast(src.bind_register), + .RegisterSpace = static_cast(src.bind_space), + .Num32BitValues = static_cast(src.size_bytes / 4), + }, .ShaderVisibility = wis::detail::DX12Convert(src.visibility), }; } @@ -303,18 +303,18 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( if (!wis::detail::DX12IsPushable(src.type)) { return wis::detail::make_result< - wis::detail::Func(), - "Descriptor type is not pushable to DX12 root signature">(E_INVALIDARG); + wis::detail::Func(), + "Descriptor type is not pushable to DX12 root signature">(E_INVALIDARG); } root_parameters_span[i] = { .ParameterType = wis::detail::DX12RootParameterType(src.type), .Descriptor = - { - .ShaderRegister = src.bind_register, - .RegisterSpace = src.bind_space, - .Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - }, + { + .ShaderRegister = src.bind_register, + .RegisterSpace = src.bind_space, + .Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, + }, .ShaderVisibility = wis::detail::DX12Convert(src.visibility), }; } @@ -335,8 +335,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( ranges = wis::make_unique(range_count); if (!ranges) { return wis::detail::make_result( - E_OUTOFMEMORY - ); + E_OUTOFMEMORY + ); } wis::span ranges_span{ranges.get(), range_count}; @@ -352,7 +352,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( .BaseShaderRegister = src.bind_register, .RegisterSpace = src.bind_space, .Flags = src.count > 1 ? D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE - : D3D12_DESCRIPTOR_RANGE_FLAG_NONE, + : D3D12_DESCRIPTOR_RANGE_FLAG_NONE, .OffsetInDescriptorsFromTableStart = src.descriptor_offset, }; } @@ -360,10 +360,10 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( root_parameters_span[i] = { .ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, .DescriptorTable = - { - .NumDescriptorRanges = static_cast(table.entry_count), - .pDescriptorRanges = ranges.get() + range_offset, - }, + { + .NumDescriptorRanges = static_cast(table.entry_count), + .pDescriptorRanges = ranges.get() + range_offset, + }, .ShaderVisibility = wis::detail::DX12Convert(table.visibility), }; range_offset += table.entry_count; @@ -412,12 +412,12 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( wis::com_ptr root_signature; hr = device.device->CreateRootSignature( - 0, - signature->GetBufferPointer(), - signature->GetBufferSize(), - IID_ID3D12RootSignature, - root_signature.put_void_unchecked() - ); + 0, + signature->GetBufferPointer(), + signature->GetBufferSize(), + IID_ID3D12RootSignature, + root_signature.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -426,7 +426,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( XXH128_hash_t hash = XXH3_128bits(signature->GetBufferPointer(), signature->GetBufferSize()); wis::detail::DX12RootSignatureKey key{.hash{hash.low64, hash.high64}}; root_signature - ->SetPrivateData(wis::detail::DX12RootSignatureKey::guid, sizeof(wis::detail::DX12RootSignatureKey), &key); + ->SetPrivateData(wis::detail::DX12RootSignatureKey::guid, sizeof(wis::detail::DX12RootSignatureKey), &key); auto& layout_impl = *new (layout) wis::impl::DX12RootSignatureImpl{.root_signature = root_signature.detach()}; return res; @@ -453,50 +453,54 @@ WIS_EXTERN_C WISDOM_API void wisDX12DeviceQueryProperties(const WisDX12Device* s props->max_queue_priority[i] = WisCommandQueuePriority(device.queue_priorities[i] & 0x7f); } props->relaxed_queue_transition = true; - } break; + } + break; case WisQueryPropertyTypeDeviceDescriptorHeapProperties: { auto* props = static_cast(next); D3D12_FEATURE_DATA_D3D12_OPTIONS19 options19 = {}; if (wis::detail::succeeded( - device.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS19, &options19, sizeof(options19)) - )) { + device.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS19, &options19, sizeof(options19)) + )) { props->max_descriptor_heap_size = options19.MaxViewDescriptorHeapSize; props->max_sampler_heap_size = options19.MaxSamplerDescriptorHeapSize; props->max_sampler_heap_size_with_embedded = options19.MaxSamplerDescriptorHeapSizeWithStaticSamplers; props->descriptor_increment_size = device.device->GetDescriptorHandleIncrementSize( - D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV - ); + D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV + ); props->sampler_increment_size = device.device->GetDescriptorHandleIncrementSize( - D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER - ); + D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER + ); props->render_target_increment_size = device.device->GetDescriptorHandleIncrementSize( - D3D12_DESCRIPTOR_HEAP_TYPE_RTV - ); + D3D12_DESCRIPTOR_HEAP_TYPE_RTV + ); props->depth_stencil_increment_size = device.device->GetDescriptorHandleIncrementSize( - D3D12_DESCRIPTOR_HEAP_TYPE_DSV - ); + D3D12_DESCRIPTOR_HEAP_TYPE_DSV + ); props->render_target_with_ms_increment_size = sizeof(wis::detail::DX12RenderTargetViewAuxData); props->depth_stencil_with_ms_increment_size = sizeof(wis::detail::DX12RenderTargetViewAuxData); } - } break; + } + break; case WisQueryPropertyTypeDeviceMemoryProperties: { auto* props = static_cast(next); D3D12_FEATURE_DATA_D3D12_OPTIONS16 options16 = {}; if (wis::detail::succeeded( - device.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS16, &options16, sizeof(options16)) - )) { + device.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS16, &options16, sizeof(options16)) + )) { props->gpu_upload_supported = options16.GPUUploadHeapSupported; props->host_image_copy_supported = options16.GPUUploadHeapSupported; } - } break; + } + break; case WisQueryPropertyTypeDeviceBindingProperties: { auto* props = static_cast(next); props->max_vertex_input_bindings = D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; props->max_vertex_input_attributes = D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT; props->multiple_viewports_supported = true; // D3D12 supports up to 16 viewports and scissor rectangles props->address_commands_supported = true; // D3D12 supports buffer address commands - } break; + } + break; default: break; } @@ -519,17 +523,17 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceWaitForMultipleFences( HANDLE event_handle = CreateEventW(nullptr, false, false, nullptr); if (!event_handle) { return wis::detail::make_result( - HRESULT_FROM_WIN32(GetLastError()) - ); + HRESULT_FROM_WIN32(GetLastError()) + ); } auto hr = device.device->SetEventOnMultipleFenceCompletion( - reinterpret_cast(fences), - fence_values, - static_cast(fence_count), - static_cast(wait_for), - event_handle - ); + reinterpret_cast(fences), + fence_values, + static_cast(fence_count), + static_cast(wait_for), + event_handle + ); CloseHandle(event_handle); @@ -554,8 +558,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreatePipelineCache( data_copy = static_cast(malloc(data_size)); if (!data_copy) { return wis::detail::make_result( - E_OUTOFMEMORY - ); + E_OUTOFMEMORY + ); } std::memcpy(data_copy, initial_data, data_size); } @@ -563,11 +567,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreatePipelineCache( wis::com_ptr pipeline_library; auto hr = device.device->CreatePipelineLibrary( - data_copy, - data_size, - IID_ID3D12PipelineLibrary1, - pipeline_library.put_void_unchecked() - ); + data_copy, + data_size, + IID_ID3D12PipelineLibrary1, + pipeline_library.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { free(data_copy); @@ -596,12 +600,12 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateShader( auto& device = wis::from_handle_ref(self); std::unique_ptr shader_header{reinterpret_cast( - operator new(wis::aligned_size(size, 8ull) + sizeof(wis::detail::DX12ShaderHeader), std::nothrow) - )}; + operator new(wis::aligned_size(size, 8ull) + sizeof(wis::detail::DX12ShaderHeader), std::nothrow) + )}; if (!shader_header) { return wis::detail::make_result( - E_OUTOFMEMORY - ); + E_OUTOFMEMORY + ); } std::construct_at(shader_header.get()); @@ -637,14 +641,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateComputePipeline( // Validate root signature if (!rootsig) { return wis::detail::make_result< - wis::detail::Func(), - "Invalid root signature provided for compute pipeline creation">(E_INVALIDARG); + wis::detail::Func(), + "Invalid root signature provided for compute pipeline creation">(E_INVALIDARG); } // Validate shader if (!shader) { return wis::detail::make_result( - E_INVALIDARG - ); + E_INVALIDARG + ); } auto bytecode = shader->GetBytecode(); @@ -694,11 +698,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateComputePipeline( // Try to load pipeline from cache first if available HRESULT hr = cache->LoadPipeline( - name_buffer, - &pso_desc, - IID_ID3D12PipelineState, - pipeline_state.put_void_unchecked() - ); + name_buffer, + &pso_desc, + IID_ID3D12PipelineState, + pipeline_state.put_void_unchecked() + ); if (wis::detail::succeeded(hr)) { auto& pipeline_impl = *new (pipeline) wis::impl::DX12PipelineImpl{ .pipeline_state = pipeline_state.detach(), @@ -709,13 +713,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateComputePipeline( // Cache miss if (desc->flags & WisPipelineFlagsFailOnCacheMiss) { return wis::detail::make_result< - wis::detail::Func(), - "Pipeline not found in cache and creation is set to fail on cache miss">(WisStatusError, E_FAIL); + wis::detail::Func(), + "Pipeline not found in cache and creation is set to fail on cache miss">(WisStatusError, E_FAIL); } } auto hr = device.device - ->CreatePipelineState(&pso_desc, IID_ID3D12PipelineState, pipeline_state.put_void_unchecked()); + ->CreatePipelineState(&pso_desc, IID_ID3D12PipelineState, pipeline_state.put_void_unchecked()); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -743,8 +747,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( auto* rootsig = std::bit_cast(desc->root_signature); if (!rootsig) { return wis::detail::make_result< - wis::detail::Func(), - "Invalid root signature provided for graphics pipeline creation">(E_INVALIDARG); + wis::detail::Func(), + "Invalid root signature provided for graphics pipeline creation">(E_INVALIDARG); } struct GraphicsPipelineStream { @@ -771,8 +775,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( } stream{ .root_signature = rootsig, .flags = desc->flags & WisPipelineFlagsEnablePrimitiveRestart - ? D3D12_PIPELINE_STATE_FLAG_DYNAMIC_INDEX_BUFFER_STRIP_CUT - : D3D12_PIPELINE_STATE_FLAG_NONE, + ? D3D12_PIPELINE_STATE_FLAG_DYNAMIC_INDEX_BUFFER_STRIP_CUT + : D3D12_PIPELINE_STATE_FLAG_NONE, }; static constexpr size_t shader_stage_count = 5; @@ -790,7 +794,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( stream.vertex_shader = {{bytecode.data(), bytecode.size()}}; } else { return wis::detail:: - make_result(E_INVALIDARG); + make_result(E_INVALIDARG); } if (auto ps = shader_headers[1]) { auto bytecode = ps->GetBytecode(); @@ -812,7 +816,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( //--Render targets if (desc->render_attachments.attachments_count > wis::MaxRenderTargets) { return wis::detail:: - make_result(E_INVALIDARG); + make_result(E_INVALIDARG); } D3D12_RT_FORMAT_ARRAY& rtv_formats = stream.rtv_formats; @@ -825,7 +829,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( } //--Multiview - D3D12_VIEW_INSTANCE_LOCATION view_locs[wis::MaxRenderTargets]{}; + D3D12_VIEW_INSTANCE_LOCATION view_locs[wis::MaxRenderTargets] {}; if (desc->render_attachments.view_mask) { uint32_t view_mask = desc->render_attachments.view_mask; for (uint32_t i = 0u; i < wis::MaxRenderTargets; i++) { @@ -848,7 +852,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( //--Input layout wis::span slots{desc->input_layout.bindings, desc->input_layout.binding_count}; wis::span attrs{desc->input_layout.attributes, desc->input_layout.attribute_count}; - D3D12_INPUT_ELEMENT_DESC reasonable_max_input_elements[wis::MinSupportedInputAttributes * 2]{}; + D3D12_INPUT_ELEMENT_DESC reasonable_max_input_elements[wis::MinSupportedInputAttributes * 2] {}; std::unique_ptr input_elements; wis::span input_elements_span; if (!slots.empty() && !attrs.empty()) { @@ -888,16 +892,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( } stream.rasterizer = CD3DX12_RASTERIZER_DESC2{D3D12_RASTERIZER_DESC2{ - .FillMode = wis::detail::DX12Convert(raster.fill_mode), - .CullMode = wis::detail::DX12Convert(raster.cull_mode), - .FrontCounterClockwise = wis::detail::DX12Convert(raster.front_face), - .DepthBias = bias ? raster.depth_bias : 0.0f, - .DepthBiasClamp = bias ? raster.depth_bias_clamp : 0.0f, - .SlopeScaledDepthBias = bias ? raster.depth_bias_slope_factor : 0.0f, - .DepthClipEnable = raster.depth_clip_enable, - .LineRasterizationMode = wis::detail::DX12Convert(raster.line_rasterization), - .ConservativeRaster = wis::detail::DX12Convert(raster.conservative_rasterization) - }}; + .FillMode = wis::detail::DX12Convert(raster.fill_mode), + .CullMode = wis::detail::DX12Convert(raster.cull_mode), + .FrontCounterClockwise = wis::detail::DX12Convert(raster.front_face), + .DepthBias = bias ? raster.depth_bias : 0.0f, + .DepthBiasClamp = bias ? raster.depth_bias_clamp : 0.0f, + .SlopeScaledDepthBias = bias ? raster.depth_bias_slope_factor : 0.0f, + .DepthClipEnable = raster.depth_clip_enable, + .LineRasterizationMode = wis::detail::DX12Convert(raster.line_rasterization), + .ConservativeRaster = wis::detail::DX12Convert(raster.conservative_rasterization) + }}; } //--Multisample @@ -918,29 +922,30 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( if (desc->depth_stencil_desc) { auto& ds = *desc->depth_stencil_desc; stream.depth_stencil = CD3DX12_DEPTH_STENCIL_DESC2{ - {.DepthEnable = ds.depth_enable, - .DepthWriteMask = D3D12_DEPTH_WRITE_MASK(ds.depth_write_enable), - .DepthFunc = wis::detail::DX12Convert(ds.depth_comp), - .StencilEnable = ds.stencil_enable, - .FrontFace = - D3D12_DEPTH_STENCILOP_DESC1{ - .StencilFailOp = wis::detail::DX12Convert(ds.stencil_front.fail_op), - .StencilDepthFailOp = wis::detail::DX12Convert(ds.stencil_front.depth_fail_op), - .StencilPassOp = wis::detail::DX12Convert(ds.stencil_front.pass_op), - .StencilFunc = wis::detail::DX12Convert(ds.stencil_front.stencil_comp), - .StencilReadMask = ds.stencil_front.read_mask, - .StencilWriteMask = ds.stencil_front.write_mask, - }, - .BackFace = - D3D12_DEPTH_STENCILOP_DESC1{ - .StencilFailOp = wis::detail::DX12Convert(ds.stencil_back.fail_op), - .StencilDepthFailOp = wis::detail::DX12Convert(ds.stencil_back.depth_fail_op), - .StencilPassOp = wis::detail::DX12Convert(ds.stencil_back.pass_op), - .StencilFunc = wis::detail::DX12Convert(ds.stencil_back.stencil_comp), - .StencilReadMask = ds.stencil_back.read_mask, - .StencilWriteMask = ds.stencil_back.write_mask, - }, - .DepthBoundsTestEnable = ds.depth_bound_test} + { .DepthEnable = ds.depth_enable, + .DepthWriteMask = D3D12_DEPTH_WRITE_MASK(ds.depth_write_enable), + .DepthFunc = wis::detail::DX12Convert(ds.depth_comp), + .StencilEnable = ds.stencil_enable, + .FrontFace = + D3D12_DEPTH_STENCILOP_DESC1{ + .StencilFailOp = wis::detail::DX12Convert(ds.stencil_front.fail_op), + .StencilDepthFailOp = wis::detail::DX12Convert(ds.stencil_front.depth_fail_op), + .StencilPassOp = wis::detail::DX12Convert(ds.stencil_front.pass_op), + .StencilFunc = wis::detail::DX12Convert(ds.stencil_front.stencil_comp), + .StencilReadMask = ds.stencil_front.read_mask, + .StencilWriteMask = ds.stencil_front.write_mask, + }, + .BackFace = + D3D12_DEPTH_STENCILOP_DESC1{ + .StencilFailOp = wis::detail::DX12Convert(ds.stencil_back.fail_op), + .StencilDepthFailOp = wis::detail::DX12Convert(ds.stencil_back.depth_fail_op), + .StencilPassOp = wis::detail::DX12Convert(ds.stencil_back.pass_op), + .StencilFunc = wis::detail::DX12Convert(ds.stencil_back.stencil_comp), + .StencilReadMask = ds.stencil_back.read_mask, + .StencilWriteMask = ds.stencil_back.write_mask, + }, + .DepthBoundsTestEnable = ds.depth_bound_test + } }; } else { // Fix for depth stencil @@ -1056,11 +1061,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( // Try to load pipeline from cache first if available HRESULT hr = cache->LoadPipeline( - name_buffer, - &psstream_desc, - IID_ID3D12PipelineState, - pipeline_state.put_void_unchecked() - ); + name_buffer, + &psstream_desc, + IID_ID3D12PipelineState, + pipeline_state.put_void_unchecked() + ); if (wis::detail::succeeded(hr)) { auto& pipeline_impl = *new (pipeline) wis::impl::DX12PipelineImpl{ .pipeline_state = pipeline_state.detach(), @@ -1071,16 +1076,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( // Cache miss if (desc->flags & WisPipelineFlagsFailOnCacheMiss) { return wis::detail::make_result< - wis::detail::Func(), - "Pipeline not found in cache and creation is set to fail on cache miss">(WisStatusError, E_FAIL); + wis::detail::Func(), + "Pipeline not found in cache and creation is set to fail on cache miss">(WisStatusError, E_FAIL); } } HRESULT hr = device.device->CreatePipelineState( - &psstream_desc, - IID_ID3D12PipelineState, - pipeline_state.put_void_unchecked() - ); + &psstream_desc, + IID_ID3D12PipelineState, + pipeline_state.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -1127,8 +1132,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceGetSurfaceParameters( .max_swapchain_images = DXGI_MAX_SWAP_CHAIN_BUFFERS, .alpha_modes_supported = 0b0000'1111, // Support all alpha modes (premultiplied, postmultiplied, opaque, custom) .texture_usage_flags_supported = static_cast( - WisTextureUsageFlagsRenderTarget | WisTextureUsageFlagsShaderResource | WisTextureUsageFlagsCopySrc - | WisTextureUsageFlagsCopyDst | WisTextureUsageFlagsUnorderedAccess + WisTextureUsageFlagsRenderTarget | WisTextureUsageFlagsShaderResource | WisTextureUsageFlagsCopySrc + | WisTextureUsageFlagsCopyDst | WisTextureUsageFlagsUnorderedAccess ), .stereo_supported = impl.factory->IsWindowedStereoEnabled() > 0, }; @@ -1153,7 +1158,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateSwapchain( BOOL xtearing = FALSE; device.factory->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &xtearing, sizeof(xtearing)); return bool(xtearing); - }(); + } + (); DXGI_USAGE usage = 0; switch (desc->texture_usage_flags) { @@ -1190,21 +1196,21 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateSwapchain( HRESULT hr = S_OK; if (surface_impl.uwp) { hr = device.factory->CreateSwapChainForCoreWindow( - queue_impl.queue, - static_cast(surface_impl.surface), - &swap_chain_desc, - nullptr, - swap_chain1.put_unchecked() - ); + queue_impl.queue, + static_cast(surface_impl.surface), + &swap_chain_desc, + nullptr, + swap_chain1.put_unchecked() + ); } else { hr = device.factory->CreateSwapChainForHwnd( - queue_impl.queue, - static_cast(surface_impl.surface), - &swap_chain_desc, - nullptr, - nullptr, - swap_chain1.put_unchecked() - ); + queue_impl.queue, + static_cast(surface_impl.surface), + &swap_chain_desc, + nullptr, + nullptr, + swap_chain1.put_unchecked() + ); } if (!wis::detail::succeeded(hr)) { diff --git a/src/include/wisdom/dx12/dx12_impl.cpp b/src/include/wisdom/dx12/dx12_impl.cpp index 43b6cfeca..04693d45d 100644 --- a/src/include/wisdom/dx12/dx12_impl.cpp +++ b/src/include/wisdom/dx12/dx12_impl.cpp @@ -90,20 +90,20 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12TextureWriteSubresource( UINT row_pitch = 0; UINT slice_pitch = 0; auto hr = D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::CalculateMinimumRowMajorRowPitch( - desc.Format, - target_region->box.width, - row_pitch - ); + desc.Format, + target_region->box.width, + row_pitch + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } hr = D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::CalculateMinimumRowMajorSlicePitch( - desc.Format, - row_pitch, - target_region->box.height, - slice_pitch - ); + desc.Format, + row_pitch, + target_region->box.height, + slice_pitch + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -117,12 +117,12 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12TextureWriteSubresource( .back = is_3d ? target_region->box.z + target_region->box.depth : 1, }; auto subresource = D3D12CalcSubresource( - target_region->target_subresource.mip_level, - target_region->target_subresource.array_layer, - target_region->target_subresource.plane_slice, - desc.MipLevels, - is_3d ? 1 : desc.DepthOrArraySize - ); + target_region->target_subresource.mip_level, + target_region->target_subresource.array_layer, + target_region->target_subresource.plane_slice, + desc.MipLevels, + is_3d ? 1 : desc.DepthOrArraySize + ); hr = resource->WriteToSubresource(subresource, &dst_box, source_data, row_pitch, slice_pitch); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); diff --git a/src/include/wisdom/dx12/dx12_instance.cpp b/src/include/wisdom/dx12/dx12_instance.cpp index 8b456940a..32c68488b 100644 --- a/src/include/wisdom/dx12/dx12_instance.cpp +++ b/src/include/wisdom/dx12/dx12_instance.cpp @@ -30,9 +30,9 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12CreateInstance( if (debug_layer) { wis::com_ptr debug_controller; auto hr2 = D3D12GetDebugInterface( - IID_ID3D12Debug, - reinterpret_cast(debug_controller.put_void_unchecked()) - ); + IID_ID3D12Debug, + reinterpret_cast(debug_controller.put_void_unchecked()) + ); if (wis::detail::succeeded(hr2)) { debug_controller->EnableDebugLayer(); wis::com_ptr debug_layer_impl{ @@ -51,7 +51,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12CreateInstance( }; WisResult res = wis::detail::dx_success; - for (auto* ext : wis::span{extensions, extension_count}) { + for (auto* ext : wis::span {extensions, extension_count}) { if (auto* table = wis::from_handle(ext); table && table->init_fptr) { res = table->init_fptr(table, impl); if (res.status != WisStatusOk) { @@ -103,11 +103,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12InstanceQueryAdapters( // Dynamic reallocation loop while (true) { auto hr = factory_ref->EnumAdapterByGpuPreference( - static_cast(count), - wis::detail::DX12Convert(preference), - IID_IDXGIAdapter4, - reinterpret_cast(adapters.get() + count) - ); + static_cast(count), + wis::detail::DX12Convert(preference), + IID_IDXGIAdapter4, + reinterpret_cast(adapters.get() + count) + ); if (hr == DXGI_ERROR_NOT_FOUND) { break; @@ -126,8 +126,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12InstanceQueryAdapters( auto new_adapters = wis::make_unique(capacity); if (!new_adapters) { return wis::detail::make_result( - E_OUTOFMEMORY - ); + E_OUTOFMEMORY + ); } std::memmove(new_adapters.get(), adapters.get(), count * sizeof(IDXGIAdapter4*)); diff --git a/src/include/wisdom/dx12/dx12_resource_allocator.cpp b/src/include/wisdom/dx12/dx12_resource_allocator.cpp index 07f15e736..6a9f2d63d 100644 --- a/src/include/wisdom/dx12/dx12_resource_allocator.cpp +++ b/src/include/wisdom/dx12/dx12_resource_allocator.cpp @@ -21,23 +21,23 @@ inline WisResult DX12CreateResource( { if (all_desc.HeapType == D3D12_HEAP_TYPE_GPU_UPLOAD && !allocator->IsGPUUploadHeapSupported()) { return wis::detail::make_result( - E_NOTIMPL - ); + E_NOTIMPL + ); } wis::com_ptr resource; wis::com_ptr allocation; HRESULT hr = allocator->CreateResource3( - &all_desc, - &res_desc, - initial_layout, - nullptr, - static_cast(cast_formats.size()), - cast_formats.data(), - allocation.put_unchecked(), - resource.iid(), - resource.put_void_unchecked() - ); + &all_desc, + &res_desc, + initial_layout, + nullptr, + static_cast(cast_formats.size()), + cast_formats.data(), + allocation.put_unchecked(), + resource.iid(), + resource.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); @@ -131,9 +131,9 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12ResourceAllocatorCreateBuffer( { auto& [allocator, device] = wis::from_handle_ref(self); uint64_t size = wis::aligned_size( - desc->size_bytes, - static_cast(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT) - ); + desc->size_bytes, + static_cast(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT) + ); D3D12_RESOURCE_DESC1 buffer_desc{ .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, .Alignment = 0, @@ -153,13 +153,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12ResourceAllocatorCreateBuffer( .HeapType = wis::detail::DX12Convert(desc->memory_type), }; return wis::detail::DX12CreateResource( - all_desc, - buffer_desc, - D3D12_BARRIER_LAYOUT_UNDEFINED, - allocator, - {}, - buffer - ); + all_desc, + buffer_desc, + D3D12_BARRIER_LAYOUT_UNDEFINED, + allocator, + {}, + buffer + ); } //---------------------------------------------------------------------------------------------------------------------- @@ -179,13 +179,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12ResourceAllocatorCreateTexture( // planar formats are uncastable if (desc->format >= WisDataFormatNV12) { return wis::detail::DX12CreateResource( - all_desc, - tex_desc, - D3D12_BARRIER_LAYOUT_UNDEFINED, - impl.allocator, - {}, - buffer - ); + all_desc, + tex_desc, + D3D12_BARRIER_LAYOUT_UNDEFINED, + impl.allocator, + {}, + buffer + ); } static constexpr uint32_t max_cast_formats = 16; @@ -221,22 +221,22 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12ResourceAllocatorCreateTexture( if (directly_mappable) { return wis::detail::DX12CreateResource( - all_desc, - tex_desc, - D3D12_BARRIER_LAYOUT_UNDEFINED, - impl.allocator, - {reinterpret_cast(desc->cast_formats), desc->cast_format_count}, - buffer - ); + all_desc, + tex_desc, + D3D12_BARRIER_LAYOUT_UNDEFINED, + impl.allocator, + {reinterpret_cast(desc->cast_formats), desc->cast_format_count}, + buffer + ); } return wis::detail::DX12CreateResource( - all_desc, - tex_desc, - D3D12_BARRIER_LAYOUT_UNDEFINED, - impl.allocator, - cast_formats_span, - buffer - ); + all_desc, + tex_desc, + D3D12_BARRIER_LAYOUT_UNDEFINED, + impl.allocator, + cast_formats_span, + buffer + ); } #endif // WIS_DX12_RESOURCE_ALLOCATOR_CPP diff --git a/src/include/wisdom/dx12/dx12_swapchain.cpp b/src/include/wisdom/dx12/dx12_swapchain.cpp index b865487d1..5671c227b 100644 --- a/src/include/wisdom/dx12/dx12_swapchain.cpp +++ b/src/include/wisdom/dx12/dx12_swapchain.cpp @@ -50,8 +50,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12SwapchainPresent( if (hr == DXGI_ERROR_WAS_STILL_DRAWING) { return wis::detail::make_result< - wis::detail::Func(), - "Previous frame is still being presented, cannot present again yet">(WisStatusTimeout, hr); + wis::detail::Func(), + "Previous frame is still being presented, cannot present again yet">(WisStatusTimeout, hr); } if (!wis::detail::succeeded(hr)) { @@ -91,7 +91,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12SwapchainUpdate( } auto hr = swapchain.swapchain - ->ResizeBuffers(image_count, width, height, wis::detail::DX12Convert(desc->format), swapchain.flags); + ->ResizeBuffers(image_count, width, height, wis::detail::DX12Convert(desc->format), swapchain.flags); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); @@ -113,8 +113,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12SwapchainGetTextures( auto& impl = wis::from_handle_ref(self); if (buffer_count < impl.backbuffer_count) { return wis::detail::make_result< - wis::detail::Func(), - "Provided buffer count is less than the number of swapchain backbuffers">(E_INVALIDARG); + wis::detail::Func(), + "Provided buffer count is less than the number of swapchain backbuffers">(E_INVALIDARG); } for (uint32_t i = 0; i < impl.backbuffer_count; i++) { diff --git a/src/include/wisdom/generated/cpp_api.hpp b/src/include/wisdom/generated/cpp_api.hpp index ef70e6823..7951d18bf 100644 --- a/src/include/wisdom/generated/cpp_api.hpp +++ b/src/include/wisdom/generated/cpp_api.hpp @@ -2868,7 +2868,9 @@ struct DX12IndexBufferDesc { }; struct DX12TextureDeleter { - void operator()(WisDX12Texture* handle) noexcept { ::wisDX12DestroyTexture(handle); } + void operator()(WisDX12Texture* handle) noexcept { + ::wisDX12DestroyTexture(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU texture resource. @@ -2886,7 +2888,9 @@ class DX12Texture : public wis::impl::Implements(&target_region) - ); + &_impl_storage, + source_data, + reinterpret_cast(&target_region) + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } }; struct DX12BufferDeleter { - void operator()(WisDX12Buffer* handle) noexcept { ::wisDX12DestroyBuffer(handle); } + void operator()(WisDX12Buffer* handle) noexcept { + ::wisDX12DestroyBuffer(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU buffer resource. @@ -2926,13 +2932,17 @@ class DX12Buffer : public wis::impl::Implements rects) const noexcept { const WisResult wis_result = ::wisDX12SwapchainPresent( - &_impl_storage, - static_cast(flags), - reinterpret_cast(rects.data()), - rects.size() - ); + &_impl_storage, + static_cast(flags), + reinterpret_cast(rects.data()), + rects.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -2987,9 +2999,9 @@ class DX12Swapchain { std::uint32_t index{}; const WisResult wis_result = ::wisDX12SwapchainGetCurrentIndex( - &_impl_storage, - reinterpret_cast(&index) - ); + &_impl_storage, + reinterpret_cast(&index) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -3007,9 +3019,9 @@ class DX12Swapchain inline wis::Result Update(const wis::SwapchainUpdateDesc& desc) const noexcept { const WisResult wis_result = ::wisDX12SwapchainUpdate( - &_impl_storage, - reinterpret_cast(&desc) - ); + &_impl_storage, + reinterpret_cast(&desc) + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3021,16 +3033,18 @@ class DX12Swapchain inline wis::Result GetTextures(wis::span buffers) const noexcept { const WisResult wis_result = ::wisDX12SwapchainGetTextures( - &_impl_storage, - reinterpret_cast(buffers.data()), - buffers.size() - ); + &_impl_storage, + reinterpret_cast(buffers.data()), + buffers.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } }; struct DX12SurfaceDeleter { - void operator()(WisDX12Surface* handle) noexcept { ::wisDX12DestroySurface(handle); } + void operator()(WisDX12Surface* handle) noexcept { + ::wisDX12DestroySurface(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU surface, which can be used as a target for rendering and @@ -3049,11 +3063,15 @@ class DX12Surface : public wis::impl::Implements(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.0. Writes a depth stencil view to the view heap and returns the CPU descriptor @@ -3106,11 +3124,11 @@ class DX12ViewHeap ) const noexcept { return (::wisDX12ViewHeapWriteDepthStencil( - &_impl_storage, - reinterpret_cast(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.1. Writes a texture view for video decode output and returns the texture view @@ -3128,11 +3146,11 @@ class DX12ViewHeap ) const noexcept { return (::wisDX12ViewHeapWriteVideoDecodeTarget( - &_impl_storage, - reinterpret_cast(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.0. Returns the CPU descriptor handle for the view heap. @@ -3173,7 +3191,9 @@ class DX12ViewHeap }; struct DX12PipelineDeleter { - void operator()(WisDX12Pipeline* handle) noexcept { ::wisDX12DestroyPipeline(handle); } + void operator()(WisDX12Pipeline* handle) noexcept { + ::wisDX12DestroyPipeline(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU pipeline state object, which encapsulates the state of the @@ -3193,11 +3213,15 @@ class DX12Pipeline std::memcpy(&v, &_impl_storage, sizeof(v)); return v; } - WIS_NODISCARD operator DX12PipelineView() const noexcept { return GetView(); } + WIS_NODISCARD operator DX12PipelineView() const noexcept { + return GetView(); + } }; struct DX12ShaderDeleter { - void operator()(WisDX12Shader* handle) noexcept { ::wisDX12DestroyShader(handle); } + void operator()(WisDX12Shader* handle) noexcept { + ::wisDX12DestroyShader(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU shader module, which contains shader code and allows to @@ -3216,11 +3240,15 @@ class DX12Shader : public wis::impl::Implements + Implements { public: using ImplType::ImplType; @@ -3241,7 +3269,9 @@ class DX12PipelineCache std::memcpy(&v, &_impl_storage, sizeof(v)); return v; } - WIS_NODISCARD operator DX12PipelineCacheView() const noexcept { return GetView(); } + WIS_NODISCARD operator DX12PipelineCacheView() const noexcept { + return GetView(); + } /** * @brief Provided by Wisdom 0.7.0. Gets the data from the pipeline cache. * @param data points to an array that is filled with serialized cache data on success. @@ -3251,10 +3281,10 @@ class DX12PipelineCache inline wis::Result Serialize(wis::span data) const noexcept { const WisResult wis_result = ::wisDX12PipelineCacheSerialize( - &_impl_storage, - reinterpret_cast(data.data()), - data.size() - ); + &_impl_storage, + reinterpret_cast(data.data()), + data.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3269,7 +3299,9 @@ class DX12PipelineCache }; struct DX12DescriptorHeapDeleter { - void operator()(WisDX12DescriptorHeap* handle) noexcept { ::wisDX12DestroyDescriptorHeap(handle); } + void operator()(WisDX12DescriptorHeap* handle) noexcept { + ::wisDX12DestroyDescriptorHeap(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a storage for descriptors used in contiguous array. @@ -3277,7 +3309,7 @@ struct DX12DescriptorHeapDeleter { * */ class DX12DescriptorHeap : public wis::impl:: - Implements + Implements { public: using ImplType::ImplType; @@ -3303,10 +3335,10 @@ class DX12DescriptorHeap inline wis::Result WriteConstantBuffer(const wis::ConstantBufferBinding& data, std::uint32_t index) const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteConstantBuffer( - &_impl_storage, - reinterpret_cast(&data), - index - ); + &_impl_storage, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3325,11 +3357,11 @@ class DX12DescriptorHeap ) const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteStructuredBuffer( - &_impl_storage, - buffer, - reinterpret_cast(&data), - index - ); + &_impl_storage, + buffer, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3348,11 +3380,11 @@ class DX12DescriptorHeap ) const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteRWStructuredBuffer( - &_impl_storage, - buffer, - reinterpret_cast(&data), - index - ); + &_impl_storage, + buffer, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3365,10 +3397,10 @@ class DX12DescriptorHeap inline wis::Result WriteSampler(const wis::SamplerDesc& sampler, std::uint32_t index) const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteSampler( - &_impl_storage, - reinterpret_cast(&sampler), - index - ); + &_impl_storage, + reinterpret_cast(&sampler), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3386,11 +3418,11 @@ class DX12DescriptorHeap ) const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteTexture( - &_impl_storage, - texture, - reinterpret_cast(&data), - index - ); + &_impl_storage, + texture, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3408,11 +3440,11 @@ class DX12DescriptorHeap ) const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteRWTexture( - &_impl_storage, - texture, - reinterpret_cast(&data), - index - ); + &_impl_storage, + texture, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3448,7 +3480,9 @@ class DX12DescriptorHeap }; struct DX12RootSignatureDeleter { - void operator()(WisDX12RootSignature* handle) noexcept { ::wisDX12DestroyRootSignature(handle); } + void operator()(WisDX12RootSignature* handle) noexcept { + ::wisDX12DestroyRootSignature(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a pipeline layout and a constant data storage, which defines @@ -3457,7 +3491,7 @@ struct DX12RootSignatureDeleter { * */ class DX12RootSignature : public wis::impl:: - Implements + Implements { public: using ImplType::ImplType; @@ -3469,11 +3503,15 @@ class DX12RootSignature std::memcpy(&v, &_impl_storage, sizeof(v)); return v; } - WIS_NODISCARD operator DX12RootSignatureView() const noexcept { return GetView(); } + WIS_NODISCARD operator DX12RootSignatureView() const noexcept { + return GetView(); + } }; struct DX12ResourceAllocatorDeleter { - void operator()(WisDX12ResourceAllocator* handle) noexcept { ::wisDX12DestroyResourceAllocator(handle); } + void operator()(WisDX12ResourceAllocator* handle) noexcept { + ::wisDX12DestroyResourceAllocator(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class for allocating and managing GPU resources like buffers and textures. @@ -3481,7 +3519,7 @@ struct DX12ResourceAllocatorDeleter { * */ class DX12ResourceAllocator : public wis::impl:: - Implements + Implements { public: using ImplType::ImplType; @@ -3501,10 +3539,10 @@ class DX12ResourceAllocator { wis::DX12Buffer buffer{}; const WisResult wis_result = ::wisDX12ResourceAllocatorCreateBuffer( - &_impl_storage, - reinterpret_cast(&desc), - buffer.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + buffer.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -3526,10 +3564,10 @@ class DX12ResourceAllocator { wis::DX12Texture texture{}; const WisResult wis_result = ::wisDX12ResourceAllocatorCreateTexture( - &_impl_storage, - reinterpret_cast(&desc), - texture.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + texture.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -3540,7 +3578,9 @@ class DX12ResourceAllocator }; struct DX12FenceDeleter { - void operator()(WisDX12Fence* handle) noexcept { ::wisDX12DestroyFence(handle); } + void operator()(WisDX12Fence* handle) noexcept { + ::wisDX12DestroyFence(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a fence for GPU-CPU and GPU-GPU synchronization. @@ -3558,7 +3598,9 @@ class DX12Fence : public wis::impl::Implements + Implements { public: using ImplType::ImplType; @@ -4087,7 +4137,9 @@ class DX12CommandAllocator }; struct DX12CommandQueueDeleter { - void operator()(WisDX12CommandQueue* handle) noexcept { ::wisDX12DestroyCommandQueue(handle); } + void operator()(WisDX12CommandQueue* handle) noexcept { + ::wisDX12DestroyCommandQueue(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a command queue for submitting command lists to the GPU. @@ -4109,10 +4161,10 @@ class DX12CommandQueue inline wis::Result Submit(wis::span lists) const noexcept { const WisResult wis_result = ::wisDX12CommandQueueSubmit( - &_impl_storage, - reinterpret_cast(lists.data()), - lists.size() - ); + &_impl_storage, + reinterpret_cast(lists.data()), + lists.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -4144,7 +4196,9 @@ class DX12CommandQueue }; struct DX12DeviceDeleter { - void operator()(WisDX12Device* handle) noexcept { ::wisDX12DestroyDevice(handle); } + void operator()(WisDX12Device* handle) noexcept { + ::wisDX12DestroyDevice(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Central class representing logical device. @@ -4170,10 +4224,10 @@ class DX12Device : public wis::impl::Implements(type), - queue.GetStorage() - ); + &_impl_storage, + static_cast(type), + queue.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4195,10 +4249,10 @@ class DX12Device : public wis::impl::Implements(type), - allocator.GetStorage() - ); + &_impl_storage, + static_cast(type), + allocator.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4255,10 +4309,10 @@ class DX12Device : public wis::impl::Implements(&desc), - layout.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + layout.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4280,10 +4334,10 @@ class DX12Device : public wis::impl::Implements(&desc), - heap.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + heap.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4309,12 +4363,12 @@ class DX12Device : public wis::impl::Implements(type), - capacity, - static_cast(flags), - heap.GetStorage() - ); + &_impl_storage, + static_cast(type), + capacity, + static_cast(flags), + heap.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4353,13 +4407,13 @@ class DX12Device : public wis::impl::Implements(wait_for), - timeout - ); + &_impl_storage, + fences, + fence_values, + fence_count, + static_cast(wait_for), + timeout + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -4376,11 +4430,11 @@ class DX12Device : public wis::impl::Implements(initial_data.data()), - initial_data.size(), - cache.GetStorage() - ); + &_impl_storage, + reinterpret_cast(initial_data.data()), + initial_data.size(), + cache.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4402,11 +4456,11 @@ class DX12Device : public wis::impl::Implements(data.data()), - data.size(), - shader.GetStorage() - ); + &_impl_storage, + reinterpret_cast(data.data()), + data.size(), + shader.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4428,10 +4482,10 @@ class DX12Device : public wis::impl::Implements(&desc), - pipeline.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + pipeline.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4453,10 +4507,10 @@ class DX12Device : public wis::impl::Implements(&desc), - pipeline.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + pipeline.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4478,8 +4532,8 @@ class DX12Device : public wis::impl::Implements(format)) - ); + ::wisDX12DeviceGetFormatPresentationSupport(&_impl_storage, surface, static_cast(format)) + ); } /** * @brief Provided by Wisdom 0.7.0. Gets presentation parameters for the specified surface. @@ -4495,10 +4549,10 @@ class DX12Device : public wis::impl::Implements(¶ms) - ); + &_impl_storage, + surface, + reinterpret_cast(¶ms) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4525,12 +4579,12 @@ class DX12Device : public wis::impl::Implements(&surface), - reinterpret_cast(&queue), - reinterpret_cast(&desc), - swapchain.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&surface), + reinterpret_cast(&queue), + reinterpret_cast(&desc), + swapchain.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4552,10 +4606,10 @@ class DX12Device : public wis::impl::Implements(format), - reinterpret_cast(&properties) - ); + &_impl_storage, + static_cast(format), + reinterpret_cast(&properties) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4566,7 +4620,9 @@ class DX12Device : public wis::impl::Implements(&desc) - ); + &_impl_storage, + index, + reinterpret_cast(&desc) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4641,11 +4697,11 @@ class DX12AdapterQuery { wis::DX12Device device{}; const WisResult wis_result = ::wisDX12AdapterQueryCreateDevice( - &_impl_storage, - index, - reinterpret_cast(&requirements), - device.GetStorage() - ); + &_impl_storage, + index, + reinterpret_cast(&requirements), + device.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4656,7 +4712,9 @@ class DX12AdapterQuery }; struct DX12InstanceDeleter { - void operator()(WisDX12Instance* handle) noexcept { ::wisDX12DestroyInstance(handle); } + void operator()(WisDX12Instance* handle) noexcept { + ::wisDX12DestroyInstance(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class for creating adapters. @@ -4686,10 +4744,10 @@ class DX12Instance { wis::DX12AdapterQuery query{}; const WisResult wis_result = ::wisDX12InstanceQueryAdapters( - &_impl_storage, - static_cast(preference), - query.GetStorage() - ); + &_impl_storage, + static_cast(preference), + query.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4717,11 +4775,11 @@ WIS_NODISCARD inline wis::DX12Instance DX12CreateInstance( { wis::DX12Instance instance{}; const WisResult wis_result = ::wisDX12CreateInstance( - reinterpret_cast(debug_desc), - reinterpret_cast(extensions.data()), - extensions.size(), - instance.GetStorage() - ); + reinterpret_cast(debug_desc), + reinterpret_cast(extensions.data()), + extensions.size(), + instance.GetStorage() + ); out_result = wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; return instance; } @@ -4935,7 +4993,9 @@ struct VKIndexBufferDesc { }; struct VKTextureDeleter { - void operator()(WisVKTexture* handle) noexcept { ::wisVKDestroyTexture(handle); } + void operator()(WisVKTexture* handle) noexcept { + ::wisVKDestroyTexture(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU texture resource. @@ -4953,7 +5013,9 @@ class VKTexture : public wis::impl::Implements(&target_region) - ); + &_impl_storage, + source_data, + reinterpret_cast(&target_region) + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } }; struct VKBufferDeleter { - void operator()(WisVKBuffer* handle) noexcept { ::wisVKDestroyBuffer(handle); } + void operator()(WisVKBuffer* handle) noexcept { + ::wisVKDestroyBuffer(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU buffer resource. @@ -4993,13 +5057,17 @@ class VKBuffer : public wis::impl::Implements rects) const noexcept { const WisResult wis_result = ::wisVKSwapchainPresent( - &_impl_storage, - static_cast(flags), - reinterpret_cast(rects.data()), - rects.size() - ); + &_impl_storage, + static_cast(flags), + reinterpret_cast(rects.data()), + rects.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5053,9 +5123,9 @@ class VKSwapchain : public wis::impl::Implements(&index) - ); + &_impl_storage, + reinterpret_cast(&index) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -5073,9 +5143,9 @@ class VKSwapchain : public wis::impl::Implements(&desc) - ); + &_impl_storage, + reinterpret_cast(&desc) + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5087,16 +5157,18 @@ class VKSwapchain : public wis::impl::Implements buffers) const noexcept { const WisResult wis_result = ::wisVKSwapchainGetTextures( - &_impl_storage, - reinterpret_cast(buffers.data()), - buffers.size() - ); + &_impl_storage, + reinterpret_cast(buffers.data()), + buffers.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } }; struct VKSurfaceDeleter { - void operator()(WisVKSurface* handle) noexcept { ::wisVKDestroySurface(handle); } + void operator()(WisVKSurface* handle) noexcept { + ::wisVKDestroySurface(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU surface, which can be used as a target for rendering and @@ -5115,11 +5187,15 @@ class VKSurface : public wis::impl::Implements(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.0. Writes a depth stencil view to the view heap and returns the CPU descriptor @@ -5171,11 +5247,11 @@ class VKViewHeap : public wis::impl::Implements(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.1. Writes a texture view for video decode output and returns the texture view @@ -5193,11 +5269,11 @@ class VKViewHeap : public wis::impl::Implements(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.0. Returns the CPU descriptor handle for the view heap. @@ -5238,7 +5314,9 @@ class VKViewHeap : public wis::impl::Implements data) const noexcept { const WisResult wis_result = ::wisVKPipelineCacheSerialize( - &_impl_storage, - reinterpret_cast(data.data()), - data.size() - ); + &_impl_storage, + reinterpret_cast(data.data()), + data.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5332,7 +5420,9 @@ class VKPipelineCache }; struct VKDescriptorHeapDeleter { - void operator()(WisVKDescriptorHeap* handle) noexcept { ::wisVKDestroyDescriptorHeap(handle); } + void operator()(WisVKDescriptorHeap* handle) noexcept { + ::wisVKDestroyDescriptorHeap(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a storage for descriptors used in contiguous array. @@ -5365,10 +5455,10 @@ class VKDescriptorHeap inline wis::Result WriteConstantBuffer(const wis::ConstantBufferBinding& data, std::uint32_t index) const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteConstantBuffer( - &_impl_storage, - reinterpret_cast(&data), - index - ); + &_impl_storage, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5387,11 +5477,11 @@ class VKDescriptorHeap ) const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteStructuredBuffer( - &_impl_storage, - buffer, - reinterpret_cast(&data), - index - ); + &_impl_storage, + buffer, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5410,11 +5500,11 @@ class VKDescriptorHeap ) const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteRWStructuredBuffer( - &_impl_storage, - buffer, - reinterpret_cast(&data), - index - ); + &_impl_storage, + buffer, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5427,10 +5517,10 @@ class VKDescriptorHeap inline wis::Result WriteSampler(const wis::SamplerDesc& sampler, std::uint32_t index) const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteSampler( - &_impl_storage, - reinterpret_cast(&sampler), - index - ); + &_impl_storage, + reinterpret_cast(&sampler), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5448,11 +5538,11 @@ class VKDescriptorHeap ) const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteTexture( - &_impl_storage, - texture, - reinterpret_cast(&data), - index - ); + &_impl_storage, + texture, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5470,11 +5560,11 @@ class VKDescriptorHeap ) const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteRWTexture( - &_impl_storage, - texture, - reinterpret_cast(&data), - index - ); + &_impl_storage, + texture, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5510,7 +5600,9 @@ class VKDescriptorHeap }; struct VKRootSignatureDeleter { - void operator()(WisVKRootSignature* handle) noexcept { ::wisVKDestroyRootSignature(handle); } + void operator()(WisVKRootSignature* handle) noexcept { + ::wisVKDestroyRootSignature(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a pipeline layout and a constant data storage, which defines @@ -5530,11 +5622,15 @@ class VKRootSignature std::memcpy(&v, &_impl_storage, sizeof(v)); return v; } - WIS_NODISCARD operator VKRootSignatureView() const noexcept { return GetView(); } + WIS_NODISCARD operator VKRootSignatureView() const noexcept { + return GetView(); + } }; struct VKResourceAllocatorDeleter { - void operator()(WisVKResourceAllocator* handle) noexcept { ::wisVKDestroyResourceAllocator(handle); } + void operator()(WisVKResourceAllocator* handle) noexcept { + ::wisVKDestroyResourceAllocator(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class for allocating and managing GPU resources like buffers and textures. @@ -5542,7 +5638,7 @@ struct VKResourceAllocatorDeleter { * */ class VKResourceAllocator : public wis::impl:: - Implements + Implements { public: using ImplType::ImplType; @@ -5559,10 +5655,10 @@ class VKResourceAllocator { wis::VKBuffer buffer{}; const WisResult wis_result = ::wisVKResourceAllocatorCreateBuffer( - &_impl_storage, - reinterpret_cast(&desc), - buffer.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + buffer.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -5584,10 +5680,10 @@ class VKResourceAllocator { wis::VKTexture texture{}; const WisResult wis_result = ::wisVKResourceAllocatorCreateTexture( - &_impl_storage, - reinterpret_cast(&desc), - texture.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + texture.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -5598,7 +5694,9 @@ class VKResourceAllocator }; struct VKFenceDeleter { - void operator()(WisVKFence* handle) noexcept { ::wisVKDestroyFence(handle); } + void operator()(WisVKFence* handle) noexcept { + ::wisVKDestroyFence(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a fence for GPU-CPU and GPU-GPU synchronization. @@ -5616,7 +5714,9 @@ class VKFence : public wis::impl::Implements + Implements { public: using ImplType::ImplType; @@ -6142,7 +6250,9 @@ class VKCommandAllocator }; struct VKCommandQueueDeleter { - void operator()(WisVKCommandQueue* handle) noexcept { ::wisVKDestroyCommandQueue(handle); } + void operator()(WisVKCommandQueue* handle) noexcept { + ::wisVKDestroyCommandQueue(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a command queue for submitting command lists to the GPU. @@ -6164,10 +6274,10 @@ class VKCommandQueue inline wis::Result Submit(wis::span lists) const noexcept { const WisResult wis_result = ::wisVKCommandQueueSubmit( - &_impl_storage, - reinterpret_cast(lists.data()), - lists.size() - ); + &_impl_storage, + reinterpret_cast(lists.data()), + lists.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -6199,7 +6309,9 @@ class VKCommandQueue }; struct VKDeviceDeleter { - void operator()(WisVKDevice* handle) noexcept { ::wisVKDestroyDevice(handle); } + void operator()(WisVKDevice* handle) noexcept { + ::wisVKDestroyDevice(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Central class representing logical device. @@ -6225,10 +6337,10 @@ class VKDevice : public wis::impl::Implements(type), - queue.GetStorage() - ); + &_impl_storage, + static_cast(type), + queue.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6250,10 +6362,10 @@ class VKDevice : public wis::impl::Implements(type), - allocator.GetStorage() - ); + &_impl_storage, + static_cast(type), + allocator.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6310,10 +6422,10 @@ class VKDevice : public wis::impl::Implements(&desc), - layout.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + layout.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6335,10 +6447,10 @@ class VKDevice : public wis::impl::Implements(&desc), - heap.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + heap.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6364,12 +6476,12 @@ class VKDevice : public wis::impl::Implements(type), - capacity, - static_cast(flags), - heap.GetStorage() - ); + &_impl_storage, + static_cast(type), + capacity, + static_cast(flags), + heap.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6408,13 +6520,13 @@ class VKDevice : public wis::impl::Implements(wait_for), - timeout - ); + &_impl_storage, + fences, + fence_values, + fence_count, + static_cast(wait_for), + timeout + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -6431,11 +6543,11 @@ class VKDevice : public wis::impl::Implements(initial_data.data()), - initial_data.size(), - cache.GetStorage() - ); + &_impl_storage, + reinterpret_cast(initial_data.data()), + initial_data.size(), + cache.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6457,11 +6569,11 @@ class VKDevice : public wis::impl::Implements(data.data()), - data.size(), - shader.GetStorage() - ); + &_impl_storage, + reinterpret_cast(data.data()), + data.size(), + shader.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6483,10 +6595,10 @@ class VKDevice : public wis::impl::Implements(&desc), - pipeline.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + pipeline.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6508,10 +6620,10 @@ class VKDevice : public wis::impl::Implements(&desc), - pipeline.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + pipeline.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6548,10 +6660,10 @@ class VKDevice : public wis::impl::Implements(¶ms) - ); + &_impl_storage, + surface, + reinterpret_cast(¶ms) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6578,12 +6690,12 @@ class VKDevice : public wis::impl::Implements(&surface), - reinterpret_cast(&queue), - reinterpret_cast(&desc), - swapchain.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&surface), + reinterpret_cast(&queue), + reinterpret_cast(&desc), + swapchain.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6605,10 +6717,10 @@ class VKDevice : public wis::impl::Implements(format), - reinterpret_cast(&properties) - ); + &_impl_storage, + static_cast(format), + reinterpret_cast(&properties) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6619,7 +6731,9 @@ class VKDevice : public wis::impl::Implements(&desc) - ); + &_impl_storage, + index, + reinterpret_cast(&desc) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6694,11 +6808,11 @@ class VKAdapterQuery { wis::VKDevice device{}; const WisResult wis_result = ::wisVKAdapterQueryCreateDevice( - &_impl_storage, - index, - reinterpret_cast(&requirements), - device.GetStorage() - ); + &_impl_storage, + index, + reinterpret_cast(&requirements), + device.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6709,7 +6823,9 @@ class VKAdapterQuery }; struct VKInstanceDeleter { - void operator()(WisVKInstance* handle) noexcept { ::wisVKDestroyInstance(handle); } + void operator()(WisVKInstance* handle) noexcept { + ::wisVKDestroyInstance(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Class for creating adapters. @@ -6738,10 +6854,10 @@ class VKInstance : public wis::impl::Implements(preference), - query.GetStorage() - ); + &_impl_storage, + static_cast(preference), + query.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6769,11 +6885,11 @@ WIS_NODISCARD inline wis::VKInstance VKCreateInstance( { wis::VKInstance instance{}; const WisResult wis_result = ::wisVKCreateInstance( - reinterpret_cast(debug_desc), - reinterpret_cast(extensions.data()), - extensions.size(), - instance.GetStorage() - ); + reinterpret_cast(debug_desc), + reinterpret_cast(extensions.data()), + extensions.size(), + instance.GetStorage() + ); out_result = wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; return instance; } diff --git a/src/include/wisdom/generated/dx12_convert.hpp b/src/include/wisdom/generated/dx12_convert.hpp index 4465c66ac..e2095a1bc 100644 --- a/src/include/wisdom/generated/dx12_convert.hpp +++ b/src/include/wisdom/generated/dx12_convert.hpp @@ -160,7 +160,9 @@ constexpr inline DXGI_FORMAT DX12Convert(WisDataFormat value) noexcept } } -constexpr inline uint32_t DX12Convert(WisSampleCount value) noexcept { return static_cast(value); } +constexpr inline uint32_t DX12Convert(WisSampleCount value) noexcept { + return static_cast(value); +} constexpr inline DXGI_GPU_PREFERENCE DX12Convert(WisAdapterPreference value) noexcept { @@ -402,11 +404,17 @@ constexpr inline D3D12_PRIMITIVE_TOPOLOGY_TYPE DX12Convert(WisTopologyType value } } -constexpr inline D3D12_FILL_MODE DX12Convert(WisFillMode value) noexcept { return static_cast(value); } +constexpr inline D3D12_FILL_MODE DX12Convert(WisFillMode value) noexcept { + return static_cast(value); +} -constexpr inline D3D12_CULL_MODE DX12Convert(WisCullMode value) noexcept { return static_cast(value); } +constexpr inline D3D12_CULL_MODE DX12Convert(WisCullMode value) noexcept { + return static_cast(value); +} -constexpr inline BOOL DX12Convert(WisWindingOrder value) noexcept { return static_cast(value); } +constexpr inline BOOL DX12Convert(WisWindingOrder value) noexcept { + return static_cast(value); +} constexpr inline D3D12_CONSERVATIVE_RASTERIZATION_MODE DX12Convert(WisConservativeRasterization value) noexcept { @@ -418,11 +426,17 @@ constexpr inline D3D12_LINE_RASTERIZATION_MODE DX12Convert(WisLineRasterization return static_cast(value); } -constexpr inline D3D12_BLEND DX12Convert(WisBlendFactor value) noexcept { return static_cast(value); } +constexpr inline D3D12_BLEND DX12Convert(WisBlendFactor value) noexcept { + return static_cast(value); +} -constexpr inline D3D12_BLEND_OP DX12Convert(WisBlendOp value) noexcept { return static_cast(value); } +constexpr inline D3D12_BLEND_OP DX12Convert(WisBlendOp value) noexcept { + return static_cast(value); +} -constexpr inline D3D12_LOGIC_OP DX12Convert(WisLogicOp value) noexcept { return static_cast(value); } +constexpr inline D3D12_LOGIC_OP DX12Convert(WisLogicOp value) noexcept { + return static_cast(value); +} constexpr inline D3D_PRIMITIVE_TOPOLOGY DX12Convert(WisPrimitiveTopology value) noexcept { diff --git a/src/include/wisdom/generated/vk_convert.hpp b/src/include/wisdom/generated/vk_convert.hpp index 24abc9e40..8628bbd48 100644 --- a/src/include/wisdom/generated/vk_convert.hpp +++ b/src/include/wisdom/generated/vk_convert.hpp @@ -371,7 +371,7 @@ constexpr inline VkMemoryPropertyFlags VKConvert(WisMemoryType value) noexcept return VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT; case WisMemoryTypeGPUUpload: return VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT - | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; default: return static_cast(0); } @@ -855,9 +855,9 @@ constexpr inline VkPipelineStageFlags2 VKConvert(WisBarrierSync value) noexcept } if (value & WisBarrierSyncDraw) { result |= VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT | VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT - | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT - | VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT - | VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; + | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT + | VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT + | VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; } if (value & WisBarrierSyncIndexInput) { result |= VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT; @@ -885,14 +885,14 @@ constexpr inline VkPipelineStageFlags2 VKConvert(WisBarrierSync value) noexcept } if (value & WisBarrierSyncResolve) { result |= VK_PIPELINE_STAGE_2_COPY_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT - | VK_PIPELINE_STAGE_2_RESOLVE_BIT | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; + | VK_PIPELINE_STAGE_2_RESOLVE_BIT | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; } if (value & WisBarrierSyncExecuteIndirect) { result |= VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; } if (value & WisBarrierSyncAllShading) { result |= VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT - | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; + | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; } if (value & WisBarrierSyncNonPixelShading) { result |= VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; diff --git a/src/include/wisdom/global/internal.hpp b/src/include/wisdom/global/internal.hpp index c1ac2ff2b..29cca6a0a 100644 --- a/src/include/wisdom/global/internal.hpp +++ b/src/include/wisdom/global/internal.hpp @@ -78,7 +78,9 @@ struct Implements { } /// @brief Destructor, calls the Deleter on the internal implementation - ~Implements() noexcept { Deleter{}(GetStorage()); } + ~Implements() noexcept { + Deleter{}(GetStorage()); + } public: /// @brief Get the immutable internal implementation @@ -97,7 +99,9 @@ struct Implements { /// @brief Get the storage pointer /// @return Pointer to the storage - [[nodiscard]] Storage* GetStorage() noexcept { return &_impl_storage; } + [[nodiscard]] Storage* GetStorage() noexcept { + return &_impl_storage; + } /// @brief Check if the handle holds a valid object /// @return true if the first 8 bytes of storage are non-zero @@ -108,7 +112,9 @@ struct Implements { } /// @brief Bool conversion, checks handle validity - explicit operator bool() const noexcept { return IsValid(); } + explicit operator bool() const noexcept { + return IsValid(); + } public: Storage _impl_storage; diff --git a/src/include/wisdom/vulkan/detail/vk_detail.hpp b/src/include/wisdom/vulkan/detail/vk_detail.hpp index 5325bb4d1..32741f140 100644 --- a/src/include/wisdom/vulkan/detail/vk_detail.hpp +++ b/src/include/wisdom/vulkan/detail/vk_detail.hpp @@ -43,8 +43,12 @@ struct VKScopeGuard { VKScopeGuard(const VKScopeGuard&) = delete; VKScopeGuard& operator=(const VKScopeGuard&) = delete; - HandleType* PutUnchecked() noexcept { return &handle; } - HandleType Release() noexcept { return std::exchange(handle, nullptr); } + HandleType* PutUnchecked() noexcept { + return &handle; + } + HandleType Release() noexcept { + return std::exchange(handle, nullptr); + } }; template @@ -143,7 +147,7 @@ struct VKDebugCallbackThunk { // Get device handle if possible uint64_t device = 0; for (auto&& obj : - wis::span{pCallbackData->pObjects, pCallbackData->objectCount}) { + wis::span {pCallbackData->pObjects, pCallbackData->objectCount}) { if (obj.objectType == VK_OBJECT_TYPE_DEVICE) { device = obj.objectHandle; break; @@ -269,8 +273,8 @@ struct VKDeviceHeader { // Destroy semaphores auto& last_family = queue_families[family_count - 1]; std::binary_semaphore* begin = reinterpret_cast( - reinterpret_cast(this) + sizeof(*this) - ); + reinterpret_cast(this) + sizeof(*this) + ); std::binary_semaphore* end = last_family.semaphore_offset + last_family.queue_count + begin; for (std::binary_semaphore* sem = begin; sem < end; ++sem) { sem->release(); @@ -291,7 +295,7 @@ struct VKDeviceHeader { return nullptr; // No valid family index for this queue type } return reinterpret_cast(reinterpret_cast(this) + sizeof(*this)) - + queue_families[type].semaphore_offset + queue_index; + + queue_families[type].semaphore_offset + queue_index; } }; @@ -324,11 +328,11 @@ struct VKSwapchainHeader { VkSurfaceKHR surface; // store surface handle for later use in presentation and swapchain recreation VkPhysicalDevice physical_device; // store physical device for later use in swapchain recreation PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR - vkGetPhysicalDeviceSurfaceCapabilities2KHR; // store function pointer for later use in swapchain recreation + vkGetPhysicalDeviceSurfaceCapabilities2KHR; // store function pointer for later use in swapchain recreation VkSwapchainCreateInfoKHR create_info; // store create info for later use in presentation and swapchain recreation VkSwapchainPresentScalingCreateInfoKHR - scaling_create_info; // store scaling create info for later use in presentation and swapchain recreation + scaling_create_info; // store scaling create info for later use in presentation and swapchain recreation VkPresentModeKHR modes[reasonable_mode_count]; uint8_t mode_count; @@ -337,29 +341,29 @@ struct VKSwapchainHeader { wis::span GetImageAvailableSemaphores() const noexcept { - return wis::span{reinterpret_cast(this + 1), create_info.minImageCount}; + return wis::span {reinterpret_cast(this + 1), create_info.minImageCount}; } wis::span GetRenderFinishedSemaphores() const noexcept { - return wis::span{ + return wis::span { reinterpret_cast(this + 1) + create_info.minImageCount, create_info.minImageCount }; } wis::span GetSemaphores() const noexcept { - return wis::span{ + return wis::span { reinterpret_cast(this + 1), create_info.minImageCount * 2 }; } wis::span GetSupportedPresentModes() const noexcept { - return wis::span{modes, mode_count}; + return wis::span {modes, mode_count}; } wis::span GetSupportedFormats() noexcept { - return wis::span{ + return wis::span { reinterpret_cast(this + 1) + create_info.minImageCount * 2, format_count }; @@ -396,24 +400,24 @@ struct alignas(void*) VKRootSignatureControlBlock { wis::span GetRootBindingOffsets() const noexcept { - return wis::span{reinterpret_cast(this + 1), root_parameter_count}; + return wis::span {reinterpret_cast(this + 1), root_parameter_count}; } wis::span GetRootBindingOffsets() noexcept { - return wis::span{reinterpret_cast(this + 1), root_parameter_count}; + return wis::span {reinterpret_cast(this + 1), root_parameter_count}; } wis::span GetMappings() noexcept { - return wis::span{ + return wis::span { reinterpret_cast(GetRootBindingOffsets().end()), mapping_count }; } wis::span GetMappings() const noexcept { - return wis::span{ + return wis::span { reinterpret_cast(GetRootBindingOffsets().end()), mapping_count }; @@ -622,8 +626,8 @@ inline void VKReleaseSwapchain(VkSwapchainKHR swap, VKSwapchainControlBlock* hea //---------------------------------------------------------------------------------------------------------------------- // Barrier helper constants constexpr static uint32_t vk_max_barrier_size = std::max( - {sizeof(VkBufferMemoryBarrier), sizeof(VkImageMemoryBarrier2), sizeof(VkMemoryBarrier2)} -); +{sizeof(VkBufferMemoryBarrier), sizeof(VkImageMemoryBarrier2), sizeof(VkMemoryBarrier2)} + ); constexpr static uint32_t vk_static_barrier_size = WIS_TRANSIENT_MAX_BARRIER_COUNT * vk_max_barrier_size; template @@ -646,8 +650,8 @@ inline std::array, 3> VKAllocateBarriers( { std::array, 3> spans; std::size_t needed_size = barriers.buffer_barrier_count * sizeof(VkBufferMemoryBarrier2) - + barriers.texture_barrier_count * sizeof(VkImageMemoryBarrier2) - + barriers.global_barrier_count * sizeof(VkMemoryBarrier2); + + barriers.texture_barrier_count * sizeof(VkImageMemoryBarrier2) + + barriers.global_barrier_count * sizeof(VkMemoryBarrier2); if (needed_size <= vk_static_barrier_size) { spans[0] = {local_scratch, barriers.buffer_barrier_count * sizeof(VkBufferMemoryBarrier2)}; @@ -731,7 +735,7 @@ inline void VKInsertBarriers(const Impl& impl, const WisVKBarrierGroup* barriers return; } - uint8_t local_scratch[vk_static_barrier_size]{}; + uint8_t local_scratch[vk_static_barrier_size] {}; auto [buffer_span, texture_span, global_span] = VKAllocateBarriers(impl, local_scratch, *barriers); @@ -783,8 +787,8 @@ inline void VKInsertBarriers(const Impl& impl, const WisVKBarrierGroup* barriers if (src.queue_type_before != src.queue_type_after) { if (impl.maintenance9 - && (impl.queue_indices[src.queue_type_before].compatible_to_families - & (1 << impl.queue_indices[src.queue_type_after].family_index))) { + && (impl.queue_indices[src.queue_type_before].compatible_to_families + & (1 << impl.queue_indices[src.queue_type_after].family_index))) { if (src.queue_type_before == impl.queue_type) { real_texture_barrier_count--; continue; diff --git a/src/include/wisdom/vulkan/detail/vk_ext1.hpp b/src/include/wisdom/vulkan/detail/vk_ext1.hpp index 1eb64ad5c..9a937716a 100644 --- a/src/include/wisdom/vulkan/detail/vk_ext1.hpp +++ b/src/include/wisdom/vulkan/detail/vk_ext1.hpp @@ -165,34 +165,34 @@ struct DeviceExtension1 : VKDeviceExtensionImpl { if (features.descriptor_heap) { // Descriptor heap properties auto& descriptor_heap_properties = *collector.GetEnabledPropertyStruct< - VkPhysicalDeviceDescriptorHeapPropertiesEXT>( - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_HEAP_PROPERTIES_EXT - ); + VkPhysicalDeviceDescriptorHeapPropertiesEXT>( + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_HEAP_PROPERTIES_EXT + ); // A lot of space is going to be wasted, but the usage will be simpler and more efficient if we use the same // size for both resource and sampler descriptors, so we take the max of the two alignments as the // descriptor size features.resource_desc_size = static_cast(std::max( - descriptor_heap_properties.imageDescriptorAlignment, - descriptor_heap_properties.bufferDescriptorAlignment - )); + descriptor_heap_properties.imageDescriptorAlignment, + descriptor_heap_properties.bufferDescriptorAlignment + )); features.sampler_desc_size = static_cast(descriptor_heap_properties.samplerDescriptorAlignment); features.max_root_space = static_cast(descriptor_heap_properties.maxPushDataSize); features.descriptor_heap_reserved_size = wis::aligned_size( - static_cast(descriptor_heap_properties.minResourceHeapReservedRange), - features.resource_desc_size - ); + static_cast(descriptor_heap_properties.minResourceHeapReservedRange), + features.resource_desc_size + ); features.sampler_heap_reserved_size = wis::aligned_size( - static_cast(descriptor_heap_properties.minSamplerHeapReservedRange), - features.sampler_desc_size - ); + static_cast(descriptor_heap_properties.minSamplerHeapReservedRange), + features.sampler_desc_size + ); features.sampler_heap_reserved_size_with_embedded = wis::aligned_size( - static_cast(descriptor_heap_properties.minSamplerHeapReservedRangeWithEmbedded), - features.sampler_desc_size - ); + static_cast(descriptor_heap_properties.minSamplerHeapReservedRangeWithEmbedded), + features.sampler_desc_size + ); features.descriptor_heap_alignment = static_cast( - descriptor_heap_properties.resourceHeapAlignment - ); + descriptor_heap_properties.resourceHeapAlignment + ); features.sampler_heap_alignment = static_cast(descriptor_heap_properties.samplerHeapAlignment); features.max_descriptor_heap_size = descriptor_heap_properties.maxResourceHeapSize; features.max_sampler_heap_size = descriptor_heap_properties.maxSamplerHeapSize; @@ -200,11 +200,11 @@ struct DeviceExtension1 : VKDeviceExtensionImpl { // Get Device properties auto& device_properties = *collector.GetEnabledPropertyStruct( - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 - ); + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 + ); features.max_vertex_attributes = static_cast( - device_properties.properties.limits.maxVertexInputAttributes - ); + device_properties.properties.limits.maxVertexInputAttributes + ); features.max_vertex_bindings = static_cast(device_properties.properties.limits.maxVertexInputBindings); features.multiple_viewports = device_properties.properties.limits.maxViewports > 1 ? 1 : 0; diff --git a/src/include/wisdom/vulkan/vk_adapter_query.cpp b/src/include/wisdom/vulkan/vk_adapter_query.cpp index 45c1877cd..cfdb254fb 100644 --- a/src/include/wisdom/vulkan/vk_adapter_query.cpp +++ b/src/include/wisdom/vulkan/vk_adapter_query.cpp @@ -40,7 +40,7 @@ struct VKQueueResidencyInfo { //---------------------------------------------------------------------------------------------------------------------- // For simplicity, we assign the same global priority to all queues. // In a real implementation, you might want to differentiate based on queue type. -static constexpr VkDeviceQueueGlobalPriorityCreateInfo vk_global_priorities[]{ +static constexpr VkDeviceQueueGlobalPriorityCreateInfo vk_global_priorities[] { { .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO, .pNext = nullptr, @@ -159,7 +159,7 @@ inline std::array VKGetSortedQueueFamilies( } constexpr static VkQueueFlags transfer_safe_mask = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT - | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT; + | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT; // --- TRANSFER SELECTION --- // Goal: Dedicated Transfer > Compute (Async) > Graphics (Fallback). @@ -231,8 +231,8 @@ inline VKQueueResidencyInfo VKGetQueueResidencyInfo( if (queue_descs.size() > WisCommandQueueTypeCount) { out_result = wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); return info; } @@ -247,8 +247,8 @@ inline VKQueueResidencyInfo VKGetQueueResidencyInfo( // No queues available, return empty info if (!queue_descs.empty()) { out_result = wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } return info; } @@ -276,8 +276,8 @@ inline VKQueueResidencyInfo VKGetQueueResidencyInfo( if (props_span.data() == nullptr) { out_result = wis::detail::make_result< - wis::detail::Func(), - "Not enough memory for device queue family properties array">(VK_ERROR_OUT_OF_HOST_MEMORY); + wis::detail::Func(), + "Not enough memory for device queue family properties array">(VK_ERROR_OUT_OF_HOST_MEMORY); } adapter_table.vkGetPhysicalDeviceQueueFamilyProperties2(adapter, &queue_family_count, props_span.data()); @@ -289,14 +289,15 @@ inline VKQueueResidencyInfo VKGetQueueResidencyInfo( std::array pQueuePriorities; std::fill_n(pQueuePriorities.data(), pQueuePriorities.size(), 1.0f); return pQueuePriorities; - }(); + } + (); for (std::size_t i = 0; i < queue_descs.size(); ++i) { auto& desc = queue_descs[i]; if (desc.type >= WisCommandQueueTypeCount) { out_result = wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); return info; } @@ -338,7 +339,7 @@ inline VKQueueResidencyInfo VKGetQueueResidencyInfo( } info.residency[desc.type] = family_props - .queueFlags = allocated_queue_count; // Store where the family is allocated in + .queueFlags = allocated_queue_count; // Store where the family is allocated in // the residency field (abusing queueFlags // for this purpose) @@ -471,8 +472,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryGetAdapterDesc( const auto& impl = *wis::from_handle(self); if (index >= impl.adapter_count) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } const auto& atable = impl.shared_header->header.adapter_table; auto adapter = impl.physical_devices[index]; @@ -494,11 +495,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryGetAdapterDesc( // Get flags WisAdapterFlags flag{}; if ((got_desc.deviceType & VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) - == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) { + == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) { flag = static_cast(flag | WisAdapterFlags::WisAdapterFlagsRemote); } if ((got_desc.deviceType & VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_CPU) - == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_CPU) { + == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_CPU) { flag = static_cast(flag | WisAdapterFlags::WisAdapterFlagsSoftware); } @@ -508,8 +509,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryGetAdapterDesc( wis::span types{memory_props.memoryTypes}; for (auto& i : types) { if (i.propertyFlags & VkMemoryPropertyFlagBits::VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT - && memory_props.memoryHeaps[i.heapIndex].flags - & VkMemoryPropertyFlagBits::VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) { + && memory_props.memoryHeaps[i.heapIndex].flags + & VkMemoryPropertyFlagBits::VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) { dedicated_video_memory = memory_props.memoryHeaps[i.heapIndex].size; } @@ -563,11 +564,11 @@ WIS_EXTERN_C WISDOM_API bool wisVKAdapterQueryGetSurfaceSupport( if (props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { VkBool32 supported = VK_FALSE; auto vr = atable.vkGetPhysicalDeviceSurfaceSupportKHR( - impl.physical_devices[index], - i, - vk_surface, - &supported - ); + impl.physical_devices[index], + i, + vk_surface, + &supported + ); if (wis::detail::succeeded(vr) && supported == VK_TRUE) { return true; } @@ -587,8 +588,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( auto& impl = *wis::from_handle(self); if (index >= impl.adapter_count) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } auto& atable = impl.shared_header->header.adapter_table; @@ -604,7 +605,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( if (requirements) { for (size_t i = 0; i < requirements->extension_count; ++i) { if (auto* ext_header = wis::from_handle(requirements->extensions[i]); - ext_header && ext_header->init_fptr) { + ext_header && ext_header->init_fptr) { auto res2 = ext_header->init_fptr(ext_header, nullptr, &collector); // Non-fatal, allow to silently fail (void)res2; @@ -712,8 +713,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( }; if (!header_storage) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } // Start header lifetime @@ -740,11 +741,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( if (queue_family.pNext) { // Global priority info is present in the pNext chain, store it in the device header const auto* global_priority_info = reinterpret_cast( - queue_family.pNext - ); + queue_family.pNext + ); family_info.queue_priority = static_cast( - wis::detail::VKConvertGlobalPriority(global_priority_info->globalPriority) - ); + wis::detail::VKConvertGlobalPriority(global_priority_info->globalPriority) + ); } semaphore_offset += family_info.queue_count; @@ -773,31 +774,31 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( if (!device_table.Init(device_handle, gtable.vkGetDeviceProcAddr)) { device_table.vkDestroyDevice(device_handle, nullptr); // cleanup return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } // Initialize command queue table if (!header->header.command_queue_table.Init(device_handle, gtable.vkGetDeviceProcAddr)) { device_table.vkDestroyDevice(device_handle, nullptr); // cleanup return wis::detail::make_result< - wis::detail::Func(), - "Failed to initialize Vulkan command queue function table">(VK_ERROR_UNKNOWN); + wis::detail::Func(), + "Failed to initialize Vulkan command queue function table">(VK_ERROR_UNKNOWN); } // Initialize command list table if (!header->header.command_list_table.Init(device_handle, gtable.vkGetDeviceProcAddr)) { device_table.vkDestroyDevice(device_handle, nullptr); // cleanup return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } if (!header->header.swapchain_table.Init(device_handle, gtable.vkGetDeviceProcAddr)) { device_table.vkDestroyDevice(device_handle, nullptr); // cleanup return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } // Create resource allocator @@ -831,11 +832,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( // Initialize device extensions if (requirements) { for (auto* ext : - wis::span{requirements->extensions, requirements->extension_count}) { + wis::span {requirements->extensions, requirements->extension_count}) { if (auto* ext_header = wis::from_handle(ext); - ext_header && ext_header->init_fptr) { + ext_header && ext_header->init_fptr) { if (auto yres = ext_header->init_fptr(ext_header, &device_impl, &collector); - yres.status != WisStatusOk) { + yres.status != WisStatusOk) { res.status = WisStatusPartial; // mark as partial success if any extension fails res.error = yres.error; res.platform_code = yres.platform_code; diff --git a/src/include/wisdom/vulkan/vk_command_allocator.cpp b/src/include/wisdom/vulkan/vk_command_allocator.cpp index bac742b32..af6f2e153 100644 --- a/src/include/wisdom/vulkan/vk_command_allocator.cpp +++ b/src/include/wisdom/vulkan/vk_command_allocator.cpp @@ -22,10 +22,10 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCommandAllocatorReset(const WisVKCommandA auto& header = impl.command_pool_header->header; auto& device_header = header.device_header->header; auto result = device_header.device_table.vkResetCommandPool( - header.device, - impl.command_pool, - VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT - ); + header.device, + impl.command_pool, + VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT + ); if (!wis::detail::succeeded(result)) { return wis::detail::make_result(result); diff --git a/src/include/wisdom/vulkan/vk_command_list.cpp b/src/include/wisdom/vulkan/vk_command_list.cpp index 149a867c3..9b9df387e 100644 --- a/src/include/wisdom/vulkan/vk_command_list.cpp +++ b/src/include/wisdom/vulkan/vk_command_list.cpp @@ -60,9 +60,9 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetDescriptorHeaps( if (resource_heap) { auto& res_heap = wis::from_handle_ref(resource_heap); VkDeviceSize reserved_resource_descriptor_size = static_cast(res_heap.reserved_size) - * res_heap.descriptor_size; + * res_heap.descriptor_size; VkDeviceSize total_resource_heap_size = static_cast(res_heap.heap_size) * res_heap.descriptor_size - + reserved_resource_descriptor_size; + + reserved_resource_descriptor_size; VkBindHeapInfoEXT bind_resource_info{ .sType = VK_STRUCTURE_TYPE_BIND_HEAP_INFO_EXT, .pNext = nullptr, @@ -76,9 +76,9 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetDescriptorHeaps( if (sampler_heap) { auto& samp_heap = wis::from_handle_ref(sampler_heap); VkDeviceSize reserved_sampler_descriptor_size = static_cast(samp_heap.reserved_size) - * samp_heap.descriptor_size; + * samp_heap.descriptor_size; VkDeviceSize total_sampler_heap_size = static_cast(samp_heap.heap_size) * samp_heap.descriptor_size - + reserved_sampler_descriptor_size; + + reserved_sampler_descriptor_size; VkBindHeapInfoEXT bind_sampler_info{ .sType = VK_STRUCTURE_TYPE_BIND_HEAP_INFO_EXT, .pNext = nullptr, @@ -204,7 +204,7 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetViewports( }; } impl.command_list_table - ->vkCmdSetViewportWithCount(impl.command_buffer, static_cast(max_count), vk_viewports); + ->vkCmdSetViewportWithCount(impl.command_buffer, static_cast(max_count), vk_viewports); } //---------------------------------------------------------------------------------------------------------------------- @@ -240,7 +240,7 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetDepthBias( { auto& impl = wis::from_handle_ref(self); impl.command_list_table - ->vkCmdSetDepthBias(impl.command_buffer, depth_bias, depth_bias_clamp, slope_scaled_depth_bias); + ->vkCmdSetDepthBias(impl.command_buffer, depth_bias, depth_bias_clamp, slope_scaled_depth_bias); } //---------------------------------------------------------------------------------------------------------------------- @@ -428,7 +428,7 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListDrawIndexed( { auto& impl = wis::from_handle_ref(self); impl.command_list_table - ->vkCmdDrawIndexed(impl.command_buffer, index_count, instance_count, start_index, base_vertex, start_instance); + ->vkCmdDrawIndexed(impl.command_buffer, index_count, instance_count, start_index, base_vertex, start_instance); } //---------------------------------------------------------------------------------------------------------------------- @@ -469,8 +469,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyBufferToTexture( while (region_offset < region_count) { uint32_t current_region_count = static_cast( - std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) - ); + std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) + ); for (size_t i = 0; i < current_region_count; ++i) { const auto& region = regions[region_offset + i]; @@ -487,8 +487,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyBufferToTexture( } if (aspect_mask == 0) { aspect_mask = (region.texture_region.flags & WisBarrierFlagsPlanarImage) - ? (VK_IMAGE_ASPECT_PLANE_0_BIT << subresource.plane_slice) - : VK_IMAGE_ASPECT_COLOR_BIT; + ? (VK_IMAGE_ASPECT_PLANE_0_BIT << subresource.plane_slice) + : VK_IMAGE_ASPECT_COLOR_BIT; } convert_regions[i] = { @@ -496,18 +496,18 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyBufferToTexture( .bufferRowLength = region.buffer_row_length, .bufferImageHeight = region.buffer_image_height, .imageSubresource = - { - .aspectMask = aspect_mask, - .mipLevel = subresource.mip_level, - .baseArrayLayer = subresource.array_layer, - .layerCount = 1, - }, + { + .aspectMask = aspect_mask, + .mipLevel = subresource.mip_level, + .baseArrayLayer = subresource.array_layer, + .layerCount = 1, + }, .imageOffset = - { - .x = static_cast(box.x), - .y = static_cast(box.y), - .z = static_cast(box.z), - }, + { + .x = static_cast(box.x), + .y = static_cast(box.y), + .z = static_cast(box.z), + }, .imageExtent = {.width = box.width, .height = box.height, .depth = box.depth}, }; } @@ -540,8 +540,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTextureToBuffer( while (region_offset < region_count) { uint32_t current_region_count = static_cast( - std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) - ); + std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) + ); for (size_t i = 0; i < current_region_count; ++i) { const auto& region = regions[region_offset + i]; @@ -558,8 +558,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTextureToBuffer( } if (aspect_mask == 0) { aspect_mask = (region.texture_region.flags & WisBarrierFlagsPlanarImage) - ? (VK_IMAGE_ASPECT_PLANE_0_BIT << subresource.plane_slice) - : VK_IMAGE_ASPECT_COLOR_BIT; + ? (VK_IMAGE_ASPECT_PLANE_0_BIT << subresource.plane_slice) + : VK_IMAGE_ASPECT_COLOR_BIT; } convert_regions[i] = { @@ -567,18 +567,18 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTextureToBuffer( .bufferRowLength = region.buffer_row_length, .bufferImageHeight = region.buffer_image_height, .imageSubresource = - { - .aspectMask = aspect_mask, - .mipLevel = subresource.mip_level, - .baseArrayLayer = subresource.array_layer, - .layerCount = 1, - }, + { + .aspectMask = aspect_mask, + .mipLevel = subresource.mip_level, + .baseArrayLayer = subresource.array_layer, + .layerCount = 1, + }, .imageOffset = - { - .x = static_cast(box.x), - .y = static_cast(box.y), - .z = static_cast(box.z), - }, + { + .x = static_cast(box.x), + .y = static_cast(box.y), + .z = static_cast(box.z), + }, .imageExtent = {.width = box.width, .height = box.height, .depth = box.depth}, }; } @@ -611,8 +611,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTexture( while (region_offset < region_count) { uint32_t current_region_count = static_cast( - std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) - ); + std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) + ); for (size_t i = 0; i < current_region_count; ++i) { const auto& region = regions[region_offset + i]; @@ -630,8 +630,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTexture( } if (src_aspect_mask == 0) { src_aspect_mask = (region.src_region.flags & WisBarrierFlagsPlanarImage) - ? (VK_IMAGE_ASPECT_PLANE_0_BIT << src_subresource.plane_slice) - : VK_IMAGE_ASPECT_COLOR_BIT; + ? (VK_IMAGE_ASPECT_PLANE_0_BIT << src_subresource.plane_slice) + : VK_IMAGE_ASPECT_COLOR_BIT; } VkImageAspectFlags dst_aspect_mask = 0; @@ -643,37 +643,37 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTexture( } if (dst_aspect_mask == 0) { dst_aspect_mask = (region.dst_region.flags & WisBarrierFlagsPlanarImage) - ? (VK_IMAGE_ASPECT_PLANE_0_BIT << dst_subresource.plane_slice) - : VK_IMAGE_ASPECT_COLOR_BIT; + ? (VK_IMAGE_ASPECT_PLANE_0_BIT << dst_subresource.plane_slice) + : VK_IMAGE_ASPECT_COLOR_BIT; } convert_regions[i] = { .srcSubresource = - { - .aspectMask = src_aspect_mask, - .mipLevel = src_subresource.mip_level, - .baseArrayLayer = src_subresource.array_layer, - .layerCount = 1, - }, + { + .aspectMask = src_aspect_mask, + .mipLevel = src_subresource.mip_level, + .baseArrayLayer = src_subresource.array_layer, + .layerCount = 1, + }, .srcOffset = - { - .x = static_cast(src_box.x), - .y = static_cast(src_box.y), - .z = static_cast(src_box.z), - }, + { + .x = static_cast(src_box.x), + .y = static_cast(src_box.y), + .z = static_cast(src_box.z), + }, .dstSubresource = - { - .aspectMask = dst_aspect_mask, - .mipLevel = dst_subresource.mip_level, - .baseArrayLayer = dst_subresource.array_layer, - .layerCount = 1, - }, + { + .aspectMask = dst_aspect_mask, + .mipLevel = dst_subresource.mip_level, + .baseArrayLayer = dst_subresource.array_layer, + .layerCount = 1, + }, .dstOffset = - { - .x = static_cast(dst_box.x), - .y = static_cast(dst_box.y), - .z = static_cast(dst_box.z), - }, + { + .x = static_cast(dst_box.x), + .y = static_cast(dst_box.y), + .z = static_cast(dst_box.z), + }, .extent = {.width = src_box.width, .height = src_box.height, .depth = src_box.depth}, }; } @@ -717,7 +717,7 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetVertexBuffers( } impl.command_list_table - ->vkCmdBindVertexBuffers2(impl.command_buffer, start_slot, count, buffers_vk, offsets, sizes, strides); + ->vkCmdBindVertexBuffers2(impl.command_buffer, start_slot, count, buffers_vk, offsets, sizes, strides); } //---------------------------------------------------------------------------------------------------------------------- @@ -738,17 +738,17 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetVertexBuffers2( .pNext = nullptr, .setStride = VK_TRUE, .addressRange = - { - .address = buffers[i].buffer, - .size = buffers[i].size, - .stride = buffers[i].stride, - }, + { + .address = buffers[i].buffer, + .size = buffers[i].size, + .stride = buffers[i].stride, + }, .addressFlags = 0, // reserved for future use }; } impl.command_list_table - ->vkCmdBindVertexBuffers3KHR(impl.command_buffer, start_slot, count, bind_vertex_buffer_infos); + ->vkCmdBindVertexBuffers3KHR(impl.command_buffer, start_slot, count, bind_vertex_buffer_infos); } //---------------------------------------------------------------------------------------------------------------------- @@ -781,10 +781,10 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetIndexBuffer2( .sType = VK_STRUCTURE_TYPE_BIND_INDEX_BUFFER_3_INFO_KHR, .pNext = nullptr, .addressRange = - { - .address = buffer->buffer, - .size = buffer->size, - }, + { + .address = buffer->buffer, + .size = buffer->size, + }, .addressFlags = 0, // reserved for future use .indexType = wis::detail::VKConvert(index_type), }; diff --git a/src/include/wisdom/vulkan/vk_descriptor_heap.cpp b/src/include/wisdom/vulkan/vk_descriptor_heap.cpp index fbcb5f35e..bbb49b38d 100644 --- a/src/include/wisdom/vulkan/vk_descriptor_heap.cpp +++ b/src/include/wisdom/vulkan/vk_descriptor_heap.cpp @@ -12,12 +12,12 @@ namespace wis::detail { inline VkImageAspectFlags VKGetAspectFlags(const WisTextureBinding& binding) noexcept { if ((binding.flags & WisTextureBindingFlagsStencilView) - && (binding.format == WisDataFormatD24UnormS8Uint || binding.format == WisDataFormatD32FloatS8Uint)) { + && (binding.format == WisDataFormatD24UnormS8Uint || binding.format == WisDataFormatD32FloatS8Uint)) { return VK_IMAGE_ASPECT_STENCIL_BIT; } if ((binding.flags & WisTextureBindingFlagsDepthView) && (binding.format == WisDataFormatD32FloatS8Uint || binding.format == WisDataFormatD24UnormS8Uint) - || (binding.format == WisDataFormatD16Unorm || binding.format == WisDataFormatD32Float)) { + || (binding.format == WisDataFormatD16Unorm || binding.format == WisDataFormatD32Float)) { return VK_IMAGE_ASPECT_DEPTH_BIT; } if (binding.range.plane_slice) { @@ -97,7 +97,7 @@ inline VkImageViewCreateInfo VKGetSRVDesc(const WisTextureBinding& binding) noex case WisTextureLayoutTexture2DMS: srv_desc.viewType = VK_IMAGE_VIEW_TYPE_2D; srv_desc.subresourceRange = - {.aspectMask = aspect_flags, .baseMipLevel = 0, .levelCount = 1, .baseArrayLayer = 0, .layerCount = 1}; + {.aspectMask = aspect_flags, .baseMipLevel = 0, .levelCount = 1, .baseArrayLayer = 0, .layerCount = 1}; break; case WisTextureLayoutTexture2DMSArray: srv_desc.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; @@ -342,7 +342,7 @@ WIS_EXTERN_C WISDOM_API void wisVKDestroyViewHeap(WisVKViewHeap* self) for (uint32_t i = 0; i < impl.capacity; ++i) { if (impl.view_heap[i].view != VK_NULL_HANDLE) { impl.device_header->header.device_table - .vkDestroyImageView(impl.device_header->header.device, impl.view_heap[i].view, nullptr); + .vkDestroyImageView(impl.device_header->header.device, impl.view_heap[i].view, nullptr); } } @@ -387,7 +387,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteConstantBuffer( VkResult result = table.vkWriteResourceDescriptorsEXT(heap.device, 1, &resource_desc, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } @@ -429,7 +429,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteStructuredBuffer( VkResult result = table.vkWriteResourceDescriptorsEXT(heap.device, 1, &resource_desc, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } @@ -466,7 +466,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteSampler( .sType = VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO, .pNext = nullptr, // Custom border? .reductionMode = sampler->comparison_op != WisCompareOpNever ? VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE - : wis::detail::VKConvert(sampler->reduction_mode) + : wis::detail::VKConvert(sampler->reduction_mode) }; VkSamplerCreateInfo sampler_info{ .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, @@ -491,7 +491,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteSampler( VkResult result = table.vkWriteSamplerDescriptorsEXT(heap.device, 1, &sampler_info, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } @@ -536,7 +536,7 @@ WISDOM_API WisResult wisVKDescriptorHeapWriteTexture( VkResult result = table.vkWriteResourceDescriptorsEXT(heap.device, 1, &resource_desc, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } @@ -575,7 +575,7 @@ WISDOM_API WisResult wisVKDescriptorHeapWriteRWTexture( VkResult result = table.vkWriteResourceDescriptorsEXT(heap.device, 1, &resource_desc, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } @@ -607,7 +607,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteAccelerationStructure( VkResult result = table.vkWriteResourceDescriptorsEXT(heap.device, 1, &resource_desc, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } @@ -693,13 +693,13 @@ WIS_EXTERN_C WISDOM_API void wisVKViewHeapCopyViews( return; // Invalid range, do nothing } auto* src_views = reinterpret_cast(std::bit_cast(src_ptr)) - + src_index; + + src_index; auto* dst_views = heap.view_heap + dst_index; for (uint32_t i = 0; i < count; ++i) { // Destroy existing view at destination if it's not null if (dst_views[i].view != VK_NULL_HANDLE) { heap.device_header->header.device_table - .vkDestroyImageView(heap.device_header->header.device, dst_views[i].view, nullptr); + .vkDestroyImageView(heap.device_header->header.device, dst_views[i].view, nullptr); } dst_views[i] = src_views[i]; } diff --git a/src/include/wisdom/vulkan/vk_device.cpp b/src/include/wisdom/vulkan/vk_device.cpp index ca4649442..bddf2d1c2 100644 --- a/src/include/wisdom/vulkan/vk_device.cpp +++ b/src/include/wisdom/vulkan/vk_device.cpp @@ -29,7 +29,7 @@ constexpr VkSpirvResourceTypeFlagsEXT GetResourceTypeFlags(const WisDescriptorTy return VK_SPIRV_RESOURCE_TYPE_READ_WRITE_STORAGE_BUFFER_BIT_EXT; case WisDescriptorTypeBuffer: return VK_SPIRV_RESOURCE_TYPE_READ_WRITE_STORAGE_BUFFER_BIT_EXT - | VK_SPIRV_RESOURCE_TYPE_READ_ONLY_STORAGE_BUFFER_BIT_EXT; + | VK_SPIRV_RESOURCE_TYPE_READ_ONLY_STORAGE_BUFFER_BIT_EXT; case WisDescriptorTypeAccelerationStructure: return VK_SPIRV_RESOURCE_TYPE_ACCELERATION_STRUCTURE_BIT_EXT; default: @@ -132,16 +132,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateCommandQueue( using QueueTypeUnderlying = std::underlying_type_t; if (static_cast(type) < 0 || static_cast(type) >= WisCommandQueueTypeCount) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } // Get queue family index based on type uint8_t queue_family_index = device.device_header->header.queue_residency[static_cast(type)]; if (queue_family_index == wis::detail::VKQueueFamilyProperties::invalid_family_index) { return wis::detail::make_result< - wis::detail::Func(), - "No suitable queue family found for the requested queue type">(VK_ERROR_FEATURE_NOT_PRESENT); + wis::detail::Func(), + "No suitable queue family found for the requested queue type">(VK_ERROR_FEATURE_NOT_PRESENT); } auto& queue_family = device.device_header->header.queue_families[queue_family_index]; @@ -183,24 +183,24 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateCommandAllocator( using QueueTypeUnderlying = std::underlying_type_t; if (static_cast(type) < 0 || static_cast(type) >= WisCommandQueueTypeCount) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } // Get queue family index based on type uint8_t queue_family_index = device.device_header->header.queue_residency[static_cast(type)]; if (queue_family_index == wis::detail::VKQueueFamilyProperties::invalid_family_index) { return wis::detail::make_result< - wis::detail::Func(), - "No suitable queue family found for the requested queue type">(VK_ERROR_FEATURE_NOT_PRESENT); + wis::detail::Func(), + "No suitable queue family found for the requested queue type">(VK_ERROR_FEATURE_NOT_PRESENT); } std::unique_ptr - pool_control_block = wis::make_unique(); + pool_control_block = wis::make_unique(); if (!pool_control_block) { return wis::detail::make_result< - wis::detail::Func(), - "Failed to allocate memory for command pool control block">(VK_ERROR_OUT_OF_HOST_MEMORY); + wis::detail::Func(), + "Failed to allocate memory for command pool control block">(VK_ERROR_OUT_OF_HOST_MEMORY); } uint8_t queue_family = device.device_header->header.queue_families[queue_family_index].family_index; @@ -301,8 +301,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( // 0. If heap is supported if (!features.descriptor_heap) { return wis::detail::make_result< - wis::detail::Func(), - "Descriptor heaps are not supported by this Vulkan device">(VK_ERROR_FEATURE_NOT_PRESENT); + wis::detail::Func(), + "Descriptor heaps are not supported by this Vulkan device">(VK_ERROR_FEATURE_NOT_PRESENT); } // 1. Calculate descriptor memory requirements based on desc @@ -311,32 +311,32 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( bool embedded_samplers = !(desc->flags & WisDescriptorHeapFlagsDisallowEmbeddedSamplers); std::size_t heap_alignment = is_shader_heap ? is_sampler_heap ? features.sampler_heap_alignment - : features.descriptor_heap_alignment - : __STDCPP_DEFAULT_NEW_ALIGNMENT__; + : features.descriptor_heap_alignment + : __STDCPP_DEFAULT_NEW_ALIGNMENT__; std::size_t descriptor_size = is_sampler_heap ? features.sampler_desc_size : features.resource_desc_size; std::size_t reserved_size = is_shader_heap ? is_sampler_heap ? embedded_samplers - ? features.sampler_heap_reserved_size_with_embedded - : features.sampler_heap_reserved_size - : features.descriptor_heap_reserved_size - : 0; + ? features.sampler_heap_reserved_size_with_embedded + : features.sampler_heap_reserved_size + : features.descriptor_heap_reserved_size + : 0; std::size_t max_heap_size = is_shader_heap - ? is_sampler_heap ? features.max_sampler_heap_size : features.max_descriptor_heap_size - : std::numeric_limits::max(); + ? is_sampler_heap ? features.max_sampler_heap_size : features.max_descriptor_heap_size + : std::numeric_limits::max(); std::size_t required_size = wis::aligned_size( - desc->descriptor_count * descriptor_size + reserved_size, - heap_alignment - ); + desc->descriptor_count * descriptor_size + reserved_size, + heap_alignment + ); if (is_shader_heap && required_size > max_heap_size) { return wis::detail::make_result< - wis::detail::Func(), - "Requested descriptor heap size exceeds the maximum supported by this Vulkan device">( - VK_ERROR_INITIALIZATION_FAILED - ); + wis::detail::Func(), + "Requested descriptor heap size exceeds the maximum supported by this Vulkan device">( + VK_ERROR_INITIALIZATION_FAILED + ); } if (!is_shader_heap) { @@ -344,8 +344,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( VkBuffer buffer = reinterpret_cast(std::malloc(required_size)); if (!buffer) { return wis::detail::make_result< - wis::detail::Func(), - "Failed to allocate memory for non-shader visible descriptor heap">(VK_ERROR_OUT_OF_HOST_MEMORY); + wis::detail::Func(), + "Failed to allocate memory for non-shader visible descriptor heap">(VK_ERROR_OUT_OF_HOST_MEMORY); } // Fill descriptor heap impl @@ -375,7 +375,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( }; VmaAllocationCreateInfo alloc_info{ .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT - | VMA_ALLOCATION_CREATE_MAPPED_BIT, + | VMA_ALLOCATION_CREATE_MAPPED_BIT, .usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE, .requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, .preferredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, @@ -385,18 +385,18 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( VmaAllocation allocation = VK_NULL_HANDLE; VmaAllocationInfo alloc_info_out{}; VkResult vr = vmaCreateBufferWithAlignment( - header.allocator, - &buffer_info, - &alloc_info, - heap_alignment, - &buffer, - &allocation, - &alloc_info_out - ); + header.allocator, + &buffer_info, + &alloc_info, + heap_alignment, + &buffer, + &allocation, + &alloc_info_out + ); if (!wis::detail::succeeded(vr)) { return wis::detail:: - make_result(vr); + make_result(vr); } // Get GPU address of the buffer @@ -432,11 +432,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateViewHeap( { (void)flags; auto& device = *wis::from_handle(self); - wis::detail::VKRenderTargetView* view_heap = new (std::nothrow) wis::detail::VKRenderTargetView[capacity]{}; + wis::detail::VKRenderTargetView* view_heap = new (std::nothrow) wis::detail::VKRenderTargetView[capacity] {}; if (!view_heap) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } new (heap) wis::impl::VKViewHeapImpl{ @@ -461,8 +461,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( if (!features.descriptor_heap) { return wis::detail::make_result< - wis::detail::Func(), - "Descriptor heaps are not supported by this Vulkan device">(VK_ERROR_FEATURE_NOT_PRESENT); + wis::detail::Func(), + "Descriptor heaps are not supported by this Vulkan device">(VK_ERROR_FEATURE_NOT_PRESENT); } // Use only 64 DWORDs, same as DX12 @@ -472,8 +472,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( const auto& push_constant = desc->push_constants[i]; if (push_constant.size_bytes % 4 != 0) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } push_constant_size += push_constant.size_bytes; } @@ -481,36 +481,36 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( // 1. Count the number of root parameters needed std::size_t total_dwords_needed = push_constant_size + desc->push_descriptor_count * 2 - + desc->descriptor_table_count; + + desc->descriptor_table_count; if (total_dwords_needed > max_root_parameters) { return wis::detail::make_result< - wis::detail::Func(), - "Root signature requires more than 64 DWORDs, which is not supported by this implementation">( - VK_ERROR_INITIALIZATION_FAILED - ); + wis::detail::Func(), + "Root signature requires more than 64 DWORDs, which is not supported by this implementation">( + VK_ERROR_INITIALIZATION_FAILED + ); } // 2. Count the number of VkDescriptorSetAndBindingMappingEXT structures // Hard part is to pack the tables into a contiguous arrays for each shader type uint32_t total_table_count = 0; std::array table_counts_per_shader = wis::detail::GetMapCountPerShaderType( - *desc - ); - std::array - local_offsets_per_shader = wis::detail::GetMappingOffsetPerShaderType( - table_counts_per_shader, - total_table_count + *desc ); + std::array + local_offsets_per_shader = wis::detail::GetMappingOffsetPerShaderType( + table_counts_per_shader, + total_table_count + ); std::size_t root_param_count = desc->push_constant_count + desc->push_descriptor_count - + desc->descriptor_table_count; + + desc->descriptor_table_count; std::size_t static_sampler_count = 0; // allocate root signature table std::size_t root_sig_size = sizeof(wis::detail::VKRootSignatureControlBlock) - + wis::aligned_size(root_param_count, 2u) * sizeof(uint32_t) - + // Root parameter binding indices, aligned to 8 bytes + + wis::aligned_size(root_param_count, 2u) * sizeof(uint32_t) + + // Root parameter binding indices, aligned to 8 bytes total_table_count * sizeof(VkDescriptorSetAndBindingMappingEXT); std::unique_ptr root_sig_control_block{ @@ -532,17 +532,17 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( } rootsig_header->shader_mapping_offset[i] = local_offsets_per_shader[i].offset - - (local_offsets_per_shader[i].even - ? 0 - : table_counts_per_shader[0]); // If even, "all" maps are after + - (local_offsets_per_shader[i].even + ? 0 + : table_counts_per_shader[0]); // If even, "all" maps are after // this stage, if odd, "all" maps // are before this stage rootsig_header - ->shader_mapping_sizes[i] = table_counts_per_shader[i] - + (local_offsets_per_shader[i].even - ? 0 - : table_counts_per_shader[0]); // If even, this stage maps + "all" + ->shader_mapping_sizes[i] = table_counts_per_shader[i] + + (local_offsets_per_shader[i].even + ? 0 + : table_counts_per_shader[0]); // If even, this stage maps + "all" // maps, if odd, only this stage maps if (!all_offset) { @@ -608,16 +608,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( uint32_t local_count = entry.count; uint32_t local_offset = heap_byte_offset; uint32_t heap_stride = entry.type == WisDescriptorTypeSampler ? features.sampler_desc_size - : features.resource_desc_size; + : features.resource_desc_size; // Check for unbounded array if (entry.count == std::numeric_limits::max()) { if (j != src.entry_count - 1) { return wis::detail::make_result< - wis::detail::Func(), - "Unbounded array descriptor table entry must be the last entry in the table">( - VK_ERROR_INITIALIZATION_FAILED - ); + wis::detail::Func(), + "Unbounded array descriptor table entry must be the last entry in the table">( + VK_ERROR_INITIALIZATION_FAILED + ); } local_count = 1; } @@ -698,14 +698,15 @@ WIS_EXTERN_C WISDOM_API void wisVKDeviceQueryProperties(const WisVKDevice* self, auto& family_index = header.queue_residency[i]; bool supported = family_index != wis::detail::VKQueueFamilyProperties::invalid_family_index; WisCommandQueuePriority priority = WisCommandQueuePriority( - supported ? (header.queue_families[family_index].queue_priority) : 0 - ); + supported ? (header.queue_families[family_index].queue_priority) : 0 + ); props->supported_queues[i] = supported; props->max_queue_priority[i] = priority; } props->relaxed_queue_transition = header.features.maintenance9; - } break; + } + break; case WisQueryPropertyTypeDeviceDescriptorHeapProperties: { auto* props = static_cast(next); if (!header.features.descriptor_heap) { @@ -713,20 +714,21 @@ WIS_EXTERN_C WISDOM_API void wisVKDeviceQueryProperties(const WisVKDevice* self, } auto real_dheap_size = header.features.max_descriptor_heap_size - - header.features.descriptor_heap_reserved_size; + - header.features.descriptor_heap_reserved_size; auto real_sheap_size = header.features.max_sampler_heap_size - header.features.sampler_heap_reserved_size; auto real_sheap_size_with_embedded = header.features.max_sampler_heap_size - - header.features.sampler_heap_reserved_size_with_embedded; + - header.features.sampler_heap_reserved_size_with_embedded; props->max_descriptor_heap_size = real_dheap_size / header.features.resource_desc_size; props->max_sampler_heap_size = real_sheap_size / header.features.sampler_desc_size; props->max_sampler_heap_size_with_embedded = real_sheap_size_with_embedded - / header.features.sampler_desc_size; + / header.features.sampler_desc_size; props->descriptor_increment_size = header.features.resource_desc_size; props->sampler_increment_size = header.features.sampler_desc_size; props->render_target_increment_size = sizeof(wis::detail::VKRenderTargetView); props->depth_stencil_increment_size = sizeof(wis::detail::VKRenderTargetView); - } break; + } + break; case WisQueryPropertyTypeDeviceMemoryProperties: { auto* props = static_cast(next); props->host_image_copy_supported = header.features.host_image_copy; @@ -757,20 +759,22 @@ WIS_EXTERN_C WISDOM_API void wisVKDeviceQueryProperties(const WisVKDevice* self, const VkMemoryPropertyFlags flags = mem_props->memoryTypes[i].propertyFlags; if ((flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) && (flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) - && (flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) { + && (flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) { props->gpu_upload_supported = true; break; } } - } break; + } + break; case WisQueryPropertyTypeDeviceBindingProperties: { auto* props = static_cast(next); props->max_vertex_input_bindings = header.features.max_vertex_bindings; props->max_vertex_input_attributes = header.features.max_vertex_attributes; props->multiple_viewports_supported = header.features.multiple_viewports; props->address_commands_supported = header.features.address_commands; - } break; + } + break; default: break; } @@ -814,8 +818,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreatePipelineCache( { if (data_size > 0 && data_size < sizeof(VkPipelineCacheHeaderVersionOne)) { return wis::detail::make_result< - wis::detail::Func(), - "Data size is too small to contain a valid pipeline cache header">(VK_ERROR_INITIALIZATION_FAILED); + wis::detail::Func(), + "Data size is too small to contain a valid pipeline cache header">(VK_ERROR_INITIALIZATION_FAILED); } auto& device = *wis::from_handle(self); @@ -842,9 +846,9 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreatePipelineCache( if (std::memcmp(initial_data, &cache_header_correct, sizeof(VkPipelineCacheHeaderVersionOne)) != 0) { return wis::detail::make_result< - wis::detail::Func(), - "Initial data pipeline cache header does not match the device's pipeline cache header, indicating it " - "is incompatible">(VK_ERROR_INITIALIZATION_FAILED); + wis::detail::Func(), + "Initial data pipeline cache header does not match the device's pipeline cache header, indicating it " + "is incompatible">(VK_ERROR_INITIALIZATION_FAILED); } } @@ -863,7 +867,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreatePipelineCache( } auto& cache_impl = *new (cache) - wis::impl::VKPipelineCacheImpl{.cache = cache_handle, .device_header = device.device_header}; + wis::impl::VKPipelineCacheImpl{.cache = cache_handle, .device_header = device.device_header}; device.device_header->AddRef(); return wis::detail::vk_success; @@ -895,8 +899,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateShader( } auto& shader_impl = *new ( - shader - ) wis::impl::VKShaderImpl{.shader_module = shader_handle, .device_header = device.device_header}; + shader + ) wis::impl::VKShaderImpl{.shader_module = shader_handle, .device_header = device.device_header}; device.device_header->AddRef(); return wis::detail::vk_success; } @@ -936,13 +940,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateComputePipeline( .pNext = &pipeline_flags_info, .flags = 0, .stage = - {.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, - .pNext = &mapping, - .flags = 0, - .stage = VK_SHADER_STAGE_COMPUTE_BIT, - .module = shader, - .pName = "main", - .pSpecializationInfo = nullptr}, + { .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, + .pNext = &mapping, + .flags = 0, + .stage = VK_SHADER_STAGE_COMPUTE_BIT, + .module = shader, + .pName = "main", + .pSpecializationInfo = nullptr + }, .layout = nullptr }; @@ -954,8 +959,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateComputePipeline( } auto& pipeline_impl = *new ( - pipeline - ) wis::impl::VKPipelineImpl{.pipeline = pipeline_handle, .device_header = device.device_header}; + pipeline + ) wis::impl::VKPipelineImpl{.pipeline = pipeline_handle, .device_header = device.device_header}; pipeline_impl.device_header->AddRef(); return wis::detail::vk_success; } @@ -974,8 +979,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( if (!rsig) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } //--Shader stages @@ -997,7 +1002,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( }; VkShaderDescriptorSetAndBindingMappingInfoEXT mappings[max_shader_stages]; VkPipelineShaderStageCreateInfo - shader_stages[max_shader_stages]; // intentionally uninitialized, will be filled based on provided shaders + shader_stages[max_shader_stages]; // intentionally uninitialized, will be filled based on provided shaders for (uint32_t i = 0; i < max_shader_stages; i++) { auto smodule = shader_modules[i]; @@ -1048,12 +1053,12 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( uint32_t ia_count = desc->input_layout.attribute_count; if (desc->input_layout.attribute_count > wis::MinSupportedInputAttributes * 2) { dynamic_vertex_attributes = wis::make_unique( - desc->input_layout.attribute_count - ); + desc->input_layout.attribute_count + ); if (!dynamic_vertex_attributes) { return wis::detail::make_result< - wis::detail::Func(), - "Failed to allocate memory for vertex input attribute descriptions">(VK_ERROR_OUT_OF_HOST_MEMORY); + wis::detail::Func(), + "Failed to allocate memory for vertex input attribute descriptions">(VK_ERROR_OUT_OF_HOST_MEMORY); } ia_span = {dynamic_vertex_attributes.get(), ia_count}; @@ -1077,11 +1082,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( .flags = 0, .vertexBindingDescriptionCount = static_cast(desc->input_layout.binding_count), .pVertexBindingDescriptions = desc->input_layout.binding_count - ? reinterpret_cast( - desc->input_layout.bindings - ) // strict aliasing violation, but we control the data and it's guaranteed - // to be compatible - : nullptr, + ? reinterpret_cast( + desc->input_layout.bindings + ) // strict aliasing violation, but we control the data and it's guaranteed + // to be compatible + : nullptr, .vertexAttributeDescriptionCount = static_cast(desc->input_layout.attribute_count), .pVertexAttributeDescriptions = desc->input_layout.attribute_count ? ia_span.data() : nullptr, }; @@ -1173,8 +1178,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( uint32_t rt_count = desc->render_attachments.attachments_count; if (rt_count > wis::MaxRenderTargets) { return wis::detail::make_result< - wis::detail::Func(), - "Exceeded maximum number of render target attachments (8)">(VK_ERROR_UNKNOWN); + wis::detail::Func(), + "Exceeded maximum number of render target attachments (8)">(VK_ERROR_UNKNOWN); } VkFormat rt_formats[wis::MaxRenderTargets]; for (uint32_t i = 0; i < rt_count; i++) { @@ -1242,25 +1247,25 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( .depthBoundsTestEnable = ds.depth_bound_test, .stencilTestEnable = ds.stencil_enable, .front = - VkStencilOpState{ - .failOp = wis::detail::VKConvert(ds.stencil_front.fail_op), - .passOp = wis::detail::VKConvert(ds.stencil_front.pass_op), - .depthFailOp = wis::detail::VKConvert(ds.stencil_front.depth_fail_op), - .compareOp = wis::detail::VKConvert(ds.stencil_front.stencil_comp), - .compareMask = ds.stencil_front.read_mask, - .writeMask = ds.stencil_front.write_mask, - .reference = 0, - }, + VkStencilOpState{ + .failOp = wis::detail::VKConvert(ds.stencil_front.fail_op), + .passOp = wis::detail::VKConvert(ds.stencil_front.pass_op), + .depthFailOp = wis::detail::VKConvert(ds.stencil_front.depth_fail_op), + .compareOp = wis::detail::VKConvert(ds.stencil_front.stencil_comp), + .compareMask = ds.stencil_front.read_mask, + .writeMask = ds.stencil_front.write_mask, + .reference = 0, + }, .back = - VkStencilOpState{ - .failOp = wis::detail::VKConvert(ds.stencil_back.fail_op), - .passOp = wis::detail::VKConvert(ds.stencil_back.pass_op), - .depthFailOp = wis::detail::VKConvert(ds.stencil_back.depth_fail_op), - .compareOp = wis::detail::VKConvert(ds.stencil_back.stencil_comp), - .compareMask = ds.stencil_back.read_mask, - .writeMask = ds.stencil_back.write_mask, - .reference = 0, - }, + VkStencilOpState{ + .failOp = wis::detail::VKConvert(ds.stencil_back.fail_op), + .passOp = wis::detail::VKConvert(ds.stencil_back.pass_op), + .depthFailOp = wis::detail::VKConvert(ds.stencil_back.depth_fail_op), + .compareOp = wis::detail::VKConvert(ds.stencil_back.stencil_comp), + .compareMask = ds.stencil_back.read_mask, + .writeMask = ds.stencil_back.write_mask, + .reference = 0, + }, .minDepthBounds = 0.0f, .maxDepthBounds = 1.0f, }; @@ -1276,7 +1281,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( .dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO, .alphaBlendOp = VK_BLEND_OP_ADD, .colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT - | VK_COLOR_COMPONENT_A_BIT, + | VK_COLOR_COMPONENT_A_BIT, }; VkPipelineColorBlendAttachmentState color_blend_attachment[wis::MaxRenderTargets]; VkPipelineColorBlendStateCreateInfo color_blending; @@ -1399,21 +1404,21 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( VkPipeline pipeline_handle = VK_NULL_HANDLE; auto vr = table.vkCreateGraphicsPipelines( - device.device, - std::bit_cast(desc->cache), - 1u, - &info, - nullptr, - &pipeline_handle - ); + device.device, + std::bit_cast(desc->cache), + 1u, + &info, + nullptr, + &pipeline_handle + ); if (!wis::detail::succeeded(vr)) { return wis::detail::make_result(vr); } auto& pipeline_impl = *new ( - pipeline - ) wis::impl::VKPipelineImpl{.pipeline = pipeline_handle, .device_header = device.device_header}; + pipeline + ) wis::impl::VKPipelineImpl{.pipeline = pipeline_handle, .device_header = device.device_header}; device.device_header->AddRef(); return wis::detail::vk_success; @@ -1453,8 +1458,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetSurfaceParameters( *params = { .min_swapchain_images = capabilities.surfaceCapabilities.minImageCount, .max_swapchain_images = capabilities.surfaceCapabilities.maxImageCount == 0 - ? wis::AbsoluteMaxSwapchainImages - : capabilities.surfaceCapabilities.maxImageCount, + ? wis::AbsoluteMaxSwapchainImages + : capabilities.surfaceCapabilities.maxImageCount, .alpha_modes_supported = alpha, .texture_usage_flags_supported = wis::detail::VKConvert(capabilities.surfaceCapabilities.supportedUsageFlags), .stereo_supported = capabilities.surfaceCapabilities.maxImageArrayLayers > 1, @@ -1496,11 +1501,11 @@ WIS_EXTERN_C WISDOM_API bool wisVKDeviceGetFormatPresentationSupport( } vr = atable.vkGetPhysicalDeviceSurfaceFormatsKHR( - device.physical_device, - vk_surface, - &format_count, - format_span.data() - ); + device.physical_device, + vk_surface, + &format_count, + format_span.data() + ); if (!wis::detail::succeeded(vr)) { return false; } @@ -1537,15 +1542,15 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( uint32_t format_count = 0; auto vr = atable.vkGetPhysicalDeviceSurfaceFormatsKHR( - device.physical_device, - surface_impl.surface, - &format_count, - nullptr - ); + device.physical_device, + surface_impl.surface, + &format_count, + nullptr + ); if (!wis::detail::succeeded(vr) || format_count == 0) { return wis::detail::make_result< - wis::detail::Func(), - "Failed to get surface formats or no formats supported by the surface">(VK_ERROR_INITIALIZATION_FAILED); + wis::detail::Func(), + "Failed to get surface formats or no formats supported by the surface">(VK_ERROR_INITIALIZATION_FAILED); } if (format_count > reasonable_format_count) { @@ -1560,11 +1565,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( } vr = atable.vkGetPhysicalDeviceSurfaceFormatsKHR( - device.physical_device, - surface_impl.surface, - &format_count, - format_span.data() - ); + device.physical_device, + surface_impl.surface, + &format_count, + format_span.data() + ); if (!wis::detail::succeeded(vr)) { return wis::detail::make_result(vr); } @@ -1576,10 +1581,10 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( if (format_it == format_span.end()) { return wis::detail::make_result< - wis::detail::Func(), - "The requested format is not supported for presentation on the given surface">( - VK_ERROR_FORMAT_NOT_SUPPORTED - ); + wis::detail::Func(), + "The requested format is not supported for presentation on the given surface">( + VK_ERROR_FORMAT_NOT_SUPPORTED + ); } // Query surface props @@ -1597,19 +1602,19 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( // validate requested parameters against capabilities if (desc->image_count < capabilities.surfaceCapabilities.minImageCount - || (capabilities.surfaceCapabilities.maxImageCount != 0 - && desc->image_count > capabilities.surfaceCapabilities.maxImageCount)) { + || (capabilities.surfaceCapabilities.maxImageCount != 0 + && desc->image_count > capabilities.surfaceCapabilities.maxImageCount)) { return wis::detail::make_result< - wis::detail::Func(), - "Requested swapchain image count is out of bounds for the given surface">(VK_ERROR_INITIALIZATION_FAILED); + wis::detail::Func(), + "Requested swapchain image count is out of bounds for the given surface">(VK_ERROR_INITIALIZATION_FAILED); } if (desc->flags & WisSwapchainFlagsStereo) { if (capabilities.surfaceCapabilities.maxImageArrayLayers == 1) { return wis::detail::make_result< - wis::detail::Func(), - "Stereo swapchain requested but the surface does not support image array layers">( - VK_ERROR_INITIALIZATION_FAILED - ); + wis::detail::Func(), + "Stereo swapchain requested but the surface does not support image array layers">( + VK_ERROR_INITIALIZATION_FAILED + ); } array_layer_count++; } @@ -1650,14 +1655,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( // Create swapchain control block in a single allocation with the header to ensure they are close together in // memory, which is important for cache performance since the header is accessed on every frame. std::size_t header_size = sizeof(wis::detail::VKSwapchainControlBlock) + desc->image_count * sizeof(VkSemaphore) * 2 - + // semaphores for present and render complete for each image + + // semaphores for present and render complete for each image format_count - * sizeof(VkSurfaceFormatKHR); // store supported formats for use in mode switching + * sizeof(VkSurfaceFormatKHR); // store supported formats for use in mode switching std::unique_ptr header_storage{new (std::nothrow) std::byte[header_size]}; if (!header_storage) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } wis::detail::VKSwapchainControlBlock* header = new (header_storage.get()) wis::detail::VKSwapchainControlBlock; @@ -1672,8 +1677,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( // Copy the supported formats for use in mode switching auto* format_storage = reinterpret_cast( - reinterpret_cast(header + 1) + desc->image_count * 2 - ); // format storage is immediately after the semaphores + reinterpret_cast(header + 1) + desc->image_count * 2 + ); // format storage is immediately after the semaphores for (uint32_t i = 0; i < format_count; i++) { format_storage[i] = format_span[i]; } @@ -1700,18 +1705,18 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( .imageFormat = vk_format, .imageColorSpace = format_it->colorSpace, .imageExtent = - { - .width = std::clamp( - desc->width, - capabilities.surfaceCapabilities.minImageExtent.width, - capabilities.surfaceCapabilities.maxImageExtent.width - ), - .height = std::clamp( - desc->height, - capabilities.surfaceCapabilities.minImageExtent.height, - capabilities.surfaceCapabilities.maxImageExtent.height - ), - }, + { + .width = std::clamp( + desc->width, + capabilities.surfaceCapabilities.minImageExtent.width, + capabilities.surfaceCapabilities.maxImageExtent.width + ), + .height = std::clamp( + desc->height, + capabilities.surfaceCapabilities.minImageExtent.height, + capabilities.surfaceCapabilities.maxImageExtent.height + ), + }, .imageArrayLayers = array_layer_count, .imageUsage = wis::detail::VKConvert(desc->texture_usage_flags), .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE, @@ -1751,7 +1756,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( } stable.vkDestroySwapchainKHR(device.device, swapchain_handle, nullptr); return wis::detail:: - make_result(vr); + make_result(vr); } } @@ -1769,7 +1774,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( } stable.vkDestroySwapchainKHR(device.device, swapchain_handle, nullptr); return wis::detail:: - make_result(vr); + make_result(vr); } swap_head.surface_header = surface_impl.surface_header; @@ -1795,13 +1800,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( // Acquire the next image index for the new swapchain to update internal state auto result = impl.swapchain_table->vkAcquireNextImageKHR( - impl.device, - impl.swapchain, - impl.lazy_acquire ? 0 : std::numeric_limits::max(), - semaphores[impl.acquire_index], - nullptr, - &impl.present_index - ); + impl.device, + impl.swapchain, + impl.lazy_acquire ? 0 : std::numeric_limits::max(), + semaphores[impl.acquire_index], + nullptr, + &impl.present_index + ); if (result != VK_SUCCESS) { return result; // Caller can choose to handle timeout differently (e.g. by skipping rendering and trying @@ -1826,7 +1831,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( }; impl.acquire_index = (impl.acquire_index + 1) % swapchain_header.create_info.minImageCount; return swapchain_table.vkQueueSubmit2(impl.present_queue, 1, &desc2, nullptr); - }(swap_impl); + } + (swap_impl); if (!wis::detail::succeeded(vr)) { for (uint32_t j = 0; j < desc->image_count * 2; j++) { @@ -1841,7 +1847,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( ); // ensure the destructor doesn't attempt to clean up a partially initialized swapchain return wis::detail:: - make_result(vr); + make_result(vr); } return wis::detail::vk_success; @@ -1874,8 +1880,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetFormatProperties( if (features & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) { support_flags |= WisFormatSupportFlagsShaderResource | WisFormatSupportFlagsTexture1D - | WisFormatSupportFlagsTexture2D | WisFormatSupportFlagsTexture3D - | WisFormatSupportFlagsTextureCube; + | WisFormatSupportFlagsTexture2D | WisFormatSupportFlagsTexture3D + | WisFormatSupportFlagsTextureCube; } if (features & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) { support_flags |= WisFormatSupportFlagsRenderTarget; @@ -1894,42 +1900,42 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetFormatProperties( if (features & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) { VkImageFormatProperties image_props{}; if (wis::detail::succeeded(atable.vkGetPhysicalDeviceImageFormatProperties( - device.physical_device, - vk_format, - VK_IMAGE_TYPE_2D, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_SAMPLED_BIT, - 0, - &image_props - ))) { + device.physical_device, + vk_format, + VK_IMAGE_TYPE_2D, + VK_IMAGE_TILING_OPTIMAL, + VK_IMAGE_USAGE_SAMPLED_BIT, + 0, + &image_props + ))) { sample_counts |= image_props.sampleCounts; } } if (features & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) { VkImageFormatProperties image_props{}; if (wis::detail::succeeded(atable.vkGetPhysicalDeviceImageFormatProperties( - device.physical_device, - vk_format, - VK_IMAGE_TYPE_2D, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, - 0, - &image_props - ))) { + device.physical_device, + vk_format, + VK_IMAGE_TYPE_2D, + VK_IMAGE_TILING_OPTIMAL, + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, + 0, + &image_props + ))) { sample_counts |= image_props.sampleCounts; } } if (features & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { VkImageFormatProperties image_props{}; if (wis::detail::succeeded(atable.vkGetPhysicalDeviceImageFormatProperties( - device.physical_device, - vk_format, - VK_IMAGE_TYPE_2D, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, - 0, - &image_props - ))) { + device.physical_device, + vk_format, + VK_IMAGE_TYPE_2D, + VK_IMAGE_TILING_OPTIMAL, + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, + 0, + &image_props + ))) { sample_counts |= image_props.sampleCounts; } } @@ -1947,7 +1953,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetFormatProperties( if (max_sample_count > WisSampleCountS1) { if (features & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT - || features & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { + || features & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { support_flags |= WisFormatSupportFlagsMultisampleRenderTarget; } support_flags |= WisFormatSupportFlagsMultisampleResolve; diff --git a/src/include/wisdom/vulkan/vk_extensions.cpp b/src/include/wisdom/vulkan/vk_extensions.cpp index 804636661..ef1e81310 100644 --- a/src/include/wisdom/vulkan/vk_extensions.cpp +++ b/src/include/wisdom/vulkan/vk_extensions.cpp @@ -16,14 +16,14 @@ GetInstanceExtensions(WisResult& result, const wis::impl::VKMainGlobal& table) n VkResult vr = table.vkEnumerateInstanceExtensionProperties(nullptr, &ext_count, nullptr); if (!wis::detail::succeeded(vr)) { result = wis::detail:: - make_result(vr); + make_result(vr); return exts; } std::unique_ptr ext_props_raw = make_unique(ext_count); if (!ext_props_raw) { result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return exts; } vr = table.vkEnumerateInstanceExtensionProperties(nullptr, &ext_count, ext_props_raw.get()); @@ -33,8 +33,8 @@ GetInstanceExtensions(WisResult& result, const wis::impl::VKMainGlobal& table) n exts.reserve(ext_count); } catch (const std::bad_alloc&) { result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return exts; } for (const auto& i : wis::span{ext_props_raw.get(), ext_count}) { @@ -58,15 +58,15 @@ inline std::unordered_set( - vr - ); + vr + ); return layers; } std::unique_ptr layer_props_raw = make_unique(layer_count); if (!layer_props_raw) { result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return layers; } vr = table.vkEnumerateInstanceLayerProperties(&layer_count, layer_props_raw.get()); @@ -75,8 +75,8 @@ inline std::unordered_set( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return layers; } for (const auto& i : wis::span{layer_props_raw.get(), layer_count}) { @@ -99,14 +99,14 @@ GetDeviceExtensions( VkResult vr = adapter_table.vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &ext_count, nullptr); if (!wis::detail::succeeded(vr)) { result = wis::detail:: - make_result(vr); + make_result(vr); return exts; } std::unique_ptr ext_props_raw = make_unique(ext_count); if (!ext_props_raw) { result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return exts; } vr = adapter_table.vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &ext_count, ext_props_raw.get()); @@ -115,8 +115,8 @@ GetDeviceExtensions( exts.reserve(ext_count); } catch (const std::bad_alloc&) { result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return exts; } for (const auto& i : wis::span{ext_props_raw.get(), ext_count}) { @@ -142,8 +142,8 @@ wis::VKInstanceExtensionCollector::VKInstanceExtensionCollector( enabled_layer_names_set.reserve(wis::detail::size(available_layers_set)); } catch (const std::bad_alloc&) { out_result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return; } for (const auto& ext : instance_extensions) { @@ -163,8 +163,8 @@ wis::VKInstanceExtensionCollector::ExtReturn wis::VKInstanceExtensionCollector:: auto names_array = make_unique(ext_count + layer_count); if (!names_array) { out_res = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return result; } std::size_t index = 0; @@ -213,8 +213,8 @@ wis::VKDeviceExtensionCollector::VKDeviceExtensionCollector( enabled_extension_names_set.reserve(wis::detail::size(available_extensions_set)); } catch (const std::bad_alloc&) { res = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return; } res = wis::detail::vk_success; @@ -275,8 +275,8 @@ wis::VKDeviceExtensionCollector::InitBuffer wis::VKDeviceExtensionCollector::Get std::unique_ptr buffer(new (std::nothrow) std::uint64_t[total_size / sizeof(std::uint64_t)]); if (!buffer) { out_res = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return result; } diff --git a/src/include/wisdom/vulkan/vk_extensions.hpp b/src/include/wisdom/vulkan/vk_extensions.hpp index 563d29c2e..f2a70839d 100644 --- a/src/include/wisdom/vulkan/vk_extensions.hpp +++ b/src/include/wisdom/vulkan/vk_extensions.hpp @@ -39,21 +39,31 @@ struct CStringHash { // hash for VkExtensionProperties struct VkExtensionPropertiesHash { using is_transparent = void; - std::size_t operator()(const VkExtensionProperties& ext) const noexcept { return CStringHash{}(ext.extensionName); } - std::size_t operator()(const char* name) const noexcept { return CStringHash{}(name); } + std::size_t operator()(const VkExtensionProperties& ext) const noexcept { + return CStringHash{}(ext.extensionName); + } + std::size_t operator()(const char* name) const noexcept { + return CStringHash{}(name); + } }; //---------------------------------------------------------------------------------------------------------------------- struct VkLayerPropertiesHash { using is_transparent = void; - std::size_t operator()(const VkLayerProperties& layer) const noexcept { return CStringHash{}(layer.layerName); } - std::size_t operator()(const char* name) const noexcept { return CStringHash{}(name); } + std::size_t operator()(const VkLayerProperties& layer) const noexcept { + return CStringHash{}(layer.layerName); + } + std::size_t operator()(const char* name) const noexcept { + return CStringHash{}(name); + } }; // Equality helpers //---------------------------------------------------------------------------------------------------------------------- struct CStringEqual { - bool operator()(const char* a, const char* b) const { return std::strncmp(a, b, VK_MAX_EXTENSION_NAME_SIZE) == 0; } + bool operator()(const char* a, const char* b) const { + return std::strncmp(a, b, VK_MAX_EXTENSION_NAME_SIZE) == 0; + } }; //---------------------------------------------------------------------------------------------------------------------- @@ -92,13 +102,13 @@ struct VkLayerPropertiesEqual { using CStringSet = std::unordered_set; using VkExtensionPropertiesSet = std:: - unordered_set; + unordered_set; using VkLayerPropertiesSet = std::unordered_set; } // namespace detail //---------------------------------------------------------------------------------------------------------------------- struct WISDOM_API VKInstanceExtensionCollector { - constexpr static const char* instance_extensions[]{ + constexpr static const char* instance_extensions[] { VK_KHR_SURFACE_EXTENSION_NAME, VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME, VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, @@ -226,7 +236,9 @@ struct WISDOM_API VKDeviceExtensionCollector { template struct VKInstanceExtensionImpl : public VKInstanceExtensionHeader { VKInstanceExtensionImpl() noexcept - : VKInstanceExtensionHeader{&VKInstanceExtensionImpl::InitThunk} + : VKInstanceExtensionHeader { + &VKInstanceExtensionImpl::InitThunk + } { assert( std::uintptr_t(static_cast(this)) == std::uintptr_t(static_cast(this)) @@ -245,9 +257,9 @@ struct VKInstanceExtensionImpl : public VKInstanceExtensionHeader { return reinterpret_cast(self)->CollectInfo(*collector); } return reinterpret_cast(self)->Init( - const_cast(*instance_impl), - const_cast(*collector) - ); + const_cast(*instance_impl), + const_cast(*collector) + ); } public: @@ -267,7 +279,9 @@ struct VKInstanceExtensionImpl : public VKInstanceExtensionHeader { template struct VKDeviceExtensionImpl : public VKDeviceExtensionHeader { VKDeviceExtensionImpl() noexcept - : VKDeviceExtensionHeader{&VKDeviceExtensionImpl::InitThunk} + : VKDeviceExtensionHeader { + &VKDeviceExtensionImpl::InitThunk + } { assert( std::uintptr_t(static_cast(this)) == std::uintptr_t(static_cast(this)) @@ -286,9 +300,9 @@ struct VKDeviceExtensionImpl : public VKDeviceExtensionHeader { return reinterpret_cast(self)->CollectInfo(*collector); } return reinterpret_cast(self)->Init( - const_cast(*device_impl), - const_cast(*collector) - ); + const_cast(*device_impl), + const_cast(*collector) + ); } public: diff --git a/src/include/wisdom/vulkan/vk_impl.cpp b/src/include/wisdom/vulkan/vk_impl.cpp index 02d259158..9ed1118d0 100644 --- a/src/include/wisdom/vulkan/vk_impl.cpp +++ b/src/include/wisdom/vulkan/vk_impl.cpp @@ -106,14 +106,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKTextureWriteSubresource( .memoryRowLength = 0, .memoryImageHeight = 0, .imageSubresource = - {.aspectMask = plane_to_aspect_mask(target_region->target_subresource.plane_slice), - .mipLevel = target_region->target_subresource.mip_level, - .baseArrayLayer = target_region->target_subresource.array_layer, - .layerCount = 1}, + { .aspectMask = plane_to_aspect_mask(target_region->target_subresource.plane_slice), + .mipLevel = target_region->target_subresource.mip_level, + .baseArrayLayer = target_region->target_subresource.array_layer, + .layerCount = 1 + }, .imageOffset = - {static_cast(target_region->box.x), - static_cast(target_region->box.y), - static_cast(target_region->box.z)}, + { static_cast(target_region->box.x), + static_cast(target_region->box.y), + static_cast(target_region->box.z) + }, .imageExtent{target_region->box.width, target_region->box.height, target_region->box.depth}, }; diff --git a/src/include/wisdom/vulkan/vk_instance.cpp b/src/include/wisdom/vulkan/vk_instance.cpp index 47c1c4951..37bcfb27a 100644 --- a/src/include/wisdom/vulkan/vk_instance.cpp +++ b/src/include/wisdom/vulkan/vk_instance.cpp @@ -66,8 +66,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCreateInstance( auto header = wis::make_unique(); if (!header) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } header->header.library = wis::detail::unique_library{wis::detail::InitializeVulkanLibrary()}; @@ -77,8 +77,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCreateInstance( if (!header->header.global_table.Init(header->header.library.get())) { return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } const auto& gt = header->header.global_table; @@ -152,11 +152,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCreateInstance( .pNext = nullptr, .flags = 0, .messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, + | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT + | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT + | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, .messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, + | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, .pfnUserCallback = wis::detail::VKDebugCallbackThunk::DebugUtilsMessengerCallbackThunk, .pUserData = debug_layer_thunk.get(), }; @@ -182,26 +182,26 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCreateInstance( if (!instance_table.Init(instance_handle, gt.vkGetInstanceProcAddr)) { instance_table.vkDestroyInstance(instance_handle, nullptr); // cleanup return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } // Initialize adapter table if (!header->header.adapter_table.Init(instance_handle, gt.vkGetInstanceProcAddr)) { instance_table.vkDestroyInstance(instance_handle, nullptr); // cleanup return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } // Setup debug messenger if requested if (debug_layer_thunk && instance_table.vkCreateDebugUtilsMessengerEXT) { auto vr2 = instance_table.vkCreateDebugUtilsMessengerEXT( - instance_handle, - &debug_create_info, - nullptr, - &header->header.debug_messenger - ); + instance_handle, + &debug_create_info, + nullptr, + &header->header.debug_messenger + ); // Non-fatal, allow to silently fail (void)vr2; } @@ -218,7 +218,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCreateInstance( }; // Initialize instance extensions - for (auto* ext : wis::span{extensions, extension_count}) { + for (auto* ext : wis::span {extensions, extension_count}) { if (auto* table = wis::from_handle(ext); table && table->init_fptr) { if (auto xres = table->init_fptr(table, &impl, &collector); xres.status != WisStatusOk) { res.status = WisStatusPartial; // mark as partial success if any extension fails @@ -269,16 +269,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKInstanceQueryAdapters( } if (device_count == 0) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } // Get physical devices devices_ref = wis::make_unique(device_count); if (!devices_ref) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } vr = table.vkEnumeratePhysicalDevices(instance_impl.instance, &device_count, devices_ref.get()); @@ -300,13 +300,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKInstanceQueryAdapters( // Sort devices based on preference constexpr static std::size_t max_align = std::max(alignof(VkPhysicalDeviceProperties), alignof(std::uintptr_t)); std::size_t total_aux_size = sizeof(VkPhysicalDeviceProperties) * device_count - + device_count * sizeof(std::uintptr_t); + + device_count * sizeof(std::uintptr_t); aux_pool = wis::make_unique(total_aux_size + max_align - 1); if (!aux_pool) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } // Aligned pointers @@ -351,10 +351,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKInstanceQueryAdapters( // Sort indices based on preference switch (preference) { case WisAdapterPreference::WisAdapterPreferenceMinConsumption: - std::ranges::sort(index_span, [&](std::uintptr_t a, std::uintptr_t b) { return less_consumption(a, b); }); + std::ranges::sort(index_span, [&](std::uintptr_t a, std::uintptr_t b) { + return less_consumption(a, b); + }); break; case WisAdapterPreference::WisAdapterPreferencePerformance: - std::ranges::sort(index_span, [&](std::uintptr_t a, std::uintptr_t b) { return less_performance(a, b); }); + std::ranges::sort(index_span, [&](std::uintptr_t a, std::uintptr_t b) { + return less_performance(a, b); + }); break; default: // No sorting diff --git a/src/include/wisdom/vulkan/vk_pipeline_cache.cpp b/src/include/wisdom/vulkan/vk_pipeline_cache.cpp index 1366545a2..7d2ef84ff 100644 --- a/src/include/wisdom/vulkan/vk_pipeline_cache.cpp +++ b/src/include/wisdom/vulkan/vk_pipeline_cache.cpp @@ -46,9 +46,9 @@ WIS_EXTERN_C WISDOM_API size_t wisVKPipelineCacheGetSerializedSize(const WisVKPi std::size_t data_size = 0; table.vkGetPipelineCacheData(impl.device_header->header.device, impl.cache, &data_size, nullptr); return wis::aligned_size( - data_size, - 4096u - ); // Align to 4096 bytes for better memory management when this data is used to create a new pipeline cache + data_size, + 4096u + ); // Align to 4096 bytes for better memory management when this data is used to create a new pipeline cache } #endif // WIS_VK_PIPELINE_CACHE_CPP diff --git a/src/include/wisdom/vulkan/vk_resource_allocator.cpp b/src/include/wisdom/vulkan/vk_resource_allocator.cpp index 4a3502c1d..f2ab9f117 100644 --- a/src/include/wisdom/vulkan/vk_resource_allocator.cpp +++ b/src/include/wisdom/vulkan/vk_resource_allocator.cpp @@ -16,8 +16,8 @@ inline VkImageCreateInfo VKFillImageDesc(const WisTextureDesc& desc) noexcept .flags = (usage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR)) - ? VK_IMAGE_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR - : VkImageCreateFlags{0}, + ? VK_IMAGE_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR + : VkImageCreateFlags{0}, .format = wis::detail::VKConvert(desc.format), .samples = VK_SAMPLE_COUNT_1_BIT, .usage = usage, @@ -118,8 +118,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateBuffer( buffer_info.flags = (buffer_info.usage & (VK_BUFFER_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR)) - ? VK_BUFFER_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR - : 0; + ? VK_BUFFER_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR + : 0; VmaAllocationCreateFlags flags = wis::detail::VKConvert(desc->memory_flags); if (desc->memory_flags & WisMemoryFlagsMapped) { @@ -145,13 +145,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateBuffer( VkBuffer buffer_handle = VK_NULL_HANDLE; VmaAllocation allocation_handle = VK_NULL_HANDLE; VkResult vr = vmaCreateBuffer( - allocator.allocator, - &buffer_info, - &alloc_info, - &buffer_handle, - &allocation_handle, - nullptr - ); + allocator.allocator, + &buffer_info, + &alloc_info, + &buffer_handle, + &allocation_handle, + nullptr + ); if (!wis::detail::succeeded(vr)) { return wis::detail::make_result(vr); } @@ -188,8 +188,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateTexture( // Check memory type, you can't create a texture with upload or readback memory types if (desc->memory_type == WisMemoryTypeUpload || desc->memory_type == WisMemoryTypeReadback) { return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } VkImageCreateInfo image_info = wis::detail::VKFillImageDesc(*desc); @@ -233,7 +233,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateTexture( VkImage image_handle = VK_NULL_HANDLE; VmaAllocation allocation_handle = VK_NULL_HANDLE; VkResult - vr = vmaCreateImage(allocator.allocator, &image_info, &alloc_info, &image_handle, &allocation_handle, nullptr); + vr = vmaCreateImage(allocator.allocator, &image_info, &alloc_info, &image_handle, &allocation_handle, nullptr); if (!wis::detail::succeeded(vr)) { return wis::detail::make_result(vr); } @@ -275,8 +275,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateTexture( .width = static_cast(image_info.extent.width), .height = static_cast(image_info.extent.height), .depth_or_array_size = desc->layout == WisTextureLayoutTexture3D - ? static_cast(image_info.extent.depth) - : static_cast(image_info.arrayLayers), + ? static_cast(image_info.extent.depth) + : static_cast(image_info.arrayLayers), }; impl.device_header->AddRef(); diff --git a/src/include/wisdom/vulkan/vk_swapchain.cpp b/src/include/wisdom/vulkan/vk_swapchain.cpp index 551d5b72a..274a304f2 100644 --- a/src/include/wisdom/vulkan/vk_swapchain.cpp +++ b/src/include/wisdom/vulkan/vk_swapchain.cpp @@ -17,13 +17,13 @@ inline VkResult VKAcquireNextImage(const impl::VKSwapchainImpl& impl) noexcept // Acquire the next image index for the new swapchain to update internal state auto result = impl.swapchain_table->vkAcquireNextImageKHR( - impl.device, - impl.swapchain, - impl.lazy_acquire ? 0 : std::numeric_limits::max(), - semaphores[impl.acquire_index], - nullptr, - &impl.present_index - ); + impl.device, + impl.swapchain, + impl.lazy_acquire ? 0 : std::numeric_limits::max(), + semaphores[impl.acquire_index], + nullptr, + &impl.present_index + ); if (result != VK_SUCCESS) { return result; // Caller can choose to handle timeout differently (e.g. by skipping rendering and trying again @@ -162,8 +162,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel VkFormat new_format = wis::detail::VKConvert(desc->format); bool size_changed = desc->width != 0 && desc->height != 0 - && (desc->width != create_info.imageExtent.width - || desc->height != create_info.imageExtent.height); + && (desc->width != create_info.imageExtent.width + || desc->height != create_info.imageExtent.height); bool format_changed = desc->format != WisDataFormatUnknown && new_format != create_info.imageFormat; bool count_changed = desc->image_count != 0 && desc->image_count != create_info.minImageCount; bool vsync_changed = desc->vsync != (create_info.presentMode == VK_PRESENT_MODE_FIFO_KHR); @@ -193,13 +193,15 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel if (format_changed) { auto formats = header.GetSupportedFormats(); if (std::ranges::find_if( - formats, - [new_format](const VkSurfaceFormatKHR& fmt) { return fmt.format == new_format; } + formats, + [new_format](const VkSurfaceFormatKHR& fmt) { + return fmt.format == new_format; + } ) - == std::end(formats)) { + == std::end(formats)) { return wis::detail::make_result( - VK_ERROR_FORMAT_NOT_SUPPORTED - ); + VK_ERROR_FORMAT_NOT_SUPPORTED + ); } } @@ -218,16 +220,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel header.vkGetPhysicalDeviceSurfaceCapabilities2KHR(header.physical_device, &surface_info, &capabilities); capabilities.surfaceCapabilities.maxImageCount = capabilities.surfaceCapabilities.maxImageCount == 0 - ? wis::AbsoluteMaxSwapchainImages - : capabilities.surfaceCapabilities.maxImageCount; + ? wis::AbsoluteMaxSwapchainImages + : capabilities.surfaceCapabilities.maxImageCount; } if (count_changed - && (desc->image_count < capabilities.surfaceCapabilities.minImageCount - || desc->image_count > capabilities.surfaceCapabilities.maxImageCount)) { + && (desc->image_count < capabilities.surfaceCapabilities.minImageCount + || desc->image_count > capabilities.surfaceCapabilities.maxImageCount)) { return wis::detail::make_result< - wis::detail::Func(), - "Requested swapchain image count is out of bounds for the given surface">(VK_ERROR_INITIALIZATION_FAILED); + wis::detail::Func(), + "Requested swapchain image count is out of bounds for the given surface">(VK_ERROR_INITIALIZATION_FAILED); } // Store backups @@ -245,17 +247,17 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel }; create_info.imageExtent.width = desc->width != 0 ? std::clamp( - desc->width, - capabilities.surfaceCapabilities.minImageExtent.width, - capabilities.surfaceCapabilities.maxImageExtent.width - ) - : create_info.imageExtent.width; + desc->width, + capabilities.surfaceCapabilities.minImageExtent.width, + capabilities.surfaceCapabilities.maxImageExtent.width + ) + : create_info.imageExtent.width; create_info.imageExtent.height = desc->height != 0 ? std::clamp( - desc->height, - capabilities.surfaceCapabilities.minImageExtent.height, - capabilities.surfaceCapabilities.maxImageExtent.height - ) - : create_info.imageExtent.height; + desc->height, + capabilities.surfaceCapabilities.minImageExtent.height, + capabilities.surfaceCapabilities.maxImageExtent.height + ) + : create_info.imageExtent.height; create_info.imageFormat = desc->format != WisDataFormatUnknown ? new_format : create_info.imageFormat; create_info.minImageCount = desc->image_count != 0 ? desc->image_count : create_info.minImageCount; @@ -278,7 +280,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel // Wait for the GPU to finish with the swapchain vr = impl.swapchain_table - ->vkWaitForFences(impl.device, 1, &impl.destroy_fence, VK_TRUE, std::numeric_limits::max()); + ->vkWaitForFences(impl.device, 1, &impl.destroy_fence, VK_TRUE, std::numeric_limits::max()); if (!wis::detail::succeeded(vr)) { restore_on_failure(); return wis::detail::make_result(vr); @@ -294,7 +296,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel if (vr != VK_SUCCESS) { // no restore return wis::detail:: - make_result(vr); + make_result(vr); } return wis::detail::vk_success; @@ -317,8 +319,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainGetTextures( if (buffer_count < actual_buffer_count) { return wis::detail::make_result< - wis::detail::Func(), - "Provided buffer count is less than the number of swapchain images">(VK_ERROR_UNKNOWN); + wis::detail::Func(), + "Provided buffer count is less than the number of swapchain images">(VK_ERROR_UNKNOWN); } // Cheat the allocation of the output array to avoid dynamic memory allocation in this function by treating the diff --git a/src/include/wisdom/vulkan/vk_tables.hpp b/src/include/wisdom/vulkan/vk_tables.hpp index 0fed82c81..2b1e327ec 100644 --- a/src/include/wisdom/vulkan/vk_tables.hpp +++ b/src/include/wisdom/vulkan/vk_tables.hpp @@ -16,7 +16,7 @@ typedef struct VkPhysicalDeviceDeviceAddressCommandsFeaturesKHR { } VkPhysicalDeviceDeviceAddressCommandsFeaturesKHR; static constexpr VkStructureType - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_ADDRESS_COMMANDS_FEATURES_KHR = VkStructureType(1000318006); +VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_ADDRESS_COMMANDS_FEATURES_KHR = VkStructureType(1000318006); static constexpr VkStructureType VK_STRUCTURE_TYPE_BIND_VERTEX_BUFFER_3_INFO_KHR = VkStructureType(1000318008); static constexpr VkStructureType VK_STRUCTURE_TYPE_BIND_INDEX_BUFFER_3_INFO_KHR = VkStructureType(1000318007); @@ -44,11 +44,11 @@ typedef struct VkBindIndexBuffer3InfoKHR { } VkBindIndexBuffer3InfoKHR; using PFN_vkCmdBindVertexBuffers3KHR = void (*)( - VkCommandBuffer commandBuffer, - uint32_t firstBinding, - uint32_t bindingCount, - const VkBindVertexBuffer3InfoKHR* pBindingInfos -); + VkCommandBuffer commandBuffer, + uint32_t firstBinding, + uint32_t bindingCount, + const VkBindVertexBuffer3InfoKHR* pBindingInfos + ); using PFN_vkCmdBindIndexBuffer3KHR = void (*)(VkCommandBuffer commandBuffer, const VkBindIndexBuffer3InfoKHR* pInfo); #endif // VK_KHR_device_address_commands diff --git a/src/include/wisdom/wisdom.hpp b/src/include/wisdom/wisdom.hpp index 9f6d7f667..cd4ae1e0c 100644 --- a/src/include/wisdom/wisdom.hpp +++ b/src/include/wisdom/wisdom.hpp @@ -91,11 +91,11 @@ WIS_NODISCARD inline wis::Instance CreateInstance( { wis::DX12Instance instance{}; const WisResult wis_result = ::wisDX12CreateInstance( - reinterpret_cast(debug_desc), - reinterpret_cast(extensions.data()), - extensions.size(), - instance.GetStorage() - ); + reinterpret_cast(debug_desc), + reinterpret_cast(extensions.data()), + extensions.size(), + instance.GetStorage() + ); out_result = wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; return instance; } @@ -177,11 +177,11 @@ WIS_NODISCARD inline wis::Instance CreateInstance( { wis::VKInstance instance{}; const WisResult wis_result = ::wisVKCreateInstance( - reinterpret_cast(debug_desc), - reinterpret_cast(extensions.data()), - extensions.size(), - instance.GetStorage() - ); + reinterpret_cast(debug_desc), + reinterpret_cast(extensions.data()), + extensions.size(), + instance.GetStorage() + ); out_result = wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; return instance; } diff --git a/src/platform/wisdom_platform/generated/cpp_api.hpp b/src/platform/wisdom_platform/generated/cpp_api.hpp index 74cc9072f..75f8ce00d 100644 --- a/src/platform/wisdom_platform/generated/cpp_api.hpp +++ b/src/platform/wisdom_platform/generated/cpp_api.hpp @@ -70,7 +70,9 @@ struct UWPWindowDesc { namespace wis { struct DX12Win32ExtensionDeleter { - void operator()(WisDX12Win32Extension* handle) noexcept { ::wisDX12DestroyWin32Extension(handle); } + void operator()(WisDX12Win32Extension* handle) noexcept { + ::wisDX12DestroyWin32Extension(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Extension for Win32 surface creation functions. @@ -78,7 +80,7 @@ struct DX12Win32ExtensionDeleter { * */ class DX12Win32Extension : public wis::impl:: - Implements + Implements { public: DX12Win32Extension() noexcept @@ -87,7 +89,9 @@ class DX12Win32Extension ::wisDX12InitWin32Extension(GetStorage()); } // Operator & overload - wis::DX12InstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } + wis::DX12InstanceExtensionHeader* operator&() noexcept { + return &GetMutableInternal().header; + } public: /** @@ -104,10 +108,10 @@ class DX12Win32Extension { wis::DX12Surface surface{}; const WisResult wis_result = ::wisDX12Win32ExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -121,11 +125,15 @@ class DX12Win32Extension * @return bool true if the extension is supported, false otherwise. * * */ - WIS_NODISCARD inline bool Supported() noexcept { return (::wisDX12Win32ExtensionSupported(&_impl_storage)); } + WIS_NODISCARD inline bool Supported() noexcept { + return (::wisDX12Win32ExtensionSupported(&_impl_storage)); + } }; struct DX12UWPExtensionDeleter { - void operator()(WisDX12UWPExtension* handle) noexcept { ::wisDX12DestroyUWPExtension(handle); } + void operator()(WisDX12UWPExtension* handle) noexcept { + ::wisDX12DestroyUWPExtension(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Extension for UWP surface creation functions. @@ -141,7 +149,9 @@ class DX12UWPExtension ::wisDX12InitUWPExtension(GetStorage()); } // Operator & overload - wis::DX12InstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } + wis::DX12InstanceExtensionHeader* operator&() noexcept { + return &GetMutableInternal().header; + } public: /** @@ -158,10 +168,10 @@ class DX12UWPExtension { wis::DX12Surface surface{}; const WisResult wis_result = ::wisDX12UWPExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -179,7 +189,9 @@ class DX12UWPExtension namespace wis { struct VKXlibExtensionDeleter { - void operator()(WisVKXlibExtension* handle) noexcept { ::wisVKDestroyXlibExtension(handle); } + void operator()(WisVKXlibExtension* handle) noexcept { + ::wisVKDestroyXlibExtension(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Extension for Xlib surface creation functions. @@ -195,7 +207,9 @@ class VKXlibExtension ::wisVKInitXlibExtension(GetStorage()); } // Operator & overload - wis::VKInstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } + wis::VKInstanceExtensionHeader* operator&() noexcept { + return &GetMutableInternal().header; + } public: /** @@ -209,10 +223,10 @@ class VKXlibExtension { wis::VKSurface surface{}; const WisResult wis_result = ::wisVKXlibExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -225,11 +239,15 @@ class VKXlibExtension * @return bool true if the extension is supported, false otherwise. * * */ - WIS_NODISCARD inline bool Supported() noexcept { return (::wisVKXlibExtensionSupported(&_impl_storage)); } + WIS_NODISCARD inline bool Supported() noexcept { + return (::wisVKXlibExtensionSupported(&_impl_storage)); + } }; struct VKXCBExtensionDeleter { - void operator()(WisVKXCBExtension* handle) noexcept { ::wisVKDestroyXCBExtension(handle); } + void operator()(WisVKXCBExtension* handle) noexcept { + ::wisVKDestroyXCBExtension(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Extension for Xlib surface creation functions. @@ -245,7 +263,9 @@ class VKXCBExtension ::wisVKInitXCBExtension(GetStorage()); } // Operator & overload - wis::VKInstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } + wis::VKInstanceExtensionHeader* operator&() noexcept { + return &GetMutableInternal().header; + } public: /** @@ -259,10 +279,10 @@ class VKXCBExtension { wis::VKSurface surface{}; const WisResult wis_result = ::wisVKXCBExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -275,11 +295,15 @@ class VKXCBExtension * @return bool true if the extension is supported, false otherwise. * * */ - WIS_NODISCARD inline bool Supported() noexcept { return (::wisVKXCBExtensionSupported(&_impl_storage)); } + WIS_NODISCARD inline bool Supported() noexcept { + return (::wisVKXCBExtensionSupported(&_impl_storage)); + } }; struct VKWaylandExtensionDeleter { - void operator()(WisVKWaylandExtension* handle) noexcept { ::wisVKDestroyWaylandExtension(handle); } + void operator()(WisVKWaylandExtension* handle) noexcept { + ::wisVKDestroyWaylandExtension(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Extension for Xlib surface creation functions. @@ -287,7 +311,7 @@ struct VKWaylandExtensionDeleter { * */ class VKWaylandExtension : public wis::impl:: - Implements + Implements { public: VKWaylandExtension() noexcept @@ -296,7 +320,9 @@ class VKWaylandExtension ::wisVKInitWaylandExtension(GetStorage()); } // Operator & overload - wis::VKInstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } + wis::VKInstanceExtensionHeader* operator&() noexcept { + return &GetMutableInternal().header; + } public: /** @@ -313,10 +339,10 @@ class VKWaylandExtension { wis::VKSurface surface{}; const WisResult wis_result = ::wisVKWaylandExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -329,11 +355,15 @@ class VKWaylandExtension * @return bool true if the extension is supported, false otherwise. * * */ - WIS_NODISCARD inline bool Supported() noexcept { return (::wisVKWaylandExtensionSupported(&_impl_storage)); } + WIS_NODISCARD inline bool Supported() noexcept { + return (::wisVKWaylandExtensionSupported(&_impl_storage)); + } }; struct VKWin32ExtensionDeleter { - void operator()(WisVKWin32Extension* handle) noexcept { ::wisVKDestroyWin32Extension(handle); } + void operator()(WisVKWin32Extension* handle) noexcept { + ::wisVKDestroyWin32Extension(handle); + } }; /** * @brief Provided by Wisdom 0.7.0. Extension for Win32 surface creation functions. @@ -349,7 +379,9 @@ class VKWin32Extension ::wisVKInitWin32Extension(GetStorage()); } // Operator & overload - wis::VKInstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } + wis::VKInstanceExtensionHeader* operator&() noexcept { + return &GetMutableInternal().header; + } public: /** @@ -366,10 +398,10 @@ class VKWin32Extension { wis::VKSurface surface{}; const WisResult wis_result = ::wisVKWin32ExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -383,7 +415,9 @@ class VKWin32Extension * @return bool true if the extension is supported, false otherwise. * * */ - WIS_NODISCARD inline bool Supported() noexcept { return (::wisVKWin32ExtensionSupported(&_impl_storage)); } + WIS_NODISCARD inline bool Supported() noexcept { + return (::wisVKWin32ExtensionSupported(&_impl_storage)); + } }; } // namespace wis diff --git a/src/platform/wisdom_platform/vulkan/vk_platform_wayland.cpp b/src/platform/wisdom_platform/vulkan/vk_platform_wayland.cpp index a2db30fad..fe42f851b 100644 --- a/src/platform/wisdom_platform/vulkan/vk_platform_wayland.cpp +++ b/src/platform/wisdom_platform/vulkan/vk_platform_wayland.cpp @@ -82,8 +82,8 @@ WIS_EXTERN_C WISDOM_PLATFORM_API WisResult wisVKWaylandExtensionCreateSurface( auto& itable = impl.instance_control_block->header.instance_table; itable.vkDestroySurfaceKHR(impl.instance_control_block->header.instance, vk_surface, nullptr); return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } header->header.instance_header = impl.instance_control_block, header->header.surface = vk_surface, diff --git a/src/platform/wisdom_platform/vulkan/vk_platform_win32.cpp b/src/platform/wisdom_platform/vulkan/vk_platform_win32.cpp index c1f3b0595..93bc34cf5 100644 --- a/src/platform/wisdom_platform/vulkan/vk_platform_win32.cpp +++ b/src/platform/wisdom_platform/vulkan/vk_platform_win32.cpp @@ -109,8 +109,8 @@ WISDOM_PLATFORM_API WisResult wisVKWin32ExtensionCreateSurface( auto& itable = impl.instance_control_block->header.instance_table; itable.vkDestroySurfaceKHR(impl.instance_control_block->header.instance, vk_surface, nullptr); return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } header->header.instance_header = impl.instance_control_block, header->header.surface = vk_surface, diff --git a/src/platform/wisdom_platform/vulkan/vk_platform_xcb.cpp b/src/platform/wisdom_platform/vulkan/vk_platform_xcb.cpp index f8080746c..eab56c055 100644 --- a/src/platform/wisdom_platform/vulkan/vk_platform_xcb.cpp +++ b/src/platform/wisdom_platform/vulkan/vk_platform_xcb.cpp @@ -86,8 +86,8 @@ WISDOM_PLATFORM_API WisResult wisVKXCBExtensionCreateSurface( auto& itable = impl.instance_control_block->header.instance_table; itable.vkDestroySurfaceKHR(impl.instance_control_block->header.instance, vk_surface, nullptr); return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } header->header.instance_header = impl.instance_control_block, header->header.surface = vk_surface, diff --git a/src/platform/wisdom_platform/vulkan/vk_platform_xlib.cpp b/src/platform/wisdom_platform/vulkan/vk_platform_xlib.cpp index c896e8ffb..630b036aa 100644 --- a/src/platform/wisdom_platform/vulkan/vk_platform_xlib.cpp +++ b/src/platform/wisdom_platform/vulkan/vk_platform_xlib.cpp @@ -87,8 +87,8 @@ WISDOM_PLATFORM_API WisResult wisVKXlibExtensionCreateSurface( auto& itable = impl.instance_control_block->header.instance_table; itable.vkDestroySurfaceKHR(impl.instance_control_block->header.instance, vk_surface, nullptr); return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } header->header.instance_header = impl.instance_control_block, header->header.surface = vk_surface, diff --git a/test_package/main.cpp b/test_package/main.cpp index a15ed5c95..84bd8e385 100644 --- a/test_package/main.cpp +++ b/test_package/main.cpp @@ -1,9 +1,9 @@ #include int main() -{ - wis::Result result{}; - wis::DebugDesc debug_desc{true}; - wis::Instance instance = wis::CreateInstance(&debug_desc, {}, result); - return 0; +{ + wis::Result result{}; + wis::DebugDesc debug_desc{true}; + wis::Instance instance = wis::CreateInstance(&debug_desc, {}, result); + return 0; } \ No newline at end of file diff --git a/tests/basic/platform_check.cpp b/tests/basic/platform_check.cpp index 03ea33250..b7c3417e4 100644 --- a/tests/basic/platform_check.cpp +++ b/tests/basic/platform_check.cpp @@ -21,14 +21,14 @@ TEST_CASE("check_platform_support") &win32_extension.header, }; WisResult result = wisCreateInstance( - NULL, - extensions, - sizeof(extensions) / sizeof(WisInstanceExtensionHeader*), - &instance - ); + NULL, + extensions, + sizeof(extensions) / sizeof(WisInstanceExtensionHeader*), + &instance + ); // Expect partial success - REQUIRE(result.status >= 0); + REQUIRE(result.status >= 0); #ifdef WISDOM_WINDOWS printf("XCB supported: %s\n", wisXCBExtensionSupported(&xcb_extension) ? "Yes" : "No"); From 9d02017e003f06d6a8babd22609a3b4aaa59f26d Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 13 Sep 2026 17:07:19 +0000 Subject: [PATCH 02/11] Restyled by autopep8 --- conanfile.py | 36 +++++++++++++++++++++++------------- test_package/conanfile.py | 3 ++- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/conanfile.py b/conanfile.py index e2ccc6199..91dc03b7c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -28,7 +28,7 @@ class WisdomConan(ConanFile): # keep it for now, but remove when we are at CCI def set_version(self): version_file_path = os.path.join(self.recipe_folder, "version/VERSION") - + try: self.version = load(self, version_file_path).strip() except Exception as e: @@ -38,7 +38,8 @@ def set_version(self): def requirements(self): # If windows platform support is enabled, we need to require the D3D12 Memory Allocator if self.settings.os == "Windows": - self.requires("d3d12-memory-allocator/[>=3.0.1 <4]", transitive_headers=True) + self.requires( + "d3d12-memory-allocator/[>=3.0.1 <4]", transitive_headers=True) self.requires("vulkan-memory-allocator/3.3.0", transitive_headers=True) def export_sources(self): @@ -86,7 +87,8 @@ def generate(self): tc.variables["WISDOM_BUILD_EXAMPLES"] = False tc.variables["WISDOM_BUILD_TESTS"] = False tc.variables["WISDOM_BUILD_DOCS"] = False - tc.variables["WISDOM_BUILD_STATIC"] = not self.options.get_safe("shared") + tc.variables["WISDOM_BUILD_STATIC"] = not self.options.get_safe( + "shared") tc.variables["WISDOM_BUILD_SHARED"] = self.options.get_safe("shared") tc.variables["WISDOM_BUILD_PLATFORM"] = self.options.build_platform tc.variables["WISDOM_USE_AGILITY_SDK"] = False @@ -115,31 +117,38 @@ def package_info(self): build_modules = ["lib/cmake/wisdom/functions.cmake"] self.cpp_info.set_property("cmake_build_modules", build_modules) - # Targets: suffix = "d" if self.settings.build_type == "Debug" else "" if self.options.get_safe("shared"): # Core Shared - self.cpp_info.components["core"].set_property("cmake_target_name", "wis::wisdom-shared") + self.cpp_info.components["core"].set_property( + "cmake_target_name", "wis::wisdom-shared") self.cpp_info.components["core"].libs = [f"wisdom-shared{suffix}"] # Platform Shared if self.options.build_platform: - self.cpp_info.components["platform"].set_property("cmake_target_name", "wis::wisdom-platform-shared") + self.cpp_info.components["platform"].set_property( + "cmake_target_name", "wis::wisdom-platform-shared") self.cpp_info.components["platform"].requires = ["core"] - self.cpp_info.components["platform"].libs = [f"wisdom-platform-shared{suffix}"] + self.cpp_info.components["platform"].libs = [ + f"wisdom-platform-shared{suffix}"] else: # Core Static - self.cpp_info.components["core"].set_property("cmake_target_name", "wis::wisdom") - self.cpp_info.components["core"].libs = [f"wisdom{suffix}", f"vkma{suffix}"] + self.cpp_info.components["core"].set_property( + "cmake_target_name", "wis::wisdom") + self.cpp_info.components["core"].libs = [ + f"wisdom{suffix}", f"vkma{suffix}"] # Platform Static if self.options.build_platform: - self.cpp_info.components["platform"].set_property("cmake_target_name", "wis::wisdom-platform") + self.cpp_info.components["platform"].set_property( + "cmake_target_name", "wis::wisdom-platform") self.cpp_info.components["platform"].requires = ["core"] - self.cpp_info.components["platform"].libs = [f"wisdom-platform{suffix}"] + self.cpp_info.components["platform"].libs = [ + f"wisdom-platform{suffix}"] - self.cpp_info.components["core"].requires = ["vulkan-memory-allocator::vulkan-memory-allocator"] + self.cpp_info.components["core"].requires = [ + "vulkan-memory-allocator::vulkan-memory-allocator"] if self.settings.os == "Windows": self.cpp_info.components["core"].defines.extend([ "D3D12MA_USING_DIRECTX_HEADERS=1", @@ -148,4 +157,5 @@ def package_info(self): self.cpp_info.components["core"].requires.extend([ "d3d12-memory-allocator::d3d12-memory-allocator" ]) - self.cpp_info.components["core"].system_libs.extend(["dxgi", "DXGUID"]) \ No newline at end of file + self.cpp_info.components["core"].system_libs.extend( + ["dxgi", "DXGUID"]) diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 9cf9befcc..e6b7e763e 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -3,6 +3,7 @@ from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain from conan.tools.build import can_run + class WisdomTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "CMakeDeps" @@ -29,4 +30,4 @@ def build(self): def test(self): if can_run(self): cmd = os.path.join(self.cpp.build.bindir, "test_app") - self.run(cmd, env="conanrun") \ No newline at end of file + self.run(cmd, env="conanrun") From eda71b26952623da0deb3f09212d4b938e510180 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 13 Sep 2026 17:07:22 +0000 Subject: [PATCH 03/11] Restyled by black --- conanfile.py | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/conanfile.py b/conanfile.py index 91dc03b7c..176e51737 100644 --- a/conanfile.py +++ b/conanfile.py @@ -39,7 +39,8 @@ def requirements(self): # If windows platform support is enabled, we need to require the D3D12 Memory Allocator if self.settings.os == "Windows": self.requires( - "d3d12-memory-allocator/[>=3.0.1 <4]", transitive_headers=True) + "d3d12-memory-allocator/[>=3.0.1 <4]", transitive_headers=True + ) self.requires("vulkan-memory-allocator/3.3.0", transitive_headers=True) def export_sources(self): @@ -87,8 +88,7 @@ def generate(self): tc.variables["WISDOM_BUILD_EXAMPLES"] = False tc.variables["WISDOM_BUILD_TESTS"] = False tc.variables["WISDOM_BUILD_DOCS"] = False - tc.variables["WISDOM_BUILD_STATIC"] = not self.options.get_safe( - "shared") + tc.variables["WISDOM_BUILD_STATIC"] = not self.options.get_safe("shared") tc.variables["WISDOM_BUILD_SHARED"] = self.options.get_safe("shared") tc.variables["WISDOM_BUILD_PLATFORM"] = self.options.build_platform tc.variables["WISDOM_USE_AGILITY_SDK"] = False @@ -122,40 +122,45 @@ def package_info(self): if self.options.get_safe("shared"): # Core Shared self.cpp_info.components["core"].set_property( - "cmake_target_name", "wis::wisdom-shared") + "cmake_target_name", "wis::wisdom-shared" + ) self.cpp_info.components["core"].libs = [f"wisdom-shared{suffix}"] # Platform Shared if self.options.build_platform: self.cpp_info.components["platform"].set_property( - "cmake_target_name", "wis::wisdom-platform-shared") + "cmake_target_name", "wis::wisdom-platform-shared" + ) self.cpp_info.components["platform"].requires = ["core"] self.cpp_info.components["platform"].libs = [ - f"wisdom-platform-shared{suffix}"] + f"wisdom-platform-shared{suffix}" + ] else: # Core Static self.cpp_info.components["core"].set_property( - "cmake_target_name", "wis::wisdom") - self.cpp_info.components["core"].libs = [ - f"wisdom{suffix}", f"vkma{suffix}"] + "cmake_target_name", "wis::wisdom" + ) + self.cpp_info.components["core"].libs = [f"wisdom{suffix}", f"vkma{suffix}"] # Platform Static if self.options.build_platform: self.cpp_info.components["platform"].set_property( - "cmake_target_name", "wis::wisdom-platform") + "cmake_target_name", "wis::wisdom-platform" + ) self.cpp_info.components["platform"].requires = ["core"] - self.cpp_info.components["platform"].libs = [ - f"wisdom-platform{suffix}"] + self.cpp_info.components["platform"].libs = [f"wisdom-platform{suffix}"] self.cpp_info.components["core"].requires = [ - "vulkan-memory-allocator::vulkan-memory-allocator"] + "vulkan-memory-allocator::vulkan-memory-allocator" + ] if self.settings.os == "Windows": - self.cpp_info.components["core"].defines.extend([ - "D3D12MA_USING_DIRECTX_HEADERS=1", - "VK_USE_PLATFORM_WIN32_KHR=1", - ]) - self.cpp_info.components["core"].requires.extend([ - "d3d12-memory-allocator::d3d12-memory-allocator" - ]) - self.cpp_info.components["core"].system_libs.extend( - ["dxgi", "DXGUID"]) + self.cpp_info.components["core"].defines.extend( + [ + "D3D12MA_USING_DIRECTX_HEADERS=1", + "VK_USE_PLATFORM_WIN32_KHR=1", + ] + ) + self.cpp_info.components["core"].requires.extend( + ["d3d12-memory-allocator::d3d12-memory-allocator"] + ) + self.cpp_info.components["core"].system_libs.extend(["dxgi", "DXGUID"]) From ca50a970101d33c80ef16039015ca6f35421ad89 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 13 Sep 2026 17:07:30 +0000 Subject: [PATCH 04/11] Restyled by clang-format --- docs/wisdom/getting_started.h | 4 +- examples/backend/sdl_backend_c.c | 18 +- examples/compute_particles_c/entry_main.c | 132 ++- examples/hello_triangle/entry_main.c | 23 +- examples/hello_triangle/entry_main.cpp | 10 +- generator/bitmask.cpp | 110 +- generator/entry_main.cpp | 10 +- generator/enum.cpp | 84 +- generator/function.cpp | 192 ++-- generator/generator.cpp | 358 +++--- generator/generator.hpp | 20 +- generator/handle.cpp | 130 +-- generator/pch.hpp | 2 +- generator/struct.cpp | 38 +- generator/types.hpp | 56 +- generator/validation.cpp | 2 +- generator/variant.cpp | 40 +- src/include/wisdom/bridge/span.hpp | 81 +- .../wisdom/dx12/detail/dx12_detail.hpp | 77 +- .../wisdom/dx12/dx12_adapter_query.cpp | 39 +- .../wisdom/dx12/dx12_command_allocator.cpp | 18 +- src/include/wisdom/dx12/dx12_command_list.cpp | 163 +-- .../wisdom/dx12/dx12_command_queue.cpp | 21 +- .../wisdom/dx12/dx12_descriptor_heap.cpp | 94 +- src/include/wisdom/dx12/dx12_device.cpp | 403 +++---- src/include/wisdom/dx12/dx12_impl.cpp | 30 +- src/include/wisdom/dx12/dx12_instance.cpp | 29 +- .../wisdom/dx12/dx12_pipeline_cache.cpp | 7 +- .../wisdom/dx12/dx12_resource_allocator.cpp | 86 +- src/include/wisdom/dx12/dx12_swapchain.cpp | 31 +- src/include/wisdom/generated/c_api.h | 279 ++--- src/include/wisdom/generated/cpp_api.hpp | 1008 +++++++---------- src/include/wisdom/generated/dx12_convert.hpp | 28 +- src/include/wisdom/generated/vk_convert.hpp | 12 +- src/include/wisdom/global/internal.hpp | 12 +- .../wisdom/vulkan/detail/vk_detail.hpp | 54 +- src/include/wisdom/vulkan/detail/vk_ext1.hpp | 43 +- .../wisdom/vulkan/vk_adapter_query.cpp | 109 +- .../wisdom/vulkan/vk_command_allocator.cpp | 14 +- src/include/wisdom/vulkan/vk_command_list.cpp | 152 +-- .../wisdom/vulkan/vk_command_queue.cpp | 21 +- .../wisdom/vulkan/vk_descriptor_heap.cpp | 53 +- src/include/wisdom/vulkan/vk_device.cpp | 578 +++++----- src/include/wisdom/vulkan/vk_extensions.cpp | 51 +- src/include/wisdom/vulkan/vk_extensions.hpp | 44 +- src/include/wisdom/vulkan/vk_impl.cpp | 23 +- src/include/wisdom/vulkan/vk_instance.cpp | 65 +- .../wisdom/vulkan/vk_pipeline_cache.cpp | 13 +- .../wisdom/vulkan/vk_resource_allocator.cpp | 54 +- src/include/wisdom/vulkan/vk_swapchain.cpp | 91 +- src/include/wisdom/vulkan/vk_tables.hpp | 12 +- src/include/wisdom/wisdom.hpp | 20 +- .../dx12/dx12_platform_uwp.cpp | 7 +- .../dx12/dx12_platform_win32.cpp | 7 +- .../wisdom_platform/generated/c_api.h | 28 +- .../wisdom_platform/generated/cpp_api.hpp | 120 +- .../vulkan/vk_platform_wayland.cpp | 11 +- .../vulkan/vk_platform_win32.cpp | 11 +- .../vulkan/vk_platform_xcb.cpp | 11 +- .../vulkan/vk_platform_xlib.cpp | 11 +- test_package/main.cpp | 2 +- tests/basic/platform_check.cpp | 11 +- 62 files changed, 2327 insertions(+), 2936 deletions(-) diff --git a/docs/wisdom/getting_started.h b/docs/wisdom/getting_started.h index f8cf5a607..f1620579e 100644 --- a/docs/wisdom/getting_started.h +++ b/docs/wisdom/getting_started.h @@ -126,7 +126,9 @@ * - `WISDOM_BUILD_TESTS=ON/OFF` build tests * - `WISDOM_BUILD_DOCS=ON/OFF` build Doxygen documentation * - `WISDOM_DXC_PATH=` custom DXC location - * - `WISDOM_USE_AGILITY_SDK=OFF` download and build with Agility SDK instead of Windows SDK, this allows using latest DirectX 12 features on older Windows versions, but requires additional setup and dependencies. Default is `OFF`, which uses Windows SDK that comes with the system and DirectX-Headers. + * - `WISDOM_USE_AGILITY_SDK=OFF` download and build with Agility SDK instead of Windows SDK, this allows using latest + * DirectX 12 features on older Windows versions, but requires additional setup and dependencies. Default is `OFF`, + * which uses Windows SDK that comes with the system and DirectX-Headers. * - `WISDOM_VULKAN_HEADER_PATH=` custom Vulkan-Headers location * * @section nuget NuGet Package diff --git a/examples/backend/sdl_backend_c.c b/examples/backend/sdl_backend_c.c index 6f6b6d9fd..451e673ff 100644 --- a/examples/backend/sdl_backend_c.c +++ b/examples/backend/sdl_backend_c.c @@ -52,8 +52,8 @@ WisSurface CreateSurface(const SDLPlatform* platform, SDL_Window* window) #if defined(SDL_PLATFORM_WIN32) case SDL_PLATFORM_EXTENSION_WIN32: { WisWin32Extension* win32_extension = (WisWin32Extension*)platform->platform_extension; - HWND hwnd = (HWND) - SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); + HWND hwnd = (HWND + )SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); if (hwnd) { WisWin32WindowDesc desc = { .hinstance = GetModuleHandle(NULL), @@ -68,9 +68,9 @@ WisSurface CreateSurface(const SDLPlatform* platform, SDL_Window* window) #elif defined(SDL_PLATFORM_LINUX) case SDL_PLATFORM_EXTENSION_X11: { void* xdisplay = (void*) - SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_X11_DISPLAY_POINTER, NULL); - uint64_t xwindow = (uint64_t) - SDL_GetNumberProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0); + SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_X11_DISPLAY_POINTER, NULL); + uint64_t xwindow = (uint64_t + )SDL_GetNumberProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0); if (xdisplay && xwindow) { WisXlibWindowDesc desc = { .display = xdisplay, @@ -85,9 +85,9 @@ WisSurface CreateSurface(const SDLPlatform* platform, SDL_Window* window) case SDL_PLATFORM_EXTENSION_WAYLAND: { WisWaylandExtension* wayland_extension = (WisWaylandExtension*)platform->platform_extension; struct wl_display* display = (struct wl_display*) - SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, NULL); + SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, NULL); struct wl_surface* surface = (struct wl_surface*) - SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, NULL); + SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, NULL); if (display && surface) { WisWaylandWindowDesc desc = { .display = display, @@ -104,9 +104,7 @@ WisSurface CreateSurface(const SDLPlatform* platform, SDL_Window* window) break; } - return (WisSurface) { - 0 - }; + return (WisSurface){0}; } void DestroyPlatform(SDLPlatform* platform) diff --git a/examples/compute_particles_c/entry_main.c b/examples/compute_particles_c/entry_main.c index 6473292df..e2f7e8cb3 100644 --- a/examples/compute_particles_c/entry_main.c +++ b/examples/compute_particles_c/entry_main.c @@ -268,10 +268,10 @@ void ResizeDepth(BasicRenderer* renderer, uint32_t width, uint32_t height) .memory_flags = WisMemoryFlagsNone, }; WisResult result = wisResourceAllocatorCreateTexture( - &renderer->allocator, - &depth_desc, - &renderer->depth_texture[i] - ); + &renderer->allocator, + &depth_desc, + &renderer->depth_texture[i] + ); printf( "CreateDepthTexture[%u] result: %d, platform_code: %d, error: %s\n", i, @@ -285,7 +285,7 @@ void ResizeDepth(BasicRenderer* renderer, uint32_t width, uint32_t height) .array_layer_count = 1, }; wisViewHeapWriteDepthStencil(&renderer->dsv_heap, &renderer->depth_texture[i], &dsv_desc, i); - barriers[i] = (WisTextureBarrier) { + barriers[i] = (WisTextureBarrier){ .sync_before = WisBarrierSyncNone, .sync_after = WisBarrierSyncNone, .access_before = WisResourceAccessNone, @@ -311,10 +311,10 @@ void ResizeDepth(BasicRenderer* renderer, uint32_t width, uint32_t height) // insert a fence result = wisCommandQueueSignalFence( - &renderer->gfx_queue, - wisGetFenceView(&renderer->aux_fence), - ++renderer->aux_fence_value - ); + &renderer->gfx_queue, + wisGetFenceView(&renderer->aux_fence), + ++renderer->aux_fence_value + ); result = wisFenceWait(&renderer->aux_fence, renderer->aux_fence_value, UINT64_MAX); } @@ -403,11 +403,11 @@ void InitRenderer(BasicRenderer* renderer, SDL_Window* window) WisInstanceExtensionHeader* extensions[] = {platform.platform_extension}; WisInstance instance = {0}; WisResult result = wisCreateInstance( - &debug_desc, - extensions, - sizeof(extensions) / sizeof(WisInstanceExtensionHeader*), - &instance - ); + &debug_desc, + extensions, + sizeof(extensions) / sizeof(WisInstanceExtensionHeader*), + &instance + ); printf( "CreateInstance result: %d, platform_code: %d, error: %s\n", result.status, @@ -433,10 +433,10 @@ void InitRenderer(BasicRenderer* renderer, SDL_Window* window) // Query format support and choose swapchain format bool present_support = wisDeviceGetFormatPresentationSupport( - &renderer->device, - wisGetSurfaceView(&surface), - WisDataFormatRGB10A2Unorm - ); + &renderer->device, + wisGetSurfaceView(&surface), + WisDataFormatRGB10A2Unorm + ); if (present_support) { renderer->swapchain_format = WisDataFormatRGB10A2Unorm; printf("Surface supports the desired swapchain format.\n"); @@ -458,12 +458,12 @@ void InitRenderer(BasicRenderer* renderer, SDL_Window* window) .composite_alpha = WisCompositeAlphaOpaque, }; result = wisDeviceCreateSwapchain( - &renderer->device, - &surface, - &renderer->gfx_queue, - &swapchain_desc, - &renderer->swapchain - ); + &renderer->device, + &surface, + &renderer->gfx_queue, + &swapchain_desc, + &renderer->swapchain + ); // Destroy instance as we no longer need it wisDestroySurface(&surface); @@ -489,10 +489,10 @@ void InitRenderer(BasicRenderer* renderer, SDL_Window* window) for (uint32_t i = 0; i < FRAMES_IN_FLIGHT; ++i) { result = wisDeviceCreateCommandAllocator( - &renderer->device, - WisCommandQueueTypeGraphics, - &renderer->frames[i].command_allocator - ); + &renderer->device, + WisCommandQueueTypeGraphics, + &renderer->frames[i].command_allocator + ); printf( "CreateCommandAllocator[%u] result: %d, platform_code: %d, error: %s\n", i, @@ -502,9 +502,9 @@ void InitRenderer(BasicRenderer* renderer, SDL_Window* window) ); result = wisCommandAllocatorCreateCommandList( - &renderer->frames[i].command_allocator, - &renderer->frames[i].command_list - ); + &renderer->frames[i].command_allocator, + &renderer->frames[i].command_list + ); printf( "CreateCommandList[%u] result: %d, platform_code: %d, error: %s\n", i, @@ -578,10 +578,10 @@ void DestoyRenderer(BasicRenderer* renderer) { if (renderer->next_fence_value > 0) { WisResult result = wisCommandQueueSignalFence( - &renderer->gfx_queue, - wisGetFenceView(&renderer->fence), - ++renderer->next_fence_value - ); + &renderer->gfx_queue, + wisGetFenceView(&renderer->fence), + ++renderer->next_fence_value + ); printf( "Flush SignalFence result: %d, platform_code: %d, error: %s\n", result.status, @@ -626,10 +626,10 @@ void DestoyRenderer(BasicRenderer* renderer) void WaitForFinish(BasicRenderer* renderer) { WisResult result = wisCommandQueueSignalFence( - &renderer->gfx_queue, - wisGetFenceView(&renderer->fence), - renderer->next_fence_value - ); + &renderer->gfx_queue, + wisGetFenceView(&renderer->fence), + renderer->next_fence_value + ); printf( "WaitForFinish SignalFence result: %d, platform_code: %d, error: %s\n", result.status, @@ -667,10 +667,10 @@ void InitRenderTask(BasicRenderTask* task, BasicRenderer* renderer) .push_descriptor_count = 1, }; WisResult result = wisDeviceCreateRootSignature( - &renderer->device, - &compute_root_signature_desc, - &task->compute_signature - ); + &renderer->device, + &compute_root_signature_desc, + &task->compute_signature + ); printf( "CreateRootSignature for ComputeShader result: %d, platform_code: %d, error: %s\n", result.status, @@ -797,10 +797,10 @@ void InitResourceContainer(ResourceContainer* container, BasicRenderer* renderer .memory_type = WisMemoryTypeDeviceLocal, }; WisResult result = wisResourceAllocatorCreateBuffer( - &renderer->allocator, - &particle_buffer_desc, - &container->particle_buffer - ); + &renderer->allocator, + &particle_buffer_desc, + &container->particle_buffer + ); printf( "Create ParticleBuffer result: %d, platform_code: %d, error: %s\n", result.status, @@ -1009,22 +1009,19 @@ void Render(BasicRenderer* renderer, const ResourceContainer* resources, const B WisRenderPassDesc render_pass_desc = { .flags = 0, .render_targets = - { { .target = swap_rt, - .load_op = WisLoadOpClear, - .store_op = WisStoreOpStore, - .clear_value = {0.5f, 1.0f, 1.0f, 1.0f} - } - }, + {{.target = swap_rt, + .load_op = WisLoadOpClear, + .store_op = WisStoreOpStore, + .clear_value = {0.5f, 1.0f, 1.0f, 1.0f}}}, .render_target_count = 1, - .depth_stencil = { - .target = wisViewHeapGetViewAddress(&renderer->dsv_heap, renderer->frame_index), - .load_op_depth = WisLoadOpClear, - .load_op_stencil = WisLoadOpDontCare, - .store_op_depth = WisStoreOpStore, - .store_op_stencil = WisStoreOpDontCare, - .flags = WisDepthStencilFlagsIgnoreStencil, - .clear_depth = 1.0f - }, + .depth_stencil = + {.target = wisViewHeapGetViewAddress(&renderer->dsv_heap, renderer->frame_index), + .load_op_depth = WisLoadOpClear, + .load_op_stencil = WisLoadOpDontCare, + .store_op_depth = WisStoreOpStore, + .store_op_stencil = WisStoreOpDontCare, + .flags = WisDepthStencilFlagsIgnoreStencil, + .clear_depth = 1.0f}, }; result = wisCommandListBegin(&frame->command_list); @@ -1088,10 +1085,10 @@ void Render(BasicRenderer* renderer, const ResourceContainer* resources, const B frame->fence_value = renderer->next_fence_value; result = wisCommandQueueSignalFence( - &renderer->gfx_queue, - wisGetFenceView(&renderer->fence), - renderer->next_fence_value - ); + &renderer->gfx_queue, + wisGetFenceView(&renderer->fence), + renderer->next_fence_value + ); print_info( "Frame[%u] SignalFence result: %d, platform_code: %d, error: %s\n", renderer->frame_index, @@ -1157,8 +1154,7 @@ void HandleEvents(bool* running, BasicRenderer* renderer) ResizeDepth(renderer, update_desc.width, update_desc.height); - } - break; + } break; default: break; } diff --git a/examples/hello_triangle/entry_main.c b/examples/hello_triangle/entry_main.c index 45ef4f6da..0bb39ee2b 100644 --- a/examples/hello_triangle/entry_main.c +++ b/examples/hello_triangle/entry_main.c @@ -238,8 +238,8 @@ static bool init_app(HelloTriangleApp* app, SDL_Window* window) wisGetSurfaceView(&surface), WisDataFormatRGB10A2Unorm ) - ? WisDataFormatRGB10A2Unorm - : WisDataFormatBGRA8Unorm; + ? WisDataFormatRGB10A2Unorm + : WisDataFormatBGRA8Unorm; WisSwapchainDesc swapchain_desc = { .width = app->width, @@ -273,10 +273,10 @@ static bool init_app(HelloTriangleApp* app, SDL_Window* window) for (uint32_t i = 0; i < FRAMES_IN_FLIGHT; ++i) { result = wisDeviceCreateCommandAllocator( - &app->device, - WisCommandQueueTypeGraphics, - &app->frames[i].command_allocator - ); + &app->device, + WisCommandQueueTypeGraphics, + &app->frames[i].command_allocator + ); if (!check_result(result, "wisDeviceCreateCommandAllocator")) { return false; } @@ -453,12 +453,11 @@ static void draw_frame(HelloTriangleApp* app, float angle) WisRenderPassDesc render_pass = { .render_targets = {{ - .target = target_rtv, - .load_op = WisLoadOpClear, - .store_op = WisStoreOpStore, - .clear_value = {0.1f, 0.1f, 0.15f, 1.0f}, - } - }, + .target = target_rtv, + .load_op = WisLoadOpClear, + .store_op = WisStoreOpStore, + .clear_value = {0.1f, 0.1f, 0.15f, 1.0f}, + }}, .render_target_count = 1, }; diff --git a/examples/hello_triangle/entry_main.cpp b/examples/hello_triangle/entry_main.cpp index 5bc1ef167..1f03d8e7f 100644 --- a/examples/hello_triangle/entry_main.cpp +++ b/examples/hello_triangle/entry_main.cpp @@ -33,14 +33,14 @@ struct HelloTriangleApp { uint64_t next_fence_value = 1; wis::Swapchain swapchain{}; - wis::Texture swapchain_textures[SWAPCHAIN_FRAMES] {}; + wis::Texture swapchain_textures[SWAPCHAIN_FRAMES]{}; wis::ViewHeap rtv_heap{}; wis::DataFormat swapchain_format = wis::DataFormat::BGRA8Unorm; wis::RootSignature root_signature{}; wis::Pipeline pipeline{}; - FrameContext frames[FRAMES_IN_FLIGHT] {}; + FrameContext frames[FRAMES_IN_FLIGHT]{}; uint32_t frame_index = 0; uint32_t width = 800; @@ -206,8 +206,8 @@ static bool init_app(HelloTriangleApp* app, SDL_Window* window) } app->swapchain_format = app->device.GetFormatPresentationSupport(surface.GetView(), wis::DataFormat::RGB10A2Unorm) - ? wis::DataFormat::RGB10A2Unorm - : wis::DataFormat::BGRA8Unorm; + ? wis::DataFormat::RGB10A2Unorm + : wis::DataFormat::BGRA8Unorm; wis::SwapchainDesc swapchain_desc = { .width = app->width, @@ -340,7 +340,7 @@ static void draw_frame(HelloTriangleApp* app, float angle) wis::Texture& target_texture = app->swapchain_textures[swapchain_index]; uint64_t target_rtv = app->rtv_heap.GetViewAddress(swapchain_index); - wis::TextureBarrier barriers[2] {}; + wis::TextureBarrier barriers[2]{}; barriers[0].sync_before = wis::BarrierSync::None; barriers[0].sync_after = wis::BarrierSync::RenderTarget; barriers[0].access_before = wis::ResourceAccess::None; diff --git a/generator/bitmask.cpp b/generator/bitmask.cpp index 0c529fed6..2692c5cac 100644 --- a/generator/bitmask.cpp +++ b/generator/bitmask.cpp @@ -53,7 +53,7 @@ void Generator::ParseBitmask(tinyxml2::XMLElement* type) } for (auto* impl_type = type->FirstChildElement("impl_type"); impl_type; - impl_type = impl_type->NextSiblingElement("impl_type")) { + impl_type = impl_type->NextSiblingElement("impl_type")) { auto impl_for = impl_type->FindAttribute("for")->Value(); auto backend = ParseBackend(impl_for); auto impl_name = impl_type->FindAttribute("name")->Value(); @@ -114,11 +114,11 @@ std::string Generator::MakeCBitmask(const WisBitmask& s, DocKind kind) for (auto& m : s.values) { if (m.is_bit) { st_decl += MakeValueDocumentation( - s, - m, - std::format(" Wis{}{} = (1u << {}),", s.name, m.name, m.value_or_bit), - kind - ); + s, + m, + std::format(" Wis{}{} = (1u << {}),", s.name, m.name, m.value_or_bit), + kind + ); continue; } st_decl += MakeValueDocumentation(s, m, std::format(" Wis{}{} = {},", s.name, m.name, m.value_or_bit), kind); @@ -139,11 +139,11 @@ std::string Generator::MakeCPPBitmask(const WisBitmask& s, DocKind kind) for (auto& m : s.values) { if (m.is_bit) { st_decl += MakeValueDocumentation( - s, - m, - std::format(" {} = (1u << {}),", m.name, m.value_or_bit), - kind - ); + s, + m, + std::format(" {} = (1u << {}),", m.name, m.value_or_bit), + kind + ); continue; } st_decl += MakeValueDocumentation(s, m, std::format(" {} = {},", m.name, m.value_or_bit), kind); @@ -210,19 +210,19 @@ std::string Generator::MakeBitmaskConverter(const WisBitmask& s, Backend backend if (cvt.direct) { converters = std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", - cvt.value, - backend_tag, - GetCFullTypename(s.name, backend), - cvt.value - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", + cvt.value, + backend_tag, + GetCFullTypename(s.name, backend), + cvt.value + ); } else { converters = std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n", - cvt.value, - backend_tag, - GetCFullTypename(s.name, backend) - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n", + cvt.value, + backend_tag, + GetCFullTypename(s.name, backend) + ); // Start with default value converters += std::format(" {} result = static_cast<{}>(0);\n", cvt.value, cvt.value); @@ -233,12 +233,12 @@ std::string Generator::MakeBitmaskConverter(const WisBitmask& s, Backend backend continue; } converters += std::format( - " if (value & {}{}) {{ result = static_cast<{}>(result | {}); }}\n", - GetCFullTypename(s.name, backend), - m.name, - cvt.value, - convert_value - ); + " if (value & {}{}) {{ result = static_cast<{}>(result | {}); }}\n", + GetCFullTypename(s.name, backend), + m.name, + cvt.value, + convert_value + ); } } else { for (auto& m : s.values) { @@ -247,11 +247,11 @@ std::string Generator::MakeBitmaskConverter(const WisBitmask& s, Backend backend continue; } converters += std::format( - " if (value & {}{}) {{ result |= {}; }}\n", - GetCFullTypename(s.name, backend), - m.name, - convert_value - ); + " if (value & {}{}) {{ result |= {}; }}\n", + GetCFullTypename(s.name, backend), + m.name, + convert_value + ); } } @@ -261,19 +261,19 @@ std::string Generator::MakeBitmaskConverter(const WisBitmask& s, Backend backend if (cvt.convert_back) { if (cvt.direct) { converters += std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", - wisdom_type, - backend_tag, - cvt.value, - wisdom_type - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", + wisdom_type, + backend_tag, + cvt.value, + wisdom_type + ); } else { converters += std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n", - wisdom_type, - backend_tag, - cvt.value - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n", + wisdom_type, + backend_tag, + cvt.value + ); converters += std::format(" {} result = static_cast<{}>(0);\n", wisdom_type, wisdom_type); for (auto& m : s.values) { @@ -282,12 +282,12 @@ std::string Generator::MakeBitmaskConverter(const WisBitmask& s, Backend backend continue; } converters += std::format( - " if (value & {}) {{ result = static_cast<{}>(result | {}{}); }}\n", - convert_value, - wisdom_type, - wisdom_type, - m.name - ); + " if (value & {}) {{ result = static_cast<{}>(result | {}{}); }}\n", + convert_value, + wisdom_type, + wisdom_type, + m.name + ); } converters += std::format(" return result;\n}}\n\n"); @@ -310,11 +310,11 @@ void Generator::WriteBitmaskDocumentation(std::filesystem::path enum_output_path files.push_back(enum_file_path); std::string enum_template_content = std::format( - " * C version:\n```c\n{}```\n" - "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", - MakeCBitmask(enum_ref, DocKind::VersionOnly), - MakeCPPBitmask(enum_ref, DocKind::VersionOnly) - ); + " * C version:\n```c\n{}```\n" + "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", + MakeCBitmask(enum_ref, DocKind::VersionOnly), + MakeCPPBitmask(enum_ref, DocKind::VersionOnly) + ); std::string enum_description = std::format(" * {}", MakeBitmaskDescription(enum_ref)); std::string enum_refs = GetRefs(enum_name); ReplaceAll(enum_template_content, "\n", "\n * "); diff --git a/generator/entry_main.cpp b/generator/entry_main.cpp index 5d47afa08..5e0c425b5 100644 --- a/generator/entry_main.cpp +++ b/generator/entry_main.cpp @@ -49,10 +49,10 @@ int main(int argc, char** argv) std::string_view arg = argv[1]; if (arg == "-h" || arg == "--help") { std::cout - << "Usage: " << argv[0] << " [module_name,...]\n" - << "If module_name is provided, generates API for that platform module. Otherwise, generates core API.\n" - << "Modules are stored in xml folder. For example, if module_name is 'platform', the generator will look " - "for 'xml/platform.xml' and generate API for it.\n"; + << "Usage: " << argv[0] << " [module_name,...]\n" + << "If module_name is provided, generates API for that platform module. Otherwise, generates core API.\n" + << "Modules are stored in xml folder. For example, if module_name is 'platform', the generator will look " + "for 'xml/platform.xml' and generate API for it.\n"; return 0; } @@ -64,7 +64,7 @@ int main(int argc, char** argv) size_t next_comma = arg.find(',', i); std::string_view platform_module_name = arg.substr(i, next_comma - i); auto module_path = std::filesystem::path(input_file).parent_path() - / (std::string(platform_module_name) + std::string(".xml")); + / (std::string(platform_module_name) + std::string(".xml")); g.ParseFile(module_path); g.WriteModuleAPI(); diff --git a/generator/enum.cpp b/generator/enum.cpp index e5933d53b..a301b5cdd 100644 --- a/generator/enum.cpp +++ b/generator/enum.cpp @@ -53,7 +53,7 @@ void Generator::ParseEnum(tinyxml2::XMLElement* type) } for (auto* impl_type = type->FirstChildElement("impl_type"); impl_type; - impl_type = impl_type->NextSiblingElement("impl_type")) { + impl_type = impl_type->NextSiblingElement("impl_type")) { auto impl_for = impl_type->FindAttribute("for")->Value(); auto backend = ParseBackend(impl_for); auto impl_name = impl_type->FindAttribute("name")->Value(); @@ -145,11 +145,11 @@ void Generator::WriteEnumDocumentation(std::filesystem::path enum_output_path) files.push_back(enum_file_path); std::string enum_template_content = std::format( - " * C version:\n```c\n{}```\n" - "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", - MakeCEnum(enum_ref, DocKind::VersionOnly), - MakeCPPEnum(enum_ref, DocKind::VersionOnly) - ); + " * C version:\n```c\n{}```\n" + "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", + MakeCEnum(enum_ref, DocKind::VersionOnly), + MakeCPPEnum(enum_ref, DocKind::VersionOnly) + ); std::string enum_description = std::format(" * {}", MakeEnumDescription(enum_ref)); std::string enum_refs = GetRefs(enum_name); ReplaceAll(enum_template_content, "\n", "\n * "); @@ -192,11 +192,11 @@ std::string Generator::MakeEnumDescription(const WisEnum& s) } translates += std::format( - "{} `{}` for {} implementation", - has_translate ? ", and" : "", - cvt.value, - impl_names[i] - ); + "{} `{}` for {} implementation", + has_translate ? ", and" : "", + cvt.value, + impl_names[i] + ); has_translate = true; } if (has_translate) { @@ -223,29 +223,29 @@ std::string Generator::MakeEnumConverter(const WisEnum& s, Backend backend) if (cvt.direct) { converters = std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", - cvt.value, - backend_tag, - GetCFullTypename(s.name, backend), - cvt.value - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", + cvt.value, + backend_tag, + GetCFullTypename(s.name, backend), + cvt.value + ); } else { converters = std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n switch(value) {{\n", - cvt.value, - backend_tag, - GetCFullTypename(s.name, backend) - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n switch(value) {{\n", + cvt.value, + backend_tag, + GetCFullTypename(s.name, backend) + ); for (auto& m : s.values) { auto convert_value = m.converts[static_cast(backend)]; if (convert_value.empty()) { continue; } converters += std::format( - " case {}: return {};\n", - std::format("{}{}", GetCFullTypename(s.name, backend), m.name), - convert_value - ); + " case {}: return {};\n", + std::format("{}{}", GetCFullTypename(s.name, backend), m.name), + convert_value + ); } if (!cvt.default_value.empty()) { @@ -258,19 +258,19 @@ std::string Generator::MakeEnumConverter(const WisEnum& s, Backend backend) if (cvt.convert_back) { if (cvt.direct) { converters += std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", - wisdom_type, - backend_tag, - cvt.value, - wisdom_type - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n return static_cast<{}>(value);\n}}\n\n", + wisdom_type, + backend_tag, + cvt.value, + wisdom_type + ); } else { converters += std::format( - "constexpr inline {} {}Convert({} value) noexcept {{\n", - wisdom_type, - backend_tag, - cvt.value - ); + "constexpr inline {} {}Convert({} value) noexcept {{\n", + wisdom_type, + backend_tag, + cvt.value + ); for (auto& m : s.values) { auto convert_value = m.converts[static_cast(backend)]; @@ -278,11 +278,11 @@ std::string Generator::MakeEnumConverter(const WisEnum& s, Backend backend) continue; } converters += std::format( - " if (value == {}) {{ return {}{}; }}\n", - convert_value, - wisdom_type, - m.name - ); + " if (value == {}) {{ return {}{}; }}\n", + convert_value, + wisdom_type, + m.name + ); } converters += std::format(" return static_cast<{}>(0);\n}}\n\n", wisdom_type); diff --git a/generator/function.cpp b/generator/function.cpp index 6f3005ad7..3ecc1284c 100644 --- a/generator/function.cpp +++ b/generator/function.cpp @@ -196,8 +196,8 @@ std::string Generator::MakeCFunctionProto( } else if (func.return_type.has_result) { full_return_type = GetCFullTypename("Result", Backend::Any); std::string arg_name = func.return_type.opt_name.empty() - ? std::format("out_{}", MakeSnakeCase(func.return_type.type)) - : std::string(func.return_type.opt_name); + ? std::format("out_{}", MakeSnakeCase(func.return_type.type)) + : std::string(func.return_type.opt_name); std::string prefix = ""; size_t length = full_return_type.size() + 1 + pre_decl.size() + 1 + function_full_name.size(); @@ -262,14 +262,14 @@ std::string Generator::MakeCFunctionProto( } return std::format( - "{}{} {}({}{}{});\n", - pre_decl, - full_return_type, - function_full_name, - this_arg, - params.empty() && !post_return.empty() ? ",\n" : params.c_str(), - post_return - ); + "{}{} {}({}{}{});\n", + pre_decl, + full_return_type, + function_full_name, + this_arg, + params.empty() && !post_return.empty() ? ",\n" : params.c_str(), + post_return + ); } //---------------------------------------------------------------------------------------------------------------------- @@ -305,23 +305,23 @@ std::string Generator::MakeCPPFunctionProto( break; case Direct: full_return_type = GetMemberTypeString( - func.return_type, - type != ProtoType::Universal ? backend : Backend::Any - ); + func.return_type, + type != ProtoType::Universal ? backend : Backend::Any + ); break; case ResultOnly: full_return_type = "wis::Result"; break; case ResultAndValue: full_return_type = GetMemberTypeString( - func.return_type, - type != ProtoType::Universal ? backend : Backend::Any - ); + func.return_type, + type != ProtoType::Universal ? backend : Backend::Any + ); // Add out parameter for result { std::string prefix = ""; size_t length = full_return_type.size() + 1 + pre_decl.size() + 1 + func.name.size() + func_prefix.size() - + xclass_code.size(); + + xclass_code.size(); if (func.parameters.size() > 0) { prefix = ",\n" + std::string(length, ' '); } @@ -336,7 +336,7 @@ std::string Generator::MakeCPPFunctionProto( } size_t length = full_return_type.size() + 1 + pre_decl.size() + 1 + func.name.size() + func_prefix.size() - + xclass_code.size(); + + xclass_code.size(); size_t max_arg_length = post_return_length; // account for spans @@ -390,27 +390,27 @@ std::string Generator::MakeCPPFunctionProto( } if ((func.modifier & Modifier::Construct) != 0) { return std::format( - "{}{}{}{}({}{}){} noexcept;\n", - func_prefix, - xclass_code, - func_prefix, - std::string_view(xclass_code.begin(), xclass_code.end() - 2), - params, - post_return, - func.modifier & Modifier::Const ? " const" : "" - ); + "{}{}{}{}({}{}){} noexcept;\n", + func_prefix, + xclass_code, + func_prefix, + std::string_view(xclass_code.begin(), xclass_code.end() - 2), + params, + post_return, + func.modifier & Modifier::Const ? " const" : "" + ); } return std::format( - "{}{} {}{}{}({}{}){} noexcept;\n", - pre_decl, - full_return_type, - func_prefix, - xclass_code, - func.name, - params, - post_return, - func.modifier & Modifier::Const ? " const" : "" - ); + "{}{} {}{}{}({}{}){} noexcept;\n", + pre_decl, + full_return_type, + func_prefix, + xclass_code, + func.name, + params, + post_return, + func.modifier & Modifier::Const ? " const" : "" + ); } //---------------------------------------------------------------------------------------------------------------------- @@ -482,17 +482,21 @@ std::string Generator::MakeCPPFunctionImpl( switch (func.return_type.GetKind()) { case ReturnTypeKind::ResultAndValue: { auto ret_value_name = func.return_type.opt_name.empty() - ? std::format("out_{}", MakeSnakeCase(func.return_type.type)) - : std::string(func.return_type.opt_name); + ? std::format("out_{}", MakeSnakeCase(func.return_type.type)) + : std::string(func.return_type.opt_name); // Prepare out parameter - body += std::format(" {} {}{{}};\n", GetMemberTypeString(func.return_type, backend), ret_value_name); + body += std::format( + " {} {}{{}};\n", + GetMemberTypeString(func.return_type, backend), + ret_value_name + ); body += std::format( - " const WisResult wis_result = ::{}({}", - c_name, - func.this_type.empty() ? "" : "&_impl_storage" - ); + " const WisResult wis_result = ::{}({}", + c_name, + func.this_type.empty() ? "" : "&_impl_storage" + ); if (func.parameters.size() > 0 && !func.this_type.empty()) { body += arg_prefix; @@ -506,22 +510,21 @@ std::string Generator::MakeCPPFunctionImpl( body += std::format(", {}.GetStorage());\n", ret_value_name); } else { body += std::format( - ", reinterpret_cast<{}*>(&{}));\n", - GetMemberTypeString(func.return_type, backend), - ret_value_name - ); + ", reinterpret_cast<{}*>(&{}));\n", + GetMemberTypeString(func.return_type, backend), + ret_value_name + ); } body += " out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, " "wis_result.error };\n"; body += std::format(" return {};\n", ret_value_name); - } - break; + } break; case ReturnTypeKind::ResultOnly: { body += std::format( - " const WisResult wis_result = ::{}({}", - c_name, - func.this_type.empty() ? "" : "&_impl_storage" - ); + " const WisResult wis_result = ::{}({}", + c_name, + func.this_type.empty() ? "" : "&_impl_storage" + ); constexpr static std::string_view arg_prefix = ",\n "; if (func.parameters.size() > 0 && !func.this_type.empty()) { body += arg_prefix; @@ -530,8 +533,7 @@ std::string Generator::MakeCPPFunctionImpl( body += ");\n"; body += " return wis::Result{ static_cast(wis_result.status), wis_result.platform_code, " "wis_result.error };\n"; - } - break; + } break; case ReturnTypeKind::Direct: { auto ret_type = GetType(func.return_type.type); std::string return_cast; @@ -549,26 +551,25 @@ std::string Generator::MakeCPPFunctionImpl( break; default: return_cast = std::format( - "reinterpret_cast<{}>", - GetMemberTypeString(func.return_type, backend) - ); + "reinterpret_cast<{}>", + GetMemberTypeString(func.return_type, backend) + ); break; } body += std::format( - " return {}(::{}({}", - return_cast, - c_name, - func.this_type.empty() ? "" : "&_impl_storage" - ); + " return {}(::{}({}", + return_cast, + c_name, + func.this_type.empty() ? "" : "&_impl_storage" + ); constexpr static std::string_view arg_prefix = ",\n "; if (func.parameters.size() > 0 && !func.this_type.empty()) { body += arg_prefix; } body += GetFunctionCallParameters(func, backend); body += "));\n"; - } - break; + } break; case ReturnTypeKind::Void: { body += std::format(" ::{}({}", c_name, func.this_type.empty() ? "" : "&_impl_storage"); constexpr static std::string_view arg_prefix = ",\n "; @@ -577,8 +578,7 @@ std::string Generator::MakeCPPFunctionImpl( } body += GetFunctionCallParameters(func, backend); body += ");\n"; - } - break; + } break; default: break; } @@ -619,18 +619,18 @@ std::string Generator::MakeFunctionDescription(const WisFunction& s) if (!s.this_type.empty()) { if (s.modifier & Modifier::Construct) { description += std::format( - "- **this** `self` is a pointer to uninitialized {{{}::}} instance memory. It will be initialized by " - "this function.\n", - s.this_type - ); + "- **this** `self` is a pointer to uninitialized {{{}::}} instance memory. It will be initialized by " + "this function.\n", + s.this_type + ); // There must also be a note about the destroy function in the description description += std::format("**note** The corresponding destroy function is `wisDestroy{}`.\n", s.this_type); } else { description += std::format( - "- **this** `self` self is a pointer to the valid {{{}::}} instance.\n", - s.this_type - ); + "- **this** `self` self is a pointer to the valid {{{}::}} instance.\n", + s.this_type + ); } } @@ -641,21 +641,21 @@ std::string Generator::MakeFunctionDescription(const WisFunction& s) switch (s.return_type.GetKind()) { case ReturnTypeKind::Direct: description += std::format( - "\n- **return** {}\n", - s.return_type.doc.empty() ? "No description." : s.return_type.doc - ); + "\n- **return** {}\n", + s.return_type.doc.empty() ? "No description." : s.return_type.doc + ); break; case ReturnTypeKind::ResultOnly: description += std::format("\n- **return** denoting the outcome of operation.\n"); break; case ReturnTypeKind::ResultAndValue: { std::string arg_name = s.return_type.opt_name.empty() ? std::format("out_{}", MakeSnakeCase(s.return_type.type)) - : std::string(s.return_type.opt_name); + : std::string(s.return_type.opt_name); description += std::format( - "- `{}` {}\n", - s.return_type.opt_name.empty() ? "value" : s.return_type.opt_name, - s.return_type.doc.empty() ? "No description." : s.return_type.doc - ); + "- `{}` {}\n", + s.return_type.opt_name.empty() ? "value" : s.return_type.opt_name, + s.return_type.doc.empty() ? "No description." : s.return_type.doc + ); description += std::format("\n- **return** denoting the outcome of operation.\n"); break; } @@ -684,10 +684,10 @@ void Generator::WriteFunctionDocumentation(std::filesystem::path func_output_pat for (auto& func_name : function_names) { auto& func_def = function_map[func_name]; std::string full_func_name = std::format( - "wis{}{}", - func_def.modifier & (Destroy | Construct) ? "" : func_def.this_type, - func_def.name - ); + "wis{}{}", + func_def.modifier & (Destroy | Construct) ? "" : func_def.this_type, + func_def.name + ); auto func_doc_path = func_output_path / std::format("{}_function.h", MakeSnakeCase(full_func_name.substr(3))); files.push_back(func_doc_path); @@ -705,18 +705,18 @@ void Generator::WriteFunctionDocumentation(std::filesystem::path func_output_pat } std::string vk_code_cpp = func_def.modifier & Modifier::Destroy || !supports_vk - ? "" - : MakeCPPFunctionImpl(func_def, Backend::Vulkan, "", DocKind::VersionOnly); + ? "" + : MakeCPPFunctionImpl(func_def, Backend::Vulkan, "", DocKind::VersionOnly); std::string dx_code_cpp = func_def.modifier & Modifier::Destroy || !supports_dx - ? "" - : MakeCPPFunctionImpl(func_def, Backend::DX12, "", DocKind::VersionOnly); + ? "" + : MakeCPPFunctionImpl(func_def, Backend::DX12, "", DocKind::VersionOnly); std::string regular_code_cpp = func_def.modifier & Modifier::Destroy || !(supports_vk && supports_dx) - ? "" - : MakeCPPFunctionImpl(func_def, Backend::Any, "", DocKind::VersionOnly); + ? "" + : MakeCPPFunctionImpl(func_def, Backend::Any, "", DocKind::VersionOnly); std::string cpp_code = regular_code_cpp; std::string cpp_impl_code = func_def.modifier & Modifier::Destroy || !(supports_vk && supports_dx) - ? "" - : vk_code_cpp + '\n' + dx_code_cpp; + ? "" + : vk_code_cpp + '\n' + dx_code_cpp; if (cpp_code.empty()) { cpp_code = !vk_code_cpp.empty() ? vk_code_cpp : dx_code_cpp; } @@ -749,7 +749,7 @@ void Generator::WriteDelegateDocumentation(std::filesystem::path func_output_pat for (auto& delegate_name : module_map.at(active_module_name).delegates_in_order) { auto full_delegate_name = GetCFullTypename(delegate_name, Backend::Any); auto delegate_doc_path = func_output_path - / std::format("{}_delegate.h", MakeSnakeCase(full_delegate_name.substr(3))); + / std::format("{}_delegate.h", MakeSnakeCase(full_delegate_name.substr(3))); auto& delegate_def = delegate_map[delegate_name]; files.push_back(delegate_doc_path); diff --git a/generator/generator.cpp b/generator/generator.cpp index 9048e3007..1f454c7f3 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp @@ -18,7 +18,7 @@ void Generator::ParseFile(std::filesystem::path file) bool has_modules = false; for (auto* module_node = root->FirstChildElement("module"); module_node; - module_node = module_node->NextSiblingElement("module")) { + module_node = module_node->NextSiblingElement("module")) { has_modules = true; auto* module_attr = module_node->FindAttribute("name"); @@ -140,7 +140,7 @@ void Generator::ParseRegistrySections(tinyxml2::XMLElement* root) void Generator::ParseIncludes(tinyxml2::XMLElement* includes) { for (auto* include = includes->FirstChildElement("include"); include; - include = include->NextSiblingElement("include")) { + include = include->NextSiblingElement("include")) { auto file = include->GetText(); auto rpath = std::filesystem::path(INPUT_FILE).parent_path() / file; auto absolute = std::filesystem::absolute(rpath); @@ -185,8 +185,8 @@ void Generator::WriteCAPI(std::filesystem::path dir) auto& module = module_map.at(active_module_name); bool has_independent_api = !module.enums_in_order.empty() || !module.bitmasks_in_order.empty() - || !module.structs_in_order.empty() || !module.constants_in_order.empty() - || !module.delegates_in_order.empty() || !module.functions_in_order.empty(); + || !module.structs_in_order.empty() || !module.constants_in_order.empty() + || !module.delegates_in_order.empty() || !module.functions_in_order.empty(); auto path = dir / "c_api.h"; if (!has_independent_api) { @@ -207,11 +207,12 @@ void Generator::WriteCAPI(std::filesystem::path dir) #include #include )" - : R"(#include + : R"(#include #include "wisdom_exports.h" )"; - auto api_macro = module.name == "Core" ? "WIS_INLINE WISDOM_API " : std::format("WIS_INLINE WISDOM_{}_API ", header_guard); + auto api_macro = module.name == "Core" ? "WIS_INLINE WISDOM_API " + : std::format("WIS_INLINE WISDOM_{}_API ", header_guard); // Write header // clang-format off @@ -228,8 +229,8 @@ extern "C" {{ if (!module.enums_in_order.empty() || !module.bitmasks_in_order.empty()) { file << "\n//==============================================================\n" - "// Enums\n" - "//==============================================================\n\n"; + "// Enums\n" + "//==============================================================\n\n"; // Write enums for (auto& enum_name : module.enums_in_order) { @@ -248,8 +249,8 @@ extern "C" {{ if (!module.delegates_in_order.empty()) { file << "\n//==============================================================\n" - "// Delegates\n" - "//==============================================================\n\n"; + "// Delegates\n" + "//==============================================================\n\n"; // Write delegates (before structs, as structs may reference delegates) for (auto& delegate_name : module.delegates_in_order) { auto& delegate_def = delegate_map[delegate_name]; @@ -260,8 +261,8 @@ extern "C" {{ if (!module.structs_in_order.empty()) { file << "\n//==============================================================\n" - "// Structs\n" - "//==============================================================\n\n"; + "// Structs\n" + "//==============================================================\n\n"; // Write structs for (auto& struct_name : module.structs_in_order) { auto& struct_def = struct_map[struct_name]; @@ -272,8 +273,8 @@ extern "C" {{ if (!module.constants_in_order.empty()) { file << "\n//==============================================================\n" - "// Constants\n" - "//==============================================================\n\n"; + "// Constants\n" + "//==============================================================\n\n"; // Write constants for (auto& const_name : module.constants_in_order) { auto& const_def = constant_map[const_name]; @@ -367,8 +368,8 @@ void Generator::WriteCPPAPI(std::filesystem::path dir) { auto& module = module_map.at(active_module_name); bool has_independent_api = !module.enums_in_order.empty() || !module.bitmasks_in_order.empty() - || !module.structs_in_order.empty() || !module.constants_in_order.empty() - || !module.delegates_in_order.empty() || !module.functions_in_order.empty(); + || !module.structs_in_order.empty() || !module.constants_in_order.empty() + || !module.delegates_in_order.empty() || !module.functions_in_order.empty(); auto path = dir / "cpp_api.hpp"; if (!has_independent_api) { @@ -389,7 +390,7 @@ void Generator::WriteCPPAPI(std::filesystem::path dir) #include #include "c_api.h" )" - : R"(#include + : R"(#include #include "wisdom_exports.h" #include "c_api.h" )"; @@ -411,8 +412,8 @@ namespace wis {{ if (!module.enums_in_order.empty() || !module.bitmasks_in_order.empty()) { file << "\n//==============================================================\n" - "// Enums\n" - "//==============================================================\n\n"; + "// Enums\n" + "//==============================================================\n\n"; // Write enums for (auto& enum_name : module.enums_in_order) { @@ -431,8 +432,8 @@ namespace wis {{ if (!module.delegates_in_order.empty()) { file << "\n//==============================================================\n" - "// Delegates\n" - "//==============================================================\n\n"; + "// Delegates\n" + "//==============================================================\n\n"; // Write delegates (before structs, as structs may reference delegates) for (auto& delegate_name : module.delegates_in_order) { auto& delegate_def = delegate_map[delegate_name]; @@ -443,8 +444,8 @@ namespace wis {{ if (!module.structs_in_order.empty()) { file << "\n//==============================================================\n" - "// Structs\n" - "//==============================================================\n\n"; + "// Structs\n" + "//==============================================================\n\n"; // Write structs for (auto& struct_name : module.structs_in_order) { auto& struct_def = struct_map[struct_name]; @@ -455,8 +456,8 @@ namespace wis {{ if (!module.constants_in_order.empty()) { file << "\n//==============================================================\n" - "// Constants\n" - "//==============================================================\n\n"; + "// Constants\n" + "//==============================================================\n\n"; // Write constants for (auto& const_name : module.constants_in_order) { auto& const_def = constant_map[const_name]; @@ -466,7 +467,7 @@ namespace wis {{ } file << std::format( - R"( + R"( }} // namespace wis #ifdef WISDOM_DX12 @@ -474,8 +475,8 @@ namespace wis {{ namespace wis {{ )", - include_root - ); + include_root + ); // Write Views for handles for (auto& handle_name : module.views_in_order) { @@ -516,7 +517,7 @@ namespace wis {{ } file << std::format( - R"( + R"( }} // namespace wis #endif // WISDOM_DX12 @@ -525,8 +526,8 @@ namespace wis {{ namespace wis {{ )", - include_root - ); + include_root + ); // Write Views for handles for (auto& handle_name : module.views_in_order) { @@ -584,14 +585,14 @@ void Generator::WriteCIndependentAPI(std::filesystem::path dir) auto& module = module_map.at(active_module_name); auto independent_name = module.name == "Core" ? std::string("wisdom") - : std::format("wisdom_{}", MakeSnakeCase(module.name)); + : std::format("wisdom_{}", MakeSnakeCase(module.name)); auto module_folder = std::filesystem::path(module.gen_path).filename().generic_string(); if (module_folder.empty()) { module_folder = std::filesystem::path(module.gen_path).parent_path().filename().generic_string(); } auto backend_include = module_folder == "wisdom" ? std::string("generated/c_api.h") - : std::format("../{}/generated/c_api.h", module_folder); + : std::format("../{}/generated/c_api.h", module_folder); auto header_guard = std::format("WISDOM_{}_H", MakeUpperSnakeCase(module.name)); std::filesystem::path path_w = dir / (independent_name + ".h"); @@ -604,7 +605,7 @@ void Generator::WriteCIndependentAPI(std::filesystem::path dir) // Write header file_w << std::format( - R"(// This file is generated. Do not edit directly. + R"(// This file is generated. Do not edit directly. #ifndef {0} #define {0} @@ -624,9 +625,9 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); #if defined(WISDOM_DX12) && !FORCEVK_SWITCH )", - header_guard, - backend_include - ); + header_guard, + backend_include + ); constexpr static auto impl_dx = GetBackendSuffix(Backend::DX12); constexpr static auto impl_vk = GetBackendSuffix(Backend::Vulkan); @@ -660,18 +661,18 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); if (dx_has_handles) { file_w << "\n\n//==============================================================\n" - "// Handles\n" - "//==============================================================\n\n"; + "// Handles\n" + "//==============================================================\n\n"; // Write handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::DX12)) { file_w << std::format( - "typedef struct {} {};\n", - GetCFullTypename(handle_def.name, Backend::DX12), - GetCFullTypename(handle_def.name) - ); + "typedef struct {} {};\n", + GetCFullTypename(handle_def.name, Backend::DX12), + GetCFullTypename(handle_def.name) + ); } } @@ -680,46 +681,46 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); auto& handle_def = handle_map[handle_name]; if (handle_def.GetViewSize(Backend::DX12) > 0) { file_w << std::format( - "typedef struct {}View {}View;\n", - GetCFullTypename(handle_def.name, Backend::DX12), - GetCFullTypename(handle_def.name) - ); + "typedef struct {}View {}View;\n", + GetCFullTypename(handle_def.name, Backend::DX12), + GetCFullTypename(handle_def.name) + ); } } } if (dx_has_variants) { file_w << "\n\n//==============================================================\n" - "// Variants\n" - "//==============================================================\n\n"; + "// Variants\n" + "//==============================================================\n\n"; // Write variants for (auto& variant_name : module.variants_in_order) { auto& variant_def = variant_map[variant_name]; if (has(variant_def.backend, Backend::DX12)) { file_w << std::format( - "typedef struct {} {};\n", - GetCFullTypename(variant_def.name, Backend::DX12), - GetCFullTypename(variant_def.name) - ); + "typedef struct {} {};\n", + GetCFullTypename(variant_def.name, Backend::DX12), + GetCFullTypename(variant_def.name) + ); } } } file_w << "\n\n//==============================================================\n" - "// Functions\n" - "//==============================================================\n\n"; + "// Functions\n" + "//==============================================================\n\n"; // Write view getters for handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::DX12) && handle_def.GetViewSize(Backend::DX12) > 0) { file_w << std::format( - "#define wisGet{}View wisGet{}{}View\n", - handle_def.name, - GetBackendSuffix(Backend::DX12), - handle_def.name - ); + "#define wisGet{}View wisGet{}{}View\n", + handle_def.name, + GetBackendSuffix(Backend::DX12), + handle_def.name + ); } } @@ -728,10 +729,10 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); auto& func_def = function_map[func_name]; if (has(func_def.backend, Backend::DX12)) { file_w << std::format( - "#define {} {}\n", - GetCFullFunctionName(func_name), - GetCFullFunctionName(func_name, Backend::DX12) - ); + "#define {} {}\n", + GetCFullFunctionName(func_name), + GetCFullFunctionName(func_name, Backend::DX12) + ); } } @@ -769,18 +770,18 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); if (vk_has_handles) { file_w << "\n\n//==============================================================\n" - "// Handles\n" - "//==============================================================\n\n"; + "// Handles\n" + "//==============================================================\n\n"; // Write handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::Vulkan)) { file_w << std::format( - "typedef struct {} {};\n", - GetCFullTypename(handle_def.name, Backend::Vulkan), - GetCFullTypename(handle_def.name) - ); + "typedef struct {} {};\n", + GetCFullTypename(handle_def.name, Backend::Vulkan), + GetCFullTypename(handle_def.name) + ); } } @@ -789,46 +790,46 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); auto& handle_def = handle_map[handle_name]; if (handle_def.GetViewSize(Backend::Vulkan) > 0) { file_w << std::format( - "typedef struct {}View {}View;\n", - GetCFullTypename(handle_def.name, Backend::Vulkan), - GetCFullTypename(handle_def.name) - ); + "typedef struct {}View {}View;\n", + GetCFullTypename(handle_def.name, Backend::Vulkan), + GetCFullTypename(handle_def.name) + ); } } } if (vk_has_variants) { file_w << "\n\n//==============================================================\n" - "// Variants\n" - "//==============================================================\n\n"; + "// Variants\n" + "//==============================================================\n\n"; // Write variants for (auto& variant_name : module.variants_in_order) { auto& variant_def = variant_map[variant_name]; if (has(variant_def.backend, Backend::Vulkan)) { file_w << std::format( - "typedef struct {} {};\n", - GetCFullTypename(variant_def.name, Backend::Vulkan), - GetCFullTypename(variant_def.name) - ); + "typedef struct {} {};\n", + GetCFullTypename(variant_def.name, Backend::Vulkan), + GetCFullTypename(variant_def.name) + ); } } } file_w << "\n\n//==============================================================\n" - "// Functions\n" - "//==============================================================\n\n"; + "// Functions\n" + "//==============================================================\n\n"; // Write view getters for handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::Vulkan) && handle_def.GetViewSize(Backend::Vulkan) > 0) { file_w << std::format( - "#define wisGet{}View wisGet{}{}View\n", - handle_def.name, - GetBackendSuffix(Backend::Vulkan), - handle_def.name - ); + "#define wisGet{}View wisGet{}{}View\n", + handle_def.name, + GetBackendSuffix(Backend::Vulkan), + handle_def.name + ); } } @@ -837,10 +838,10 @@ static_assert(WISDOM_UWP && _WIN32, "Platform error"); auto& func_def = function_map[func_name]; if (has(func_def.backend, Backend::Vulkan)) { file_w << std::format( - "#define {} {}\n", - GetCFullFunctionName(func_name), - GetCFullFunctionName(func_name, Backend::Vulkan) - ); + "#define {} {}\n", + GetCFullFunctionName(func_name), + GetCFullFunctionName(func_name, Backend::Vulkan) + ); } } @@ -868,14 +869,14 @@ void Generator::WriteCPPIndependentAPI(std::filesystem::path dir) auto& module = module_map.at(active_module_name); auto independent_name = module.name == "Core" ? std::string("wisdom") - : std::format("wisdom_{}", MakeSnakeCase(module.name)); + : std::format("wisdom_{}", MakeSnakeCase(module.name)); auto module_folder = std::filesystem::path(module.gen_path).filename().generic_string(); if (module_folder.empty()) { module_folder = std::filesystem::path(module.gen_path).parent_path().filename().generic_string(); } auto backend_include = module_folder == "wisdom" ? std::string("generated/cpp_api.hpp") - : std::format("../{}/generated/cpp_api.hpp", module_folder); + : std::format("../{}/generated/cpp_api.hpp", module_folder); auto header_guard = std::format("WISDOM_{}_HPP", MakeUpperSnakeCase(module.name)); std::filesystem::path path_w = dir / (independent_name + ".hpp"); @@ -888,7 +889,7 @@ void Generator::WriteCPPIndependentAPI(std::filesystem::path dir) // Write header file_w << std::format( - R"(// This file is generated. Do not edit directly. + R"(// This file is generated. Do not edit directly. #ifndef {0} #define {0} @@ -910,9 +911,9 @@ void Generator::WriteCPPIndependentAPI(std::filesystem::path dir) namespace wis {{ )", - header_guard, - backend_include - ); + header_guard, + backend_include + ); if (module.name == "Core") { file_w << "static constexpr wis::ShaderIntermediate shader_intermediate = wis::ShaderIntermediate::DXIL;\n"; @@ -953,18 +954,18 @@ namespace wis {{ if (dx_has_handles) { file_w << "\n\n//==============================================================\n" - "// Handles\n" - "//==============================================================\n\n"; + "// Handles\n" + "//==============================================================\n\n"; // Write handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::DX12)) { file_w << std::format( - "using {} = {};\n", - handle_def.name, - GetCPPFullTypename(handle_def.name, Backend::DX12) - ); + "using {} = {};\n", + handle_def.name, + GetCPPFullTypename(handle_def.name, Backend::DX12) + ); } } @@ -973,36 +974,36 @@ namespace wis {{ auto& handle_def = handle_map[handle_name]; if (handle_def.GetViewSize(Backend::DX12) > 0) { file_w << std::format( - "using {}View = {};\n", - handle_def.name, - GetCPPFullTypename(handle_def.name, Backend::DX12) + "View" - ); + "using {}View = {};\n", + handle_def.name, + GetCPPFullTypename(handle_def.name, Backend::DX12) + "View" + ); } } } if (dx_has_variants) { file_w << "\n\n//==============================================================\n" - "// Variants\n" - "//==============================================================\n\n"; + "// Variants\n" + "//==============================================================\n\n"; // Write variants for (auto& variant_name : module.variants_in_order) { auto& variant_def = variant_map[variant_name]; if (has(variant_def.backend, Backend::DX12)) { file_w << std::format( - "using {} = {};\n", - variant_def.name, - GetCPPFullTypename(variant_def.name, Backend::DX12) - ); + "using {} = {};\n", + variant_def.name, + GetCPPFullTypename(variant_def.name, Backend::DX12) + ); } } } if (dx_has_functions) { file_w << "\n\n//==============================================================\n" - "// Functions\n" - "//==============================================================\n\n"; + "// Functions\n" + "//==============================================================\n\n"; // Write functions for (auto& func_name : module.free_functions_in_order) { @@ -1062,18 +1063,18 @@ namespace wis { if (vk_has_handles) { file_w << "\n\n//==============================================================\n" - "// Handles\n" - "//==============================================================\n\n"; + "// Handles\n" + "//==============================================================\n\n"; // Write handles for (auto& handle_name : module.handles_in_order) { auto& handle_def = handle_map[handle_name]; if (has(handle_def.GetBackend(), Backend::Vulkan)) { file_w << std::format( - "using {} = {};\n", - handle_def.name, - GetCPPFullTypename(handle_def.name, Backend::Vulkan) - ); + "using {} = {};\n", + handle_def.name, + GetCPPFullTypename(handle_def.name, Backend::Vulkan) + ); } } @@ -1082,36 +1083,36 @@ namespace wis { auto& handle_def = handle_map[handle_name]; if (handle_def.GetViewSize(Backend::Vulkan) > 0) { file_w << std::format( - "using {}View = {};\n", - handle_def.name, - GetCPPFullTypename(handle_def.name, Backend::Vulkan) + "View" - ); + "using {}View = {};\n", + handle_def.name, + GetCPPFullTypename(handle_def.name, Backend::Vulkan) + "View" + ); } } } if (vk_has_variants) { file_w << "\n\n//==============================================================\n" - "// Variants\n" - "//==============================================================\n\n"; + "// Variants\n" + "//==============================================================\n\n"; // Write variants for (auto& variant_name : module.variants_in_order) { auto& variant_def = variant_map[variant_name]; if (has(variant_def.backend, Backend::Vulkan)) { file_w << std::format( - "using {} = {};\n", - variant_def.name, - GetCPPFullTypename(variant_def.name, Backend::Vulkan) - ); + "using {} = {};\n", + variant_def.name, + GetCPPFullTypename(variant_def.name, Backend::Vulkan) + ); } } } if (vk_has_functions) { file_w << "\n\n//==============================================================\n" - "// Functions\n" - "//==============================================================\n\n"; + "// Functions\n" + "//==============================================================\n\n"; // Write functions for (auto& func_name : module.free_functions_in_order) { @@ -1119,7 +1120,7 @@ namespace wis { auto& func_def = function_map[key]; if (has(func_def.backend, Backend::Vulkan)) { file_w - << MakeCPPFunctionImpl(func_def, Backend::Vulkan, "inline ", DocKind::Full, ProtoType::Universal); + << MakeCPPFunctionImpl(func_def, Backend::Vulkan, "inline ", DocKind::Full, ProtoType::Universal); file_w << '\n'; } } @@ -1160,7 +1161,7 @@ void Generator::WriteConversions(std::filesystem::path dir) // Write header file_dx << std::format( - R"(// This file is generated. Do not edit directly. + R"(// This file is generated. Do not edit directly. #ifndef WISDOM_{0}_CPP_DX12_CONVERT_HPP #define WISDOM_{0}_CPP_DX12_CONVERT_HPP #ifndef __cplusplus @@ -1173,10 +1174,10 @@ void Generator::WriteConversions(std::filesystem::path dir) namespace wis{{ namespace detail {{ )", - header_guard - ); + header_guard + ); file_vk << std::format( - R"(// This file is generated. Do not edit directly. + R"(// This file is generated. Do not edit directly. #ifndef WISDOM_{0}_CPP_VK_CONVERT_HPP #define WISDOM_{0}_CPP_VK_CONVERT_HPP #ifndef __cplusplus @@ -1189,8 +1190,8 @@ namespace wis{{ namespace detail {{ namespace wis{{ namespace detail {{ )", - header_guard - ); + header_guard + ); // Write enums for (auto& enum_name : module.enums_in_order) { @@ -1211,19 +1212,19 @@ namespace wis{{ namespace detail {{ // Write footer file_dx << std::format( - R"( + R"( }}}} #endif // WISDOM_{}_CPP_DX12_CONVERT_HPP )", - header_guard - ); + header_guard + ); file_vk << std::format( - R"( + R"( }}}} #endif // WISDOM_{}_CPP_VK_CONVERT_HPP )", - header_guard - ); + header_guard + ); } void Generator::WriteDocumentation( @@ -1246,9 +1247,9 @@ void Generator::WriteDocumentation( if (!file_exists) { std::string xenum = std::vformat( - doc_template, - std::make_format_args(object_name, code, desc, active_module_name) - ); + doc_template, + std::make_format_args(object_name, code, desc, active_module_name) + ); enum_file << FinalizeCDocumentation(xenum, object_name); enum_file.close(); @@ -1278,22 +1279,22 @@ void Generator::WriteDocumentation( // Replace the references section if (ref_start != std::string::npos && ref_end != std::string::npos && ref_end > ref_start) { existing_content = existing_content.substr(0, ref_start) + "\\cond WIS_GEN_REFS\n" + std::string(refs) - + existing_content.substr(ref_end); + + existing_content.substr(ref_end); } // Replace the vuids section if (vuid_start != std::string::npos && vuid_end != std::string::npos && vuid_end > vuid_start) { existing_content = existing_content.substr(0, vuid_start) + "\\cond WIS_GEN_WIS_IDS\n" + std::string(vuids) - + existing_content.substr(vuid_end); + + existing_content.substr(vuid_end); } // Replace the description section if (desc_start != std::string::npos && desc_end != std::string::npos && desc_end > desc_start) { existing_content = existing_content.substr(0, desc_start) + "\\cond WIS_GEN_DESC\n" + std::string(desc) - + existing_content.substr(desc_end); + + existing_content.substr(desc_end); } // Replace the generated section if (gen_start != std::string::npos && gen_end != std::string::npos && gen_end > gen_start) { existing_content = existing_content.substr(0, gen_start) + "\\cond WIS_GEN_CODE\n" + std::string(code) - + existing_content.substr(gen_end); + + existing_content.substr(gen_end); } // Write back to file @@ -1359,9 +1360,7 @@ void Generator::TryMakeRef(std::string_view type, std::string_view ref) } } -void Generator::TryMakeRef(std::string_view type, FunctionKey ref) { - dependency_tree[type].functions.push_back(ref); -} +void Generator::TryMakeRef(std::string_view type, FunctionKey ref) { dependency_tree[type].functions.push_back(ref); } std::string Generator::GetCFullTypename(std::string_view type, Backend backend) { @@ -1460,35 +1459,35 @@ std::string Generator::FinalizeCDocumentation(std::string doc, std::string_view auto& x = enum_map.at(this_type_view); auto evalue = x.HasValue(value); replacement = evalue ? std::format("`{}{}`", GetCFullTypename(x.name, backend), evalue->name) - : GetCFullTypename(x.name, backend); + : GetCFullTypename(x.name, backend); break; } case TypeKind::Bitmask: { auto& b = bitmask_map.at(this_type_view); auto evalue = b.HasValue(value); replacement = evalue ? std::format("`{}{}`", GetCFullTypename(b.name, backend), evalue->name) - : GetCFullTypename(b.name, backend); + : GetCFullTypename(b.name, backend); break; } case TypeKind::Struct: { auto& s = struct_map.at(this_type_view); auto member = s.HasValue(value); replacement = member ? std::format("`{}::{}`", GetCFullTypename(s.name, backend), member->name) - : GetCFullTypename(s.name, backend); + : GetCFullTypename(s.name, backend); break; } case TypeKind::Variant: { auto& v = variant_map.at(this_type_view); auto m = v.HasValue(value); replacement = m ? std::format("`{}::{}`", GetCFullTypename(v.name, backend), m->name) - : GetCFullTypename(v.name, backend); + : GetCFullTypename(v.name, backend); break; } case TypeKind::FuncPointer: { auto& d = delegate_map.at(this_type_view); auto m = d.HasValue(value); replacement = m ? std::format("`{}::{}`", GetCFullTypename(d.name, backend), m->name) - : GetCFullTypename(d.name, backend); + : GetCFullTypename(d.name, backend); break; } case TypeKind::Handle: { @@ -1577,35 +1576,35 @@ std::string Generator::FinalizeCPPDocumentation(std::string doc, std::string_vie auto& x = enum_map.at(this_type_view); auto evalue = x.HasValue(value); replacement = evalue ? std::format("`{}::{}`", GetCPPFullTypename(x.name, backend), evalue->name) - : GetCPPFullTypename(x.name, backend); + : GetCPPFullTypename(x.name, backend); break; } case TypeKind::Bitmask: { auto& b = bitmask_map.at(this_type_view); auto evalue = b.HasValue(value); replacement = evalue ? std::format("`{}::{}`", GetCPPFullTypename(b.name, backend), evalue->name) - : GetCPPFullTypename(b.name, backend); + : GetCPPFullTypename(b.name, backend); break; } case TypeKind::Struct: { auto& s = struct_map.at(this_type_view); auto member = s.HasValue(value); replacement = member ? std::format("`{}::{}`", GetCPPFullTypename(s.name, backend), member->name) - : GetCPPFullTypename(s.name, backend); + : GetCPPFullTypename(s.name, backend); break; } case TypeKind::Variant: { auto& v = variant_map.at(this_type_view); auto m = v.HasValue(value); replacement = m ? std::format("`{}::{}`", GetCPPFullTypename(v.name, backend), m->name) - : GetCPPFullTypename(v.name, backend); + : GetCPPFullTypename(v.name, backend); break; } case TypeKind::FuncPointer: { auto& d = delegate_map.at(this_type_view); auto m = d.HasValue(value); replacement = m ? std::format("`{}::{}`", GetCPPFullTypename(d.name, backend), m->name) - : GetCPPFullTypename(d.name, backend); + : GetCPPFullTypename(d.name, backend); break; } case TypeKind::Handle: { @@ -1677,9 +1676,9 @@ std::string Generator::GetSpecificationCode( if (!c_impl_code.empty()) { // append a details section template_content_c += std::format( - "
\nC Implementation Specific Version:\n```c\n{}```\n
\n", - c_impl_code - ); + "
\nC Implementation Specific Version:\n```c\n{}```\n
\n", + c_impl_code + ); } } @@ -1689,10 +1688,10 @@ std::string Generator::GetSpecificationCode( if (!cpp_impl_code.empty()) { // append a details section template_content_cpp += std::format( - "
\nC++ Implementation Specific Version:\n```cpp\nnamespace " - "wis{{\n{}}}\n```\n
\n", - cpp_impl_code - ); + "
\nC++ Implementation Specific Version:\n```cpp\nnamespace " + "wis{{\n{}}}\n```\n
\n", + cpp_impl_code + ); } } @@ -1934,7 +1933,8 @@ std::string Generator::GetRefs(std::string_view for_type) return refs; } -std::string Generator::GetFunctionCallParameters(const WisFunction& func, Backend backend) { +std::string Generator::GetFunctionCallParameters(const WisFunction& func, Backend backend) +{ constexpr static std::string_view arg_prefix = ",\n "; std::string body; for (size_t i = 0; i < func.parameters.size(); ++i) { @@ -1942,11 +1942,11 @@ std::string Generator::GetFunctionCallParameters(const WisFunction& func, Backen if (p.modifier & Modifier::Span) { body += std::format( - "reinterpret_cast<{}>({}.data()), {}.size()", - GetMemberTypeString(p, backend), - p.name, - p.name - ); + "reinterpret_cast<{}>({}.data()), {}.size()", + GetMemberTypeString(p, backend), + p.name, + p.name + ); i++; // skip next parameter (the size) if (i < func.parameters.size() - 1) { body += arg_prefix; diff --git a/generator/generator.hpp b/generator/generator.hpp index 0f12a353f..8464737cd 100644 --- a/generator/generator.hpp +++ b/generator/generator.hpp @@ -2,13 +2,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include "types.hpp" @@ -25,9 +25,7 @@ class Generator void ParseFile(std::filesystem::path file); void WriteModuleAPI(); void WriteModuleAPIDoc(std::string_view module_name = {}); - auto GetFiles() const { - return std::span {files}; - } + auto GetFiles() const { return std::span{files}; } public: void ParseIncludes(tinyxml2::XMLElement* includes); @@ -255,7 +253,7 @@ class Generator } } return pre_doc ? std::format(" {}\n {}\n", documentation, value_decl) - : std::format("{}{}\n", value_decl, documentation); + : std::format("{}{}\n", value_decl, documentation); } template @@ -269,9 +267,9 @@ class Generator // This arg if (!type.this_type.empty()) { args += std::format( - "@param self is a pointer to the valid {{{}::}} instance.\n", - type.this_type - ); + "@param self is a pointer to the valid {{{}::}} instance.\n", + type.this_type + ); } // Function arguments @@ -356,9 +354,9 @@ class Generator } if (member.modifier & Modifier::Span) { return std::format( - "wis::span<{}>", - attributes_pre + GetCPPFullTypename(member.type, backend) + attributes_inter - ); + "wis::span<{}>", + attributes_pre + GetCPPFullTypename(member.type, backend) + attributes_inter + ); } return attributes_pre + GetCPPFullTypename(member.type, backend) + attributes_inter; } else { diff --git a/generator/handle.cpp b/generator/handle.cpp index 2d55414b6..e4fb52d6d 100644 --- a/generator/handle.cpp +++ b/generator/handle.cpp @@ -169,10 +169,10 @@ std::string Generator::MakeCHandle(const WisHandle& s, Backend backend, DocKind auto impl_string = GetBackendSuffix(backend); auto extends_macro = s.extends == Extends::None - ? std::string("WIS_DEFINE_HANDLE") - : (s.extends == Extends::Instance - ? std::format("WIS_DEFINE_{}_INSTANCE_EXT_HANDLE", impl_string) - : std::format("WIS_DEFINE_{}_DEVICE_EXT_HANDLE", impl_string)); + ? std::string("WIS_DEFINE_HANDLE") + : (s.extends == Extends::Instance + ? std::format("WIS_DEFINE_{}_INSTANCE_EXT_HANDLE", impl_string) + : std::format("WIS_DEFINE_{}_DEVICE_EXT_HANDLE", impl_string)); auto full_name = GetCFullTypename(s.name, backend); @@ -191,12 +191,12 @@ std::string Generator::MakeCHandle(const WisHandle& s, Backend backend, DocKind auto view_name = s.view_override.empty() ? full_name : GetCFullTypename(s.view_override, backend); st_decl += std::format( - "\nstatic inline {}View wisGet{}{}View(const {}* handle){{\n", - view_name, - impl_string, - s.name, - full_name - ); + "\nstatic inline {}View wisGet{}{}View(const {}* handle){{\n", + view_name, + impl_string, + s.name, + full_name + ); st_decl += std::format(" {}View v;\n", view_name); st_decl += " memcpy(&v, handle, sizeof(v));\n" " return v;\n}\n"; @@ -212,23 +212,23 @@ std::string Generator::MakeCPPHandle(const WisHandle& s, Backend backend, DocKin auto full_name = GetCFullTypename(s.name, backend); std::string deleter = std::format( - "struct {}{}Deleter {{\n " - "void operator()({}* handle) noexcept {{\n ", - impl_string, - s.name, - full_name - ); + "struct {}{}Deleter {{\n " + "void operator()({}* handle) noexcept {{\n ", + impl_string, + s.name, + full_name + ); std::string st_decl = std::format( - "class {}{} : public wis::impl::Implements{{\npublic:\n", - impl_string, - s.name, - impl_string, - s.name, - full_name, - impl_string, - s.name - ); + "class {}{} : public wis::impl::Implements{{\npublic:\n", + impl_string, + s.name, + impl_string, + s.name, + full_name, + impl_string, + s.name + ); if (!s.doc.empty()) { std::string xdoc = MakeTypeDocumentation(s, kind); @@ -246,25 +246,25 @@ std::string Generator::MakeCPPHandle(const WisHandle& s, Backend backend, DocKin // Strict aliasing rules prevent us from doing a simple cast, so we have to memcpy the data to a new view struct auto view_name = s.view_override.empty() ? s.name : s.view_override; st_decl2 += std::format( - " WIS_NODISCARD {}{}View GetView() const noexcept {{\n" - " {}{}View v;\n" - " std::memcpy(&v, &_impl_storage, sizeof(v));\n" - " return v;\n" - " }}\n", - impl_string, - view_name, - impl_string, - view_name - ); + " WIS_NODISCARD {}{}View GetView() const noexcept {{\n" + " {}{}View v;\n" + " std::memcpy(&v, &_impl_storage, sizeof(v));\n" + " return v;\n" + " }}\n", + impl_string, + view_name, + impl_string, + view_name + ); // add conversion operator to view st_decl2 += std::format( - " WIS_NODISCARD operator {}{}View() const noexcept {{\n" - " return GetView();\n" - " }}\n", - impl_string, - view_name - ); + " WIS_NODISCARD operator {}{}View() const noexcept {{\n" + " return GetView();\n" + " }}\n", + impl_string, + view_name + ); } // Add all the functions @@ -272,11 +272,11 @@ std::string Generator::MakeCPPHandle(const WisHandle& s, Backend backend, DocKin FunctionKey func_key{s.name, func_name}; auto& func_ref = function_map[func_key]; auto c_name = std::format( - "wis{}{}{}", - impl_string, - func_ref.modifier & (Destroy | Construct) ? "" : func_ref.this_type, - func_ref.name - ); + "wis{}{}{}", + impl_string, + func_ref.modifier & (Destroy | Construct) ? "" : func_ref.this_type, + func_ref.name + ); if (func_ref.modifier & Modifier::Destroy) { deleter += std::format(" ::{}(handle);\n", c_name); continue; @@ -315,17 +315,17 @@ std::string Generator::MakeCPPHandle(const WisHandle& s, Backend backend, DocKin } ctor_decl += std::format( - " {}{}({}) noexcept\n" - " :ImplType(wis::in_place)\n" - " {{\n" - " ::{}({});\n" - " }}\n", - impl_string, - s.name, - params, - c_name, - args - ); + " {}{}({}) noexcept\n" + " :ImplType(wis::in_place)\n" + " {{\n" + " ::{}({});\n" + " }}\n", + impl_string, + s.name, + params, + c_name, + args + ); continue; } @@ -334,14 +334,14 @@ std::string Generator::MakeCPPHandle(const WisHandle& s, Backend backend, DocKin if (s.extends != Extends::None) { auto header = s.extends == Extends::Instance ? GetCPPFullTypename("InstanceExtensionHeader", backend) - : GetCPPFullTypename("DeviceExtensionHeader", backend); + : GetCPPFullTypename("DeviceExtensionHeader", backend); ctor_decl += std::format( - " // Operator & overload\n" - "{}* operator&() noexcept {{\n" - " return &GetMutableInternal().header;\n" - "}}\n", - header - ); + " // Operator & overload\n" + "{}* operator&() noexcept {{\n" + " return &GetMutableInternal().header;\n" + "}}\n", + header + ); } deleter += " }\n};\n"; @@ -372,7 +372,7 @@ void Generator::WriteHandleDocumentation(std::filesystem::path handle_output_pat // Make a folder for enums starting with this letter std::filesystem::create_directories(handle_output_path); std::filesystem::path handle_file_path = handle_output_path - / std::format("{}_handle.h", MakeSnakeCase(handle_name)); + / std::format("{}_handle.h", MakeSnakeCase(handle_name)); auto& handle_ref = handle_map[handle_name]; files.push_back(handle_file_path); diff --git a/generator/pch.hpp b/generator/pch.hpp index 60de69698..70d48f890 100644 --- a/generator/pch.hpp +++ b/generator/pch.hpp @@ -2,10 +2,10 @@ #include #include #include +#include #include #include #include #include #include #include -#include diff --git a/generator/struct.cpp b/generator/struct.cpp index 514eb8c61..8a4cbd3f1 100644 --- a/generator/struct.cpp +++ b/generator/struct.cpp @@ -91,10 +91,10 @@ std::string Generator::MakeCStruct(const WisStruct& s, DocKind kind) { auto full_name = GetCFullTypename(s.name, Backend::Any); std::string st_decl = std::format( - "typedef struct {} {} {{\n", - s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD" : "", - full_name - ); + "typedef struct {} {} {{\n", + s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD" : "", + full_name + ); if (!s.doc.empty()) { std::string xdoc = MakeTypeDocumentation(s, kind); st_decl = std::format("{}\n{}", xdoc, st_decl); @@ -118,10 +118,10 @@ std::string Generator::MakeCStruct(const WisStruct& s, DocKind kind) std::string Generator::MakeCPPStruct(const WisStruct& s, DocKind kind) { std::string st_decl = std::format( - "struct {} {} {{\n", - s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD" : "", - s.name - ); + "struct {} {} {{\n", + s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD" : "", + s.name + ); if (!s.doc.empty()) { std::string xdoc = MakeTypeDocumentation(s, kind); st_decl = std::format("{}\n{}", xdoc, st_decl); @@ -142,11 +142,11 @@ std::string Generator::MakeCPPStruct(const WisStruct& s, DocKind kind) } st_decl += MakeValueDocumentation( - s, - m, - MakeCPPMemberDeclaration(m, max_type_length, Backend::Any), - kind - ); + s, + m, + MakeCPPMemberDeclaration(m, max_type_length, Backend::Any), + kind + ); prev_span = m.modifier & Modifier::Span; } st_decl += "};\n"; @@ -213,16 +213,16 @@ void Generator::WriteStructDocumentation(std::filesystem::path struct_output_pat for (const auto& struct_name : struct_names) { // Make a folder for enums starting with this letter std::filesystem::path struct_file_path = struct_output_path - / std::format("{}_struct.h", MakeSnakeCase(struct_name)); + / std::format("{}_struct.h", MakeSnakeCase(struct_name)); auto& struct_ref = struct_map[struct_name]; files.push_back(struct_file_path); std::string struct_template_content = std::format( - " * C version:\n```c\n{}```\n" - "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", - MakeCStruct(struct_ref, DocKind::VersionOnly), - MakeCPPStruct(struct_ref, DocKind::VersionOnly) - ); + " * C version:\n```c\n{}```\n" + "C++ version:\n```cpp\nnamespace wis{{\n{}}}\n```\n", + MakeCStruct(struct_ref, DocKind::VersionOnly), + MakeCPPStruct(struct_ref, DocKind::VersionOnly) + ); std::string struct_description = std::format(" * {}", MakeStructDescription(struct_ref)); std::string struct_refs = GetRefs(struct_name); diff --git a/generator/types.hpp b/generator/types.hpp index 5d99f4cbd..dfe6932c6 100644 --- a/generator/types.hpp +++ b/generator/types.hpp @@ -41,9 +41,7 @@ constexpr Backend operator&(Backend a, Backend b) { return static_cast(static_cast(a) & static_cast(b)); } -constexpr bool has(Backend a, Backend b) { - return (a & b) == b; -} +constexpr bool has(Backend a, Backend b) { return (a & b) == b; } enum class ImplOs { None, @@ -120,11 +118,8 @@ struct WisEnum { public: std::optional HasValue(std::string_view name) const noexcept { - auto enum_value = std::find_if(values.begin(), values.end(), [&](auto& v) { - return v.name == name; - }); - return enum_value != values.end() ? std::optional {*enum_value} : - std::nullopt; + auto enum_value = std::find_if(values.begin(), values.end(), [&](auto& v) { return v.name == name; }); + return enum_value != values.end() ? std::optional{*enum_value} : std::nullopt; } }; @@ -147,11 +142,8 @@ struct WisBitmask { public: std::optional HasValue(std::string_view name) const noexcept { - auto enum_value = std::find_if(values.begin(), values.end(), [&](auto& v) { - return v.name == name; - }); - return enum_value != values.end() ? std::optional {*enum_value} : - std::nullopt; + auto enum_value = std::find_if(values.begin(), values.end(), [&](auto& v) { return v.name == name; }); + return enum_value != values.end() ? std::optional{*enum_value} : std::nullopt; } }; @@ -182,14 +174,10 @@ struct WisStruct { return {}; } - auto enum_value = std::find_if(members.begin(), members.end(), [&](auto& v) { - return v.name == name; - }); + auto enum_value = std::find_if(members.begin(), members.end(), [&](auto& v) { return v.name == name; }); return *enum_value; } - void FilterBackend(Backend b) { - backend = backend & b; - } + void FilterBackend(Backend b) { backend = backend & b; } }; //---------------------------------------------------------------------------------------------------------------------- @@ -268,18 +256,10 @@ struct WisReturnType { return ReturnTypeKind::ResultAndValue; } - bool IsVoid() const noexcept { - return type.empty() && !has_result; - } - bool IsRV() const noexcept { - return has_result && !type.empty(); - } - bool IsDirect() const noexcept { - return !has_result && !type.empty(); - } - bool IsResultOnly() const noexcept { - return has_result && type.empty(); - } + bool IsVoid() const noexcept { return type.empty() && !has_result; } + bool IsRV() const noexcept { return has_result && !type.empty(); } + bool IsDirect() const noexcept { return !has_result && !type.empty(); } + bool IsResultOnly() const noexcept { return has_result && type.empty(); } }; struct WisFunction { std::string_view name; @@ -298,9 +278,7 @@ struct WisFunction { if (name.empty()) { return {}; } - auto enum_value = std::find_if(parameters.begin(), parameters.end(), [&](auto& v) { - return v.name == name; - }); + auto enum_value = std::find_if(parameters.begin(), parameters.end(), [&](auto& v) { return v.name == name; }); if (enum_value == parameters.end()) { // it can be return value if (return_type.opt_name == name) { @@ -318,13 +296,9 @@ struct WisFunction { } // constructor or destructor - bool IsCD() const noexcept { - return modifier & (Modifier::Construct | Modifier::Destroy); - } + bool IsCD() const noexcept { return modifier & (Modifier::Construct | Modifier::Destroy); } - void FilterBackend(Backend b) { - backend = backend & b; - } + void FilterBackend(Backend b) { backend = backend & b; } }; static inline constexpr Severity from_chars(std::string_view input) noexcept @@ -368,7 +342,7 @@ template <> struct hash { std::size_t operator()(const FunctionKey& k) const noexcept { - return std::hash {}(k.first) ^ (std::hash {}(k.second) << 1); + return std::hash{}(k.first) ^ (std::hash{}(k.second) << 1); } }; } // namespace std diff --git a/generator/validation.cpp b/generator/validation.cpp index 640e7ef31..33388eed5 100644 --- a/generator/validation.cpp +++ b/generator/validation.cpp @@ -4,7 +4,7 @@ void Generator::ParseValidations(tinyxml2::XMLElement* validations) { for (auto* validation = validations->FirstChildElement("validation"); validation; - validation = validation->NextSiblingElement("validation")) { + validation = validation->NextSiblingElement("validation")) { auto name = validation->FindAttribute("for")->Value(); auto& ref = validation_map[name]; diff --git a/generator/variant.cpp b/generator/variant.cpp index fc5affd39..2b7deb445 100644 --- a/generator/variant.cpp +++ b/generator/variant.cpp @@ -91,10 +91,10 @@ std::string Generator::MakeCVariant(const WisStruct& s, Backend backend, DocKind auto impl_suffix = GetBackendSuffix(backend); auto full_name = GetCFullTypename(s.name, backend); std::string st_decl = std::format( - "typedef struct {}{} {{\n", - s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD " : "", - full_name - ); + "typedef struct {}{} {{\n", + s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD " : "", + full_name + ); if (!s.doc.empty()) { std::string xdoc = MakeTypeDocumentation(s, kind); st_decl = std::format("{}\n{}", xdoc, st_decl); @@ -123,11 +123,11 @@ std::string Generator::MakeCPPVariant(const WisStruct& s, Backend backend, DocKi auto impl_suffix = GetBackendSuffix(backend); std::string st_decl = std::format( - "struct {}{}{} {{\n", - s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD " : "", - impl_suffix, - s.name - ); + "struct {}{}{} {{\n", + s.modifier & Modifier::Nodiscard ? "WIS_NODISCARD " : "", + impl_suffix, + s.name + ); if (!s.doc.empty()) { std::string xdoc = MakeTypeDocumentation(s, kind); st_decl = std::format("{}\n{}", xdoc, st_decl); @@ -171,7 +171,7 @@ void Generator::WriteVariantDocumentation(std::filesystem::path struct_output_pa for (const auto& variant_name : variant_names) { // Make a folder for enums starting with this letter std::filesystem::path variant_file_path = struct_output_path - / std::format("{}_struct.h", MakeSnakeCase(variant_name)); + / std::format("{}_struct.h", MakeSnakeCase(variant_name)); auto& variant_ref = variant_map[variant_name]; files.push_back(variant_file_path); @@ -181,8 +181,8 @@ void Generator::WriteVariantDocumentation(std::filesystem::path struct_output_pa std::string vk_code = supports_vk ? MakeCVariant(variant_ref, Backend::Vulkan, DocKind::VersionOnly) : ""; std::string dx_code = supports_dx ? MakeCVariant(variant_ref, Backend::DX12, DocKind::VersionOnly) : ""; std::string regular_code = supports_vk && supports_dx - ? MakeCVariant(variant_ref, Backend::Any, DocKind::VersionOnly) - : ""; + ? MakeCVariant(variant_ref, Backend::Any, DocKind::VersionOnly) + : ""; std::string c_code = regular_code; std::string cimpl_code = supports_vk && supports_dx ? (vk_code + '\n' + dx_code) : ""; @@ -191,18 +191,18 @@ void Generator::WriteVariantDocumentation(std::filesystem::path struct_output_pa } std::string vk_cpp = variant_ref.modifier & Modifier::COnly || !supports_vk - ? "" - : MakeCPPVariant(variant_ref, Backend::Vulkan, DocKind::VersionOnly); + ? "" + : MakeCPPVariant(variant_ref, Backend::Vulkan, DocKind::VersionOnly); std::string dx_cpp = variant_ref.modifier & Modifier::COnly || !supports_dx - ? "" - : MakeCPPVariant(variant_ref, Backend::DX12, DocKind::VersionOnly); + ? "" + : MakeCPPVariant(variant_ref, Backend::DX12, DocKind::VersionOnly); std::string regular_code_cpp = variant_ref.modifier & Modifier::COnly || !(supports_vk && supports_dx) - ? "" - : MakeCPPVariant(variant_ref, Backend::Any, DocKind::VersionOnly); + ? "" + : MakeCPPVariant(variant_ref, Backend::Any, DocKind::VersionOnly); std::string cpp_code = regular_code_cpp; std::string cimpl_code_cpp = variant_ref.modifier & Modifier::COnly || !(supports_vk && supports_dx) - ? "" - : vk_cpp + '\n' + dx_cpp; + ? "" + : vk_cpp + '\n' + dx_cpp; if (cpp_code.empty()) { cpp_code = !vk_cpp.empty() ? vk_cpp : dx_cpp; } diff --git a/src/include/wisdom/bridge/span.hpp b/src/include/wisdom/bridge/span.hpp index 8e85d9cc2..12771f1dc 100644 --- a/src/include/wisdom/bridge/span.hpp +++ b/src/include/wisdom/bridge/span.hpp @@ -73,13 +73,10 @@ struct contract_violation_error : std::logic_error { {} }; -inline void contract_violation(const char* msg) { - throw contract_violation_error(msg); -} +inline void contract_violation(const char* msg) { throw contract_violation_error(msg); } #elif defined(TCB_SPAN_TERMINATE_ON_CONTRACT_VIOLATION) -[[noreturn]] inline void contract_violation( - const char* /*unused*/ +[[noreturn]] inline void contract_violation(const char* /*unused*/ ) { std::terminate(); @@ -256,12 +253,12 @@ struct has_size_and_data : std::false_type {}; template struct has_size_and_data< T, -void_t())), decltype(detail::data(std::declval()))>> : std::true_type {}; + void_t())), decltype(detail::data(std::declval()))>> : std::true_type {}; template > struct is_container { static constexpr bool value = !is_span::value && !is_std_array::value && !std::is_array::value - && has_size_and_data::value; + && has_size_and_data::value; }; template @@ -275,9 +272,9 @@ struct is_container_element_type_compatible< T, E, typename std::enable_if< -!std::is_same()))>::type, void>::value -&& std::is_convertible()))> (*)[], E (*)[]>::value>:: -type> : std::true_type {}; + !std::is_same()))>::type, void>::value + && std::is_convertible()))> (*)[], E (*)[]>::value>:: + type> : std::true_type {}; template struct is_complete : std::false_type {}; @@ -321,7 +318,7 @@ class span // [span.cons], span constructors, copy, assignment, and destructor template ::type = 0> - constexpr span() noexcept + constexpr span() noexcept {} TCB_SPAN_CONSTEXPR11 span(pointer ptr, size_type count) @@ -341,7 +338,7 @@ class span std::size_t E = Extent, typename std::enable_if< (E == dynamic_extent || N == E) - && detail::is_container_element_type_compatible::value, + && detail::is_container_element_type_compatible::value, int>::type = 0> constexpr span(element_type (&arr)[N]) noexcept : storage_(arr, N) @@ -353,7 +350,7 @@ class span std::size_t E = Extent, typename std::enable_if< (E == dynamic_extent || N == E) - && detail::is_container_element_type_compatible&, ElementType>::value, + && detail::is_container_element_type_compatible&, ElementType>::value, int>::type = 0> TCB_SPAN_ARRAY_CONSTEXPR span(std::array& arr) noexcept : storage_(arr.data(), N) @@ -365,7 +362,7 @@ class span std::size_t E = Extent, typename std::enable_if< (E == dynamic_extent || N == E) - && detail::is_container_element_type_compatible&, ElementType>::value, + && detail::is_container_element_type_compatible&, ElementType>::value, int>::type = 0> TCB_SPAN_ARRAY_CONSTEXPR span(const std::array& arr) noexcept : storage_(arr.data(), N) @@ -376,7 +373,7 @@ class span std::size_t E = Extent, typename std::enable_if< E == dynamic_extent && detail::is_container::value - && detail::is_container_element_type_compatible::value, + && detail::is_container_element_type_compatible::value, int>::type = 0> constexpr span(Container& cont) : storage_(detail::data(cont), detail::size(cont)) @@ -387,7 +384,7 @@ class span std::size_t E = Extent, typename std::enable_if< E == dynamic_extent && detail::is_container::value - && detail::is_container_element_type_compatible::value, + && detail::is_container_element_type_compatible::value, int>::type = 0> constexpr span(const Container& cont) : storage_(detail::data(cont), detail::size(cont)) @@ -400,7 +397,7 @@ class span std::size_t OtherExtent, typename std::enable_if< (Extent == dynamic_extent || OtherExtent == dynamic_extent || Extent == OtherExtent) - && std::is_convertible::value, + && std::is_convertible::value, int>::type = 0> constexpr span(const span& other) noexcept : storage_(other.data(), other.size()) @@ -434,10 +431,10 @@ class span TCB_SPAN_CONSTEXPR11 subspan_return_t subspan() const { TCB_SPAN_EXPECT(Offset <= size() && (Count == dynamic_extent || Offset + Count <= size())); - return {data() + Offset, Count != dynamic_extent ? Count : size() - Offset}; + return {data() + Offset, Count != dynamic_extent ? Count : size() - Offset}; } - TCB_SPAN_CONSTEXPR11 span first(size_type count) const + TCB_SPAN_CONSTEXPR11 span first(size_type count) const { TCB_SPAN_EXPECT(count <= size()); return {data(), count}; @@ -449,27 +446,19 @@ class span return {data() + (size() - count), count}; } - TCB_SPAN_CONSTEXPR11 span subspan( - size_type offset, - size_type count = dynamic_extent - ) const + TCB_SPAN_CONSTEXPR11 span subspan(size_type offset, size_type count = dynamic_extent) + const { TCB_SPAN_EXPECT(offset <= size() && (count == dynamic_extent || offset + count <= size())); return {data() + offset, count == dynamic_extent ? size() - offset : count}; } // [span.obs], span observers - constexpr size_type size() const noexcept { - return storage_.size; - } + constexpr size_type size() const noexcept { return storage_.size; } - constexpr size_type size_bytes() const noexcept { - return size() * sizeof(element_type); - } + constexpr size_type size_bytes() const noexcept { return size() * sizeof(element_type); } - TCB_SPAN_NODISCARD constexpr bool empty() const noexcept { - return size() == 0; - } + TCB_SPAN_NODISCARD constexpr bool empty() const noexcept { return size() == 0; } // [span.elem], span element access TCB_SPAN_CONSTEXPR11 reference operator[](size_type idx) const @@ -490,26 +479,16 @@ class span return WIS_UNSAFE_BUFFERS(*(data() + (size() - 1))); } - constexpr pointer data() const noexcept { - return storage_.ptr; - } + constexpr pointer data() const noexcept { return storage_.ptr; } // [span.iterators], span iterator support - constexpr iterator begin() const noexcept { - return data(); - } + constexpr iterator begin() const noexcept { return data(); } - constexpr iterator end() const noexcept { - return WIS_UNSAFE_BUFFERS(data() + size()); - } + constexpr iterator end() const noexcept { return WIS_UNSAFE_BUFFERS(data() + size()); } - TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rbegin() const noexcept { - return reverse_iterator(end()); - } + TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } - TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rend() const noexcept { - return reverse_iterator(begin()); - } + TCB_SPAN_ARRAY_CONSTEXPR reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } private: storage_type storage_{}; @@ -576,7 +555,7 @@ constexpr span make_span(const Container& template span as_bytes( span s - ) noexcept +) noexcept { return {reinterpret_cast(s.data()), s.size_bytes()}; } @@ -584,7 +563,7 @@ span::value, int>::type = 0> span as_writable_bytes( span s - ) noexcept +) noexcept { return {reinterpret_cast(s.data()), s.size_bytes()}; } @@ -605,8 +584,8 @@ class tuple_size> : public in template class tuple_size>; // not defined + ElementType, + TCB_SPAN_NAMESPACE_NAME::dynamic_extent>>; // not defined template class tuple_element> diff --git a/src/include/wisdom/dx12/detail/dx12_detail.hpp b/src/include/wisdom/dx12/detail/dx12_detail.hpp index 71d982f3a..262d5ad8b 100644 --- a/src/include/wisdom/dx12/detail/dx12_detail.hpp +++ b/src/include/wisdom/dx12/detail/dx12_detail.hpp @@ -57,11 +57,11 @@ struct DX12DebugLayerThunk final : public IUnknownImplRegisterMessageCallback( - DX12CallbackThunk, - D3D12_MESSAGE_CALLBACK_FLAG_NONE, - this, - &cookie - ); + DX12CallbackThunk, + D3D12_MESSAGE_CALLBACK_FLAG_NONE, + this, + &cookie + ); // Debug layer creation failure is allowed to silently fail (void)hr; } @@ -136,18 +136,18 @@ struct DX12RootSignatureKey { //---------------------------------------------------------------------------------------------------------------------- struct DX12ShaderHeader { - uint64_t hash[2] {}; // Hash of the shader bytecode, used for caching and identification purposes. + uint64_t hash[2]{}; // Hash of the shader bytecode, used for caching and identification purposes. std::size_t size = 0; // Size of the shader bytecode in bytes. // bytecode follows immediately after the header in memory. wis::span GetBytecode() const noexcept { - return wis::span {reinterpret_cast(this + 1), size}; + return wis::span{reinterpret_cast(this + 1), size}; } wis::span GetMutableBytecode() noexcept { - return wis::span {reinterpret_cast(this + 1), size}; + return wis::span{reinterpret_cast(this + 1), size}; } }; @@ -244,7 +244,7 @@ inline constexpr uint32_t DX12GetCopyPlaneSlice(WisBarrierFlags flags, uint16_t //---------------------------------------------------------------------------------------------------------------------- // Barrier helper constants constexpr static uint32_t dx12_max_barrier_size = std::max( -{sizeof(D3D12_BUFFER_BARRIER), sizeof(D3D12_TEXTURE_BARRIER), sizeof(D3D12_GLOBAL_BARRIER)} + {sizeof(D3D12_BUFFER_BARRIER), sizeof(D3D12_TEXTURE_BARRIER), sizeof(D3D12_GLOBAL_BARRIER)} ); constexpr static uint32_t dx12_static_size = wis::TransientMaxBarrierCount * dx12_max_barrier_size; @@ -268,8 +268,8 @@ inline std::array, 3> DX12AllocateBarriers( { std::array, 3> spans; std::size_t needed_size = barriers.buffer_barrier_count * sizeof(D3D12_BUFFER_BARRIER) - + barriers.texture_barrier_count * sizeof(D3D12_TEXTURE_BARRIER) - + barriers.global_barrier_count * sizeof(D3D12_GLOBAL_BARRIER); + + barriers.texture_barrier_count * sizeof(D3D12_TEXTURE_BARRIER) + + barriers.global_barrier_count * sizeof(D3D12_GLOBAL_BARRIER); if (needed_size <= dx12_static_size) { spans[0] = {local_scratch, barriers.buffer_barrier_count * sizeof(D3D12_BUFFER_BARRIER)}; @@ -403,7 +403,7 @@ inline void DX12InsertBarriers( return; } - uint8_t local_scratch[dx12_static_size] {}; + uint8_t local_scratch[dx12_static_size]{}; auto [buffer_span, texture_span, global_span] = DX12AllocateBarriers(impl, local_scratch, *barriers); @@ -444,13 +444,13 @@ inline void DX12InsertBarriers( bool release_barrier = qfot_barrier && src.queue_type_before == queue_type; auto layout_before = DX12GetOptimalBarrierLayout( - queue_type, - acquire_barrier ? WisTextureStateCommon : src.state_before - ); + queue_type, + acquire_barrier ? WisTextureStateCommon : src.state_before + ); auto layout_after = DX12GetOptimalBarrierLayout( - queue_type, - release_barrier ? WisTextureStateCommon : src.state_after - ); + queue_type, + release_barrier ? WisTextureStateCommon : src.state_after + ); texture_barriers_span[i] = D3D12_TEXTURE_BARRIER{ .SyncBefore = DX12Convert(src.sync_before), @@ -461,16 +461,16 @@ inline void DX12InsertBarriers( .LayoutAfter = layout_after, .pResource = std::bit_cast(src.texture), .Subresources = - { - .IndexOrFirstMipLevel = src.subresource_range.base_mip_level, - .NumMipLevels = src.subresource_range.mip_level_count, - .FirstArraySlice = src.subresource_range.base_array_layer, - .NumArraySlices = src.subresource_range.array_layer_count, - .FirstPlane = src.flags & WisBarrierFlagsPlanarImage ? src.subresource_range.plane_slice : 0u, - .NumPlanes = src.flags & WisBarrierFlagsPlanarImage ? src.subresource_range.plane_slice_count : 1u, - }, + { + .IndexOrFirstMipLevel = src.subresource_range.base_mip_level, + .NumMipLevels = src.subresource_range.mip_level_count, + .FirstArraySlice = src.subresource_range.base_array_layer, + .NumArraySlices = src.subresource_range.array_layer_count, + .FirstPlane = src.flags & WisBarrierFlagsPlanarImage ? src.subresource_range.plane_slice : 0u, + .NumPlanes = src.flags & WisBarrierFlagsPlanarImage ? src.subresource_range.plane_slice_count : 1u, + }, .Flags = src.state_before == WisTextureStateUndefined ? D3D12_TEXTURE_BARRIER_FLAG_DISCARD - : D3D12_TEXTURE_BARRIER_FLAG_NONE, + : D3D12_TEXTURE_BARRIER_FLAG_NONE, }; } @@ -488,19 +488,16 @@ inline void DX12InsertBarriers( }; } - D3D12_BARRIER_GROUP groups[] { - { .Type = D3D12_BARRIER_TYPE_BUFFER, - .NumBarriers = real_buffer_barrier_count, - .pBufferBarriers = buffer_barriers_span.data() - }, - { .Type = D3D12_BARRIER_TYPE_TEXTURE, - .NumBarriers = static_cast(barriers->texture_barrier_count), - .pTextureBarriers = texture_barriers_span.data() - }, - { .Type = D3D12_BARRIER_TYPE_GLOBAL, - .NumBarriers = static_cast(barriers->global_barrier_count), - .pGlobalBarriers = global_barriers_span.data() - } + D3D12_BARRIER_GROUP groups[]{ + {.Type = D3D12_BARRIER_TYPE_BUFFER, + .NumBarriers = real_buffer_barrier_count, + .pBufferBarriers = buffer_barriers_span.data()}, + {.Type = D3D12_BARRIER_TYPE_TEXTURE, + .NumBarriers = static_cast(barriers->texture_barrier_count), + .pTextureBarriers = texture_barriers_span.data()}, + {.Type = D3D12_BARRIER_TYPE_GLOBAL, + .NumBarriers = static_cast(barriers->global_barrier_count), + .pGlobalBarriers = global_barriers_span.data()} }; list->Barrier(std::size(groups), groups); } diff --git a/src/include/wisdom/dx12/dx12_adapter_query.cpp b/src/include/wisdom/dx12/dx12_adapter_query.cpp index b60934b51..7af53a063 100644 --- a/src/include/wisdom/dx12/dx12_adapter_query.cpp +++ b/src/include/wisdom/dx12/dx12_adapter_query.cpp @@ -39,11 +39,8 @@ WIS_EXTERN_C WISDOM_API size_t wisDX12AdapterQueryGetAdapterCount(const WisDX12A } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12AdapterQueryGetAdapterDesc( - const WisDX12AdapterQuery* self, - size_t index, - WisAdapterDesc* desc -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12AdapterQueryGetAdapterDesc(const WisDX12AdapterQuery* self, size_t index, WisAdapterDesc* desc) { WisResult res = wis::detail::dx_success; auto& impl = wis::from_handle_ref(self); @@ -112,11 +109,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12AdapterQueryCreateDevice( } wis::com_ptr device_ref; auto hr = D3D12CreateDevice( - impl.physical_devices[index], - D3D_FEATURE_LEVEL_12_0, - IID_ID3D12Device10, - reinterpret_cast(device_ref.put_void_unchecked()) - ); + impl.physical_devices[index], + D3D_FEATURE_LEVEL_12_0, + IID_ID3D12Device10, + reinterpret_cast(device_ref.put_void_unchecked()) + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -124,8 +121,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12AdapterQueryCreateDevice( D3D12_FEATURE_DATA_D3D12_OPTIONS12 options12 = {}; bool EnhancedBarriersSupported = false; if (wis::detail::succeeded( - device_ref->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12, &options12, sizeof(options12)) - )) { + device_ref->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12, &options12, sizeof(options12)) + )) { EnhancedBarriersSupported = options12.EnhancedBarriersSupported; } if (!EnhancedBarriersSupported) { @@ -136,10 +133,10 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12AdapterQueryCreateDevice( if (impl.debug_layer && impl.debug_layer->callback) { wis::com_ptr info_queue; if (auto hr2 = device_ref->QueryInterface( - IID_ID3D12InfoQueue1, - reinterpret_cast(info_queue.put_void_unchecked()) - ); - wis::detail::succeeded(hr2)) { + IID_ID3D12InfoQueue1, + reinterpret_cast(info_queue.put_void_unchecked()) + ); + wis::detail::succeeded(hr2)) { const wis::com_ptr thunk{ new wis::detail::DX12DebugLayerThunk( info_queue.get(), @@ -189,7 +186,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12AdapterQueryCreateDevice( const auto& desc = requirements->queue_descs[i]; if (desc.type >= WisCommandQueueTypeCount || desc.type < 0) { return wis::detail:: - make_result(E_INVALIDARG); + make_result(E_INVALIDARG); } if (desc.priority > WisCommandQueuePriorityNormal) { @@ -199,17 +196,17 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12AdapterQueryCreateDevice( .Priority = static_cast(wis::detail::DX12Convert(desc.priority)), }; device_impl.device - ->CheckFeatureSupport(D3D12_FEATURE_COMMAND_QUEUE_PRIORITY, &queue_priority, sizeof(queue_priority)); + ->CheckFeatureSupport(D3D12_FEATURE_COMMAND_QUEUE_PRIORITY, &queue_priority, sizeof(queue_priority)); device_impl.queue_priorities[desc.type] = queue_priority.PriorityForTypeIsSupported - ? desc.priority - : WisCommandQueuePriorityNormal; + ? desc.priority + : WisCommandQueuePriorityNormal; } device_impl.queue_priorities[desc.type] |= 1 << 7; // set support bit for this queue type } for (auto* ext : - wis::span {requirements->extensions, requirements->extension_count}) { + wis::span{requirements->extensions, requirements->extension_count}) { if (auto* table = wis::from_handle(ext); table && table->init_fptr) { if (const auto xres = table->init_fptr(table, device_impl); xres.status != WisStatusOk) { res.status = WisStatusPartial; // mark as partial success if any extension fails diff --git a/src/include/wisdom/dx12/dx12_command_allocator.cpp b/src/include/wisdom/dx12/dx12_command_allocator.cpp index 3ed03d7b4..d147a7859 100644 --- a/src/include/wisdom/dx12/dx12_command_allocator.cpp +++ b/src/include/wisdom/dx12/dx12_command_allocator.cpp @@ -30,22 +30,20 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12CommandAllocatorReset(const WisDX12Comm } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12CommandAllocatorCreateCommandList( - const WisDX12CommandAllocator* self, - WisDX12CommandList* list -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12CommandAllocatorCreateCommandList(const WisDX12CommandAllocator* self, WisDX12CommandList* list) { auto& [allocator, device, type] = wis::from_handle_ref(self); wis::com_ptr command_list; auto hr = device->CreateCommandList1( - 0, - wis::detail::DX12Convert(type), - D3D12_COMMAND_LIST_FLAG_NONE, - IID_ID3D12GraphicsCommandList9, - command_list.put_void_unchecked() - ); + 0, + wis::detail::DX12Convert(type), + D3D12_COMMAND_LIST_FLAG_NONE, + IID_ID3D12GraphicsCommandList9, + command_list.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); diff --git a/src/include/wisdom/dx12/dx12_command_list.cpp b/src/include/wisdom/dx12/dx12_command_list.cpp index 239e0a4de..c8c1684e1 100644 --- a/src/include/wisdom/dx12/dx12_command_list.cpp +++ b/src/include/wisdom/dx12/dx12_command_list.cpp @@ -21,7 +21,7 @@ inline D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS* DX12Alloc if (new_size > impl.rp_memory_size) { delete[] impl.render_pass_memory; impl.render_pass_memory = new (std::nothrow) - D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS[new_size]; + D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS[new_size]; impl.rp_memory_size = impl.render_pass_memory ? new_size : 0; } return impl.render_pass_memory; @@ -84,17 +84,17 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListSetDescriptorHeaps( uint32_t heap_count = (resource_heap != 0) + (sampler_heap != 0); ID3D12DescriptorHeap* heaps[] = { resource_heap ? wis::from_handle(resource_heap)->descriptor_heap - : nullptr, + : nullptr, sampler_heap ? wis::from_handle(sampler_heap)->descriptor_heap - : nullptr, + : nullptr, }; impl.descriptor_handle = resource_heap - ? wis::from_handle(resource_heap)->gpu_handle - : D3D12_GPU_DESCRIPTOR_HANDLE{0}; + ? wis::from_handle(resource_heap)->gpu_handle + : D3D12_GPU_DESCRIPTOR_HANDLE{0}; impl.sampler_handle = sampler_heap - ? wis::from_handle(sampler_heap)->gpu_handle - : D3D12_GPU_DESCRIPTOR_HANDLE{0}; + ? wis::from_handle(sampler_heap)->gpu_handle + : D3D12_GPU_DESCRIPTOR_HANDLE{0}; if (heap_count > 0) { impl.list->SetDescriptorHeaps(heap_count, heaps + heap_offset); @@ -134,12 +134,12 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListSetPushConstants( default: case WisPipelineTypeGraphics: impl.list - ->SetGraphicsRoot32BitConstants(data->root_index, data->data_size / 4, data->data, data->push_offset / 4); + ->SetGraphicsRoot32BitConstants(data->root_index, data->data_size / 4, data->data, data->push_offset / 4); break; case WisPipelineTypeRayTracing: case WisPipelineTypeCompute: impl.list - ->SetComputeRoot32BitConstants(data->root_index, data->data_size / 4, data->data, data->push_offset / 4); + ->SetComputeRoot32BitConstants(data->root_index, data->data_size / 4, data->data, data->push_offset / 4); } } @@ -347,13 +347,14 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( render_targets[i] = { .cpuDescriptor = aux ? aux->handle : D3D12_CPU_DESCRIPTOR_HANDLE{src.target}, .BeginningAccess = - { - .Type = wis::detail::DX12Convert(src.load_op), - }, - .EndingAccess = { - .Type = src.resolve_desc ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE - : wis::detail::DX12Convert(src.store_op), - }, + { + .Type = wis::detail::DX12Convert(src.load_op), + }, + .EndingAccess = + { + .Type = src.resolve_desc ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE + : wis::detail::DX12Convert(src.store_op), + }, }; if (src.load_op == WisLoadOpClear) { render_targets[i].BeginningAccess.Clear.ClearValue = { @@ -380,8 +381,7 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( // Encode the other parameters .pSubresourceParameters = static_cast< - const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>( - static_cast(dst) + const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>(static_cast(dst) ), .Format = static_cast(dst->format), .ResolveMode = wis::detail::DX12Convert(resolve.mode), @@ -397,37 +397,38 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( bool ignore_stencil = (desc->depth_stencil.flags & WisDepthStencilFlagsIgnoreStencil); flags |= (desc->depth_stencil.flags & WisDepthStencilFlagsReadOnlyDepth) && !ignore_depth - ? D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_DEPTH - : D3D12_RENDER_PASS_FLAG_NONE; + ? D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_DEPTH + : D3D12_RENDER_PASS_FLAG_NONE; flags |= (desc->depth_stencil.flags & WisDepthStencilFlagsReadOnlyStencil) && !ignore_stencil - ? D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_STENCIL - : D3D12_RENDER_PASS_FLAG_NONE; + ? D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_STENCIL + : D3D12_RENDER_PASS_FLAG_NONE; auto& src = desc->depth_stencil; auto* aux = wis::detail::DX12DecodeViewAddress(src.target); depth_stencil = { .cpuDescriptor = aux ? aux->handle : D3D12_CPU_DESCRIPTOR_HANDLE{src.target}, .DepthBeginningAccess = - { - .Type = ignore_depth ? D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS - : wis::detail::DX12Convert(src.load_op_depth), - }, + { + .Type = ignore_depth ? D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS + : wis::detail::DX12Convert(src.load_op_depth), + }, .StencilBeginningAccess = - { - .Type = ignore_stencil ? D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS - : wis::detail::DX12Convert(src.load_op_stencil), - }, + { + .Type = ignore_stencil ? D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS + : wis::detail::DX12Convert(src.load_op_stencil), + }, .DepthEndingAccess = - { - .Type = ignore_depth ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS - : src.resolve_depth_desc ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE - : wis::detail::DX12Convert(src.store_op_depth), - }, - .StencilEndingAccess = { - .Type = ignore_stencil ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS - : src.resolve_stencil_desc ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE - : wis::detail::DX12Convert(src.store_op_stencil), - }, + { + .Type = ignore_depth ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS + : src.resolve_depth_desc ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE + : wis::detail::DX12Convert(src.store_op_depth), + }, + .StencilEndingAccess = + { + .Type = ignore_stencil ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS + : src.resolve_stencil_desc ? D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE + : wis::detail::DX12Convert(src.store_op_stencil), + }, }; if (src.resolve_depth_desc) { @@ -449,8 +450,7 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( // Encode the other parameters .pSubresourceParameters = static_cast< - const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>( - static_cast(dst) + const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>(static_cast(dst) ), .Format = static_cast(dst->format), .ResolveMode = wis::detail::DX12Convert(resolve.mode), @@ -476,8 +476,7 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( .SubresourceCount = layer_count, // Encode the other parameters .pSubresourceParameters = static_cast< - const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>( - static_cast(dst) + const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS*>(static_cast(dst) ), .Format = static_cast(dst->format), .ResolveMode = wis::detail::DX12Convert(resolve.mode), @@ -501,9 +500,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( auto& dst = render_targets[i].EndingAccess.Resolve; auto* src_aux = wis::detail::DX12DecodeViewAddress(src.target); - auto* dst_aux = reinterpret_cast( - dst.pSubresourceParameters - ); + auto* dst_aux = reinterpret_cast(dst.pSubresourceParameters + ); wis::span subresource_params{ subresources + offset, @@ -514,12 +512,13 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( subresource_params[j] = { .SrcSubresource = src_aux->base_subresource + j * src_aux->subresource_stride, .DstSubresource = dst_aux->base_subresource + j * dst_aux->subresource_stride, - .SrcRect = { - .left = 0, - .top = 0, - .right = static_cast(width), - .bottom = static_cast(height), - }, + .SrcRect = + { + .left = 0, + .top = 0, + .right = static_cast(width), + .bottom = static_cast(height), + }, }; } dst.pSubresourceParameters = subresource_params.data(); @@ -539,8 +538,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( if (src.resolve_depth_desc) { auto& dst_depth = depth_stencil.DepthEndingAccess.Resolve; auto* dst_depth_aux = reinterpret_cast( - dst_depth.pSubresourceParameters - ); + dst_depth.pSubresourceParameters + ); wis::span subresource_params{ subresources + offset, @@ -551,13 +550,14 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( subresource_params[j] = { .SrcSubresource = aux->base_subresource + j * aux->subresource_stride, .DstSubresource = (dst_depth_aux ? dst_depth_aux->base_subresource : 0) - + j * (dst_depth_aux ? dst_depth_aux->subresource_stride : 0), - .SrcRect = { - .left = 0, - .top = 0, - .right = static_cast(width), - .bottom = static_cast(height), - }, + + j * (dst_depth_aux ? dst_depth_aux->subresource_stride : 0), + .SrcRect = + { + .left = 0, + .top = 0, + .right = static_cast(width), + .bottom = static_cast(height), + }, }; } depth_stencil.DepthEndingAccess.Resolve.pSubresourceParameters = subresource_params.data(); @@ -571,8 +571,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( auto& dst_stencil = depth_stencil.StencilEndingAccess.Resolve; auto* dst_stencil_aux = reinterpret_cast( - dst_stencil.pSubresourceParameters - ); + dst_stencil.pSubresourceParameters + ); wis::span subresource_params{ subresources + offset, @@ -583,13 +583,14 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListBeginRenderPass( subresource_params[j] = { .SrcSubresource = aux->base_stencil_subresource + j * aux->subresource_stride, .DstSubresource = (dst_stencil_aux ? dst_stencil_aux->base_stencil_subresource : 0) - + j * (dst_stencil_aux ? dst_stencil_aux->subresource_stride : 0), - .SrcRect = { - .left = 0, - .top = 0, - .right = static_cast(width), - .bottom = static_cast(height), - }, + + j * (dst_stencil_aux ? dst_stencil_aux->subresource_stride : 0), + .SrcRect = + { + .left = 0, + .top = 0, + .right = static_cast(width), + .bottom = static_cast(height), + }, }; } depth_stencil.StencilEndingAccess.Resolve.pSubresourceParameters = subresource_params.data(); @@ -688,7 +689,7 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListCopyBufferToTexture( uint32_t plane_slice = wis::detail::DX12GetCopyPlaneSlice(region.texture_region.flags, subresource.plane_slice); uint32_t dst_subresource = subresource.mip_level + subresource.array_layer * texture_desc.MipLevels - + plane_slice * texture_desc.MipLevels * texture_desc.DepthOrArraySize; + + plane_slice * texture_desc.MipLevels * texture_desc.DepthOrArraySize; D3D12_TEXTURE_COPY_LOCATION dst_location{ .pResource = dst, .Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, @@ -755,7 +756,7 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListCopyTextureToBuffer( uint32_t plane_slice = wis::detail::DX12GetCopyPlaneSlice(region.texture_region.flags, subresource.plane_slice); uint32_t src_subresource = subresource.mip_level + subresource.array_layer * texture_desc.MipLevels - + plane_slice * texture_desc.MipLevels * texture_desc.DepthOrArraySize; + + plane_slice * texture_desc.MipLevels * texture_desc.DepthOrArraySize; D3D12_TEXTURE_COPY_LOCATION src_location{ .pResource = src, .Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, @@ -830,18 +831,18 @@ WIS_EXTERN_C WISDOM_API void wisDX12CommandListCopyTexture( const auto& dst_subresource = region.dst_region.target_subresource; uint32_t src_plane_slice = wis::detail::DX12GetCopyPlaneSlice( - region.src_region.flags, - src_subresource.plane_slice - ); + region.src_region.flags, + src_subresource.plane_slice + ); uint32_t src_subresource_index = src_subresource.mip_level + src_subresource.array_layer * src_desc.MipLevels - + src_plane_slice * src_desc.MipLevels * src_desc.DepthOrArraySize; + + src_plane_slice * src_desc.MipLevels * src_desc.DepthOrArraySize; uint32_t dst_plane_slice = wis::detail::DX12GetCopyPlaneSlice( - region.dst_region.flags, - dst_subresource.plane_slice - ); + region.dst_region.flags, + dst_subresource.plane_slice + ); uint32_t dst_subresource_index = dst_subresource.mip_level + dst_subresource.array_layer * dst_desc.MipLevels - + dst_plane_slice * dst_desc.MipLevels * dst_desc.DepthOrArraySize; + + dst_plane_slice * dst_desc.MipLevels * dst_desc.DepthOrArraySize; D3D12_TEXTURE_COPY_LOCATION dst_location{ .pResource = dst, diff --git a/src/include/wisdom/dx12/dx12_command_queue.cpp b/src/include/wisdom/dx12/dx12_command_queue.cpp index d8912c6eb..b5f7d6876 100644 --- a/src/include/wisdom/dx12/dx12_command_queue.cpp +++ b/src/include/wisdom/dx12/dx12_command_queue.cpp @@ -20,11 +20,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12DestroyCommandQueue(WisDX12CommandQueue* sel } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12CommandQueueSubmit( - const WisDX12CommandQueue* self, - const WisDX12CommandListView* lists, - size_t count -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12CommandQueueSubmit(const WisDX12CommandQueue* self, const WisDX12CommandListView* lists, size_t count) { auto& [queue] = wis::from_handle_ref(self); queue->ExecuteCommandLists(static_cast(count), reinterpret_cast(lists)); @@ -32,11 +29,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12CommandQueueSubmit( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12CommandQueueSignalFence( - const WisDX12CommandQueue* self, - WisDX12FenceView fence, - uint64_t value -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12CommandQueueSignalFence(const WisDX12CommandQueue* self, WisDX12FenceView fence, uint64_t value) { auto& [queue] = wis::from_handle_ref(self); auto hr = queue->Signal(std::bit_cast(fence), value); @@ -48,11 +42,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12CommandQueueSignalFence( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12CommandQueueWaitFence( - const WisDX12CommandQueue* self, - WisDX12FenceView fence, - uint64_t value -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12CommandQueueWaitFence(const WisDX12CommandQueue* self, WisDX12FenceView fence, uint64_t value) { auto& [queue] = wis::from_handle_ref(self); auto hr = queue->Wait(std::bit_cast(fence), value); diff --git a/src/include/wisdom/dx12/dx12_descriptor_heap.cpp b/src/include/wisdom/dx12/dx12_descriptor_heap.cpp index 99139c86d..aac4e712f 100644 --- a/src/include/wisdom/dx12/dx12_descriptor_heap.cpp +++ b/src/include/wisdom/dx12/dx12_descriptor_heap.cpp @@ -37,13 +37,13 @@ inline DXGI_FORMAT DX12GetSRVFormat(const WisTextureBinding& binding) noexcept inline uint32_t DX12GetComponentMapping(WisComponentMapping mapping) noexcept { uint32_t r = mapping.r ? wis::detail::DX12Convert(mapping.r) - : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0; + : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0; uint32_t g = mapping.g ? wis::detail::DX12Convert(mapping.g) - : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1; + : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1; uint32_t b = mapping.b ? wis::detail::DX12Convert(mapping.b) - : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2; + : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2; uint32_t a = mapping.a ? wis::detail::DX12Convert(mapping.a) - : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3; + : D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3; return D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(r, g, b, a); } @@ -215,7 +215,7 @@ inline void DX12FillRTVAuxData( // even though RT can be non-array, it may be a part of array uint32_t base_subresource = render_target.mip_level + mip_levels * render_target.base_array_layer - + plane_stride * plane_slice; + + plane_stride * plane_slice; switch (render_target.layout) { default: @@ -284,7 +284,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteConstantBuffer( }; heap.device->CreateConstantBufferView( &cbv_desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -304,17 +304,18 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteStructuredBuffer( .Format = DXGI_FORMAT_UNKNOWN, // must be UNKNOWN for structured buffers .ViewDimension = D3D12_SRV_DIMENSION_BUFFER, .Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, - .Buffer = { - .FirstElement = data->array_offset, - .NumElements = data->structure_count, - .StructureByteStride = data->stride_bytes, - .Flags = D3D12_BUFFER_SRV_FLAG_NONE, - }, + .Buffer = + { + .FirstElement = data->array_offset, + .NumElements = data->structure_count, + .StructureByteStride = data->stride_bytes, + .Flags = D3D12_BUFFER_SRV_FLAG_NONE, + }, }; heap.device->CreateShaderResourceView( resource, &srv_desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -333,45 +334,43 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteRWStructuredBuffer( D3D12_UNORDERED_ACCESS_VIEW_DESC uav_desc{ .Format = DXGI_FORMAT_UNKNOWN, // must be UNKNOWN for structured buffers .ViewDimension = D3D12_UAV_DIMENSION_BUFFER, - .Buffer = { - .FirstElement = data->array_offset, - .NumElements = data->structure_count, - .StructureByteStride = data->stride_bytes, - .Flags = D3D12_BUFFER_UAV_FLAG_NONE, - }, + .Buffer = + { + .FirstElement = data->array_offset, + .NumElements = data->structure_count, + .StructureByteStride = data->stride_bytes, + .Flags = D3D12_BUFFER_UAV_FLAG_NONE, + }, }; heap.device->CreateUnorderedAccessView( resource, nullptr, &uav_desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteSampler( - const WisDX12DescriptorHeap* self, - const WisSamplerDesc* sampler, - uint32_t index -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12DescriptorHeapWriteSampler(const WisDX12DescriptorHeap* self, const WisSamplerDesc* sampler, uint32_t index) { auto& heap = wis::from_handle_ref(self); auto min_filter = !sampler->is_anisotropic ? wis::detail::DX12Convert(sampler->min_filter) - : D3D12_FILTER_TYPE_LINEAR; + : D3D12_FILTER_TYPE_LINEAR; auto mag_filter = !sampler->is_anisotropic ? wis::detail::DX12Convert(sampler->mag_filter) - : D3D12_FILTER_TYPE_LINEAR; + : D3D12_FILTER_TYPE_LINEAR; auto reduction_mode = sampler->comparison_op != WisCompareOpNone - ? D3D12_FILTER_REDUCTION_TYPE::D3D12_FILTER_REDUCTION_TYPE_COMPARISON - : wis::detail::DX12Convert(sampler->reduction_mode); + ? D3D12_FILTER_REDUCTION_TYPE::D3D12_FILTER_REDUCTION_TYPE_COMPARISON + : wis::detail::DX12Convert(sampler->reduction_mode); auto basic_filter = D3D12_ENCODE_BASIC_FILTER( - min_filter, - mag_filter, - wis::detail::DX12Convert(sampler->mip_filter), - reduction_mode - ); + min_filter, + mag_filter, + wis::detail::DX12Convert(sampler->mip_filter), + reduction_mode + ); auto filter = D3D12_FILTER(sampler->is_anisotropic * D3D12_ANISOTROPIC_FILTERING_BIT | basic_filter); constexpr static std::array border_colors[] = { @@ -395,7 +394,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteSampler( }; heap.device->CreateSampler( &sampler_desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -414,7 +413,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteTexture( heap.device->CreateShaderResourceView( resource, &desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -434,17 +433,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteRWTexture( resource, nullptr, &desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteAccelerationStructure( - const WisDX12DescriptorHeap* self, - uint64_t address, - uint32_t index -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12DescriptorHeapWriteAccelerationStructure(const WisDX12DescriptorHeap* self, uint64_t address, uint32_t index) { auto& heap = wis::from_handle_ref(self); D3D12_SHADER_RESOURCE_VIEW_DESC desc{ @@ -456,7 +452,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DescriptorHeapWriteAccelerationStructur heap.device->CreateShaderResourceView( nullptr, &desc, - {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} + {heap.cpu_handle.ptr + static_cast(index) * heap.descriptor_size} ); return wis::detail::dx_success; } @@ -473,9 +469,9 @@ WIS_EXTERN_C WISDOM_API void wisDX12DescriptorHeapCopyDescriptors( auto& heap = wis::from_handle_ref(self); heap.device->CopyDescriptorsSimple( count, - {heap.cpu_handle.ptr + static_cast(dst_index) * heap.descriptor_size}, - {std::bit_cast(src_ptr) + static_cast(src_index) * heap.descriptor_size}, - heap.type + {heap.cpu_handle.ptr + static_cast(dst_index) * heap.descriptor_size}, + {std::bit_cast(src_ptr) + static_cast(src_index) * heap.descriptor_size}, + heap.type ); } @@ -681,9 +677,9 @@ WIS_EXTERN_C WISDOM_API void wisDX12ViewHeapCopyViews( heap.device->CopyDescriptorsSimple( count, - {heap.cpu_handle.ptr + static_cast(dst_index) * heap.descriptor_size}, - {src_handle_ptr}, - heap.type + {heap.cpu_handle.ptr + static_cast(dst_index) * heap.descriptor_size}, + {src_handle_ptr}, + heap.type ); // copy aux data if present diff --git a/src/include/wisdom/dx12/dx12_device.cpp b/src/include/wisdom/dx12/dx12_device.cpp index 2b904064a..bf5eb8e72 100644 --- a/src/include/wisdom/dx12/dx12_device.cpp +++ b/src/include/wisdom/dx12/dx12_device.cpp @@ -34,19 +34,16 @@ WIS_EXTERN_C WISDOM_API void wisDX12DestroyDevice(WisDX12Device* self) } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateCommandQueue( - const WisDX12Device* self, - WisCommandQueueType type, - WisDX12CommandQueue* queue -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12DeviceCreateCommandQueue(const WisDX12Device* self, WisCommandQueueType type, WisDX12CommandQueue* queue) { auto& device = wis::from_handle_ref(self); bool supported = (device.queue_priorities[type] & ~0x7fu) != 0; if (!supported) { return wis::detail::make_result< - wis::detail::Func(), - "Requested command queue type is not supported or not enabled by the device">(E_INVALIDARG); + wis::detail::Func(), + "Requested command queue type is not supported or not enabled by the device">(E_INVALIDARG); } D3D12_COMMAND_QUEUE_DESC desc{ @@ -70,21 +67,18 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateCommandQueue( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateCommandAllocator( - const WisDX12Device* self, - WisCommandQueueType type, - WisDX12CommandAllocator* list -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12DeviceCreateCommandAllocator(const WisDX12Device* self, WisCommandQueueType type, WisDX12CommandAllocator* list) { WisResult result = wis::detail::dx_success; auto& device = wis::from_handle_ref(self); wis::com_ptr allocator; auto hr = device.device->CreateCommandAllocator( - wis::detail::DX12Convert(type), - IID_ID3D12CommandAllocator, - allocator.put_void_unchecked() - ); + wis::detail::DX12Convert(type), + IID_ID3D12CommandAllocator, + allocator.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -99,11 +93,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateCommandAllocator( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateFence( - const WisDX12Device* self, - uint64_t initial_value, - WisDX12Fence* fence -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12DeviceCreateFence(const WisDX12Device* self, uint64_t initial_value, WisDX12Fence* fence) { WisResult result = wis::detail::dx_success; auto& device = wis::from_handle_ref(self); @@ -111,7 +102,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateFence( wis::com_ptr out_fence; auto hr = device.device - ->CreateFence(initial_value, D3D12_FENCE_FLAG_NONE, IID_ID3D12Fence, out_fence.put_void_unchecked()); + ->CreateFence(initial_value, D3D12_FENCE_FLAG_NONE, IID_ID3D12Fence, out_fence.put_void_unchecked()); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -120,8 +111,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateFence( auto event_handle = CreateEventW(nullptr, false, false, nullptr); if (!event_handle) { return wis::detail::make_result( - HRESULT_FROM_WIN32(GetLastError()) - ); + HRESULT_FROM_WIN32(GetLastError()) + ); } auto& internal = *new (fence) wis::impl::DX12FenceImpl{ @@ -132,10 +123,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateFence( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceGetResourceAllocator( - const WisDX12Device* self, - WisDX12ResourceAllocator* allocator -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12DeviceGetResourceAllocator(const WisDX12Device* self, WisDX12ResourceAllocator* allocator) { auto& device = wis::from_handle_ref(self); @@ -167,7 +156,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateDescriptorHeap( wis::com_ptr descriptor_heap; HRESULT hr = device.device - ->CreateDescriptorHeap(&heap_desc, IID_ID3D12DescriptorHeap, descriptor_heap.put_void_unchecked()); + ->CreateDescriptorHeap(&heap_desc, IID_ID3D12DescriptorHeap, descriptor_heap.put_void_unchecked()); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -205,7 +194,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateViewHeap( wis::com_ptr descriptor_heap; HRESULT hr = device.device - ->CreateDescriptorHeap(&heap_desc, IID_ID3D12DescriptorHeap, descriptor_heap.put_void_unchecked()); + ->CreateDescriptorHeap(&heap_desc, IID_ID3D12DescriptorHeap, descriptor_heap.put_void_unchecked()); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -221,12 +210,12 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateViewHeap( && "[INTERNAL ERROR] DescriptorHandle is not aligned! Report the issue to the developers." ); - aux_data = new (std::nothrow) wis::detail::DX12RenderTargetViewAuxData[capacity] {}; + aux_data = new (std::nothrow) wis::detail::DX12RenderTargetViewAuxData[capacity]{}; if (!aux_data) { raw_heap->Release(); return wis::detail::make_result( - E_OUTOFMEMORY - ); + E_OUTOFMEMORY + ); } for (uint32_t i = 0; i < capacity; ++i) { aux_data[i].handle = {cpu_handle.ptr + static_cast(i) * descriptor_size}; @@ -262,8 +251,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( const auto& push_constant = desc->push_constants[i]; if (push_constant.size_bytes % 4 != 0) { return wis::detail::make_result( - E_INVALIDARG - ); + E_INVALIDARG + ); } push_constant_size += push_constant.size_bytes; } @@ -271,14 +260,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( // Check limits if (push_constant_size + 2 * desc->push_descriptor_count + desc->descriptor_table_count > max_root_parameters) { - return wis::detail::make_result( - E_INVALIDARG - ); + return wis::detail::make_result(E_INVALIDARG + ); } D3D12_ROOT_PARAMETER1 root_parameters[max_root_parameters]; std::size_t num_root_parameters = desc->push_constant_count + desc->push_descriptor_count - + desc->descriptor_table_count; + + desc->descriptor_table_count; wis::span root_parameters_span{root_parameters, num_root_parameters}; // Push constants @@ -287,11 +275,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( root_parameters_span[i] = { .ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS, .Constants = - { - .ShaderRegister = static_cast(src.bind_register), - .RegisterSpace = static_cast(src.bind_space), - .Num32BitValues = static_cast(src.size_bytes / 4), - }, + { + .ShaderRegister = static_cast(src.bind_register), + .RegisterSpace = static_cast(src.bind_space), + .Num32BitValues = static_cast(src.size_bytes / 4), + }, .ShaderVisibility = wis::detail::DX12Convert(src.visibility), }; } @@ -302,19 +290,19 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( auto& src = desc->push_descriptors[i]; if (!wis::detail::DX12IsPushable(src.type)) { - return wis::detail::make_result< - wis::detail::Func(), - "Descriptor type is not pushable to DX12 root signature">(E_INVALIDARG); + return wis::detail:: + make_result(E_INVALIDARG + ); } root_parameters_span[i] = { .ParameterType = wis::detail::DX12RootParameterType(src.type), .Descriptor = - { - .ShaderRegister = src.bind_register, - .RegisterSpace = src.bind_space, - .Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - }, + { + .ShaderRegister = src.bind_register, + .RegisterSpace = src.bind_space, + .Flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, + }, .ShaderVisibility = wis::detail::DX12Convert(src.visibility), }; } @@ -335,8 +323,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( ranges = wis::make_unique(range_count); if (!ranges) { return wis::detail::make_result( - E_OUTOFMEMORY - ); + E_OUTOFMEMORY + ); } wis::span ranges_span{ranges.get(), range_count}; @@ -352,7 +340,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( .BaseShaderRegister = src.bind_register, .RegisterSpace = src.bind_space, .Flags = src.count > 1 ? D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE - : D3D12_DESCRIPTOR_RANGE_FLAG_NONE, + : D3D12_DESCRIPTOR_RANGE_FLAG_NONE, .OffsetInDescriptorsFromTableStart = src.descriptor_offset, }; } @@ -360,10 +348,10 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( root_parameters_span[i] = { .ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, .DescriptorTable = - { - .NumDescriptorRanges = static_cast(table.entry_count), - .pDescriptorRanges = ranges.get() + range_offset, - }, + { + .NumDescriptorRanges = static_cast(table.entry_count), + .pDescriptorRanges = ranges.get() + range_offset, + }, .ShaderVisibility = wis::detail::DX12Convert(table.visibility), }; range_offset += table.entry_count; @@ -372,13 +360,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( D3D12_VERSIONED_ROOT_SIGNATURE_DESC rsig_desc{ .Version = D3D_ROOT_SIGNATURE_VERSION_1_2, - .Desc_1_2 = { - .NumParameters = static_cast(num_root_parameters), - .pParameters = root_parameters, - .NumStaticSamplers = 0, - .pStaticSamplers = nullptr, - .Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT, - }, + .Desc_1_2 = + { + .NumParameters = static_cast(num_root_parameters), + .pParameters = root_parameters, + .NumStaticSamplers = 0, + .pStaticSamplers = nullptr, + .Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT, + }, }; wis::com_ptr signature; @@ -412,12 +401,12 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( wis::com_ptr root_signature; hr = device.device->CreateRootSignature( - 0, - signature->GetBufferPointer(), - signature->GetBufferSize(), - IID_ID3D12RootSignature, - root_signature.put_void_unchecked() - ); + 0, + signature->GetBufferPointer(), + signature->GetBufferSize(), + IID_ID3D12RootSignature, + root_signature.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -426,7 +415,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateRootSignature( XXH128_hash_t hash = XXH3_128bits(signature->GetBufferPointer(), signature->GetBufferSize()); wis::detail::DX12RootSignatureKey key{.hash{hash.low64, hash.high64}}; root_signature - ->SetPrivateData(wis::detail::DX12RootSignatureKey::guid, sizeof(wis::detail::DX12RootSignatureKey), &key); + ->SetPrivateData(wis::detail::DX12RootSignatureKey::guid, sizeof(wis::detail::DX12RootSignatureKey), &key); auto& layout_impl = *new (layout) wis::impl::DX12RootSignatureImpl{.root_signature = root_signature.detach()}; return res; @@ -453,54 +442,50 @@ WIS_EXTERN_C WISDOM_API void wisDX12DeviceQueryProperties(const WisDX12Device* s props->max_queue_priority[i] = WisCommandQueuePriority(device.queue_priorities[i] & 0x7f); } props->relaxed_queue_transition = true; - } - break; + } break; case WisQueryPropertyTypeDeviceDescriptorHeapProperties: { auto* props = static_cast(next); D3D12_FEATURE_DATA_D3D12_OPTIONS19 options19 = {}; if (wis::detail::succeeded( - device.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS19, &options19, sizeof(options19)) - )) { + device.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS19, &options19, sizeof(options19)) + )) { props->max_descriptor_heap_size = options19.MaxViewDescriptorHeapSize; props->max_sampler_heap_size = options19.MaxSamplerDescriptorHeapSize; props->max_sampler_heap_size_with_embedded = options19.MaxSamplerDescriptorHeapSizeWithStaticSamplers; props->descriptor_increment_size = device.device->GetDescriptorHandleIncrementSize( - D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV - ); + D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV + ); props->sampler_increment_size = device.device->GetDescriptorHandleIncrementSize( - D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER - ); + D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER + ); props->render_target_increment_size = device.device->GetDescriptorHandleIncrementSize( - D3D12_DESCRIPTOR_HEAP_TYPE_RTV - ); + D3D12_DESCRIPTOR_HEAP_TYPE_RTV + ); props->depth_stencil_increment_size = device.device->GetDescriptorHandleIncrementSize( - D3D12_DESCRIPTOR_HEAP_TYPE_DSV - ); + D3D12_DESCRIPTOR_HEAP_TYPE_DSV + ); props->render_target_with_ms_increment_size = sizeof(wis::detail::DX12RenderTargetViewAuxData); props->depth_stencil_with_ms_increment_size = sizeof(wis::detail::DX12RenderTargetViewAuxData); } - } - break; + } break; case WisQueryPropertyTypeDeviceMemoryProperties: { auto* props = static_cast(next); D3D12_FEATURE_DATA_D3D12_OPTIONS16 options16 = {}; if (wis::detail::succeeded( - device.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS16, &options16, sizeof(options16)) - )) { + device.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS16, &options16, sizeof(options16)) + )) { props->gpu_upload_supported = options16.GPUUploadHeapSupported; props->host_image_copy_supported = options16.GPUUploadHeapSupported; } - } - break; + } break; case WisQueryPropertyTypeDeviceBindingProperties: { auto* props = static_cast(next); props->max_vertex_input_bindings = D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; props->max_vertex_input_attributes = D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT; props->multiple_viewports_supported = true; // D3D12 supports up to 16 viewports and scissor rectangles props->address_commands_supported = true; // D3D12 supports buffer address commands - } - break; + } break; default: break; } @@ -523,17 +508,17 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceWaitForMultipleFences( HANDLE event_handle = CreateEventW(nullptr, false, false, nullptr); if (!event_handle) { return wis::detail::make_result( - HRESULT_FROM_WIN32(GetLastError()) - ); + HRESULT_FROM_WIN32(GetLastError()) + ); } auto hr = device.device->SetEventOnMultipleFenceCompletion( - reinterpret_cast(fences), - fence_values, - static_cast(fence_count), - static_cast(wait_for), - event_handle - ); + reinterpret_cast(fences), + fence_values, + static_cast(fence_count), + static_cast(wait_for), + event_handle + ); CloseHandle(event_handle); @@ -558,8 +543,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreatePipelineCache( data_copy = static_cast(malloc(data_size)); if (!data_copy) { return wis::detail::make_result( - E_OUTOFMEMORY - ); + E_OUTOFMEMORY + ); } std::memcpy(data_copy, initial_data, data_size); } @@ -567,11 +552,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreatePipelineCache( wis::com_ptr pipeline_library; auto hr = device.device->CreatePipelineLibrary( - data_copy, - data_size, - IID_ID3D12PipelineLibrary1, - pipeline_library.put_void_unchecked() - ); + data_copy, + data_size, + IID_ID3D12PipelineLibrary1, + pipeline_library.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { free(data_copy); @@ -586,12 +571,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreatePipelineCache( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateShader( - const WisDX12Device* self, - const uint8_t* data, - size_t size, - WisDX12Shader* shader -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12DeviceCreateShader(const WisDX12Device* self, const uint8_t* data, size_t size, WisDX12Shader* shader) { if (!data || size == 0) { return wis::detail::make_result(E_INVALIDARG); @@ -600,12 +581,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateShader( auto& device = wis::from_handle_ref(self); std::unique_ptr shader_header{reinterpret_cast( - operator new(wis::aligned_size(size, 8ull) + sizeof(wis::detail::DX12ShaderHeader), std::nothrow) - )}; + operator new(wis::aligned_size(size, 8ull) + sizeof(wis::detail::DX12ShaderHeader), std::nothrow) + )}; if (!shader_header) { - return wis::detail::make_result( - E_OUTOFMEMORY - ); + return wis::detail::make_result(E_OUTOFMEMORY + ); } std::construct_at(shader_header.get()); @@ -641,14 +621,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateComputePipeline( // Validate root signature if (!rootsig) { return wis::detail::make_result< - wis::detail::Func(), - "Invalid root signature provided for compute pipeline creation">(E_INVALIDARG); + wis::detail::Func(), + "Invalid root signature provided for compute pipeline creation">(E_INVALIDARG); } // Validate shader if (!shader) { return wis::detail::make_result( - E_INVALIDARG - ); + E_INVALIDARG + ); } auto bytecode = shader->GetBytecode(); @@ -698,11 +678,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateComputePipeline( // Try to load pipeline from cache first if available HRESULT hr = cache->LoadPipeline( - name_buffer, - &pso_desc, - IID_ID3D12PipelineState, - pipeline_state.put_void_unchecked() - ); + name_buffer, + &pso_desc, + IID_ID3D12PipelineState, + pipeline_state.put_void_unchecked() + ); if (wis::detail::succeeded(hr)) { auto& pipeline_impl = *new (pipeline) wis::impl::DX12PipelineImpl{ .pipeline_state = pipeline_state.detach(), @@ -713,13 +693,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateComputePipeline( // Cache miss if (desc->flags & WisPipelineFlagsFailOnCacheMiss) { return wis::detail::make_result< - wis::detail::Func(), - "Pipeline not found in cache and creation is set to fail on cache miss">(WisStatusError, E_FAIL); + wis::detail::Func(), + "Pipeline not found in cache and creation is set to fail on cache miss">(WisStatusError, E_FAIL); } } auto hr = device.device - ->CreatePipelineState(&pso_desc, IID_ID3D12PipelineState, pipeline_state.put_void_unchecked()); + ->CreatePipelineState(&pso_desc, IID_ID3D12PipelineState, pipeline_state.put_void_unchecked()); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -747,8 +727,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( auto* rootsig = std::bit_cast(desc->root_signature); if (!rootsig) { return wis::detail::make_result< - wis::detail::Func(), - "Invalid root signature provided for graphics pipeline creation">(E_INVALIDARG); + wis::detail::Func(), + "Invalid root signature provided for graphics pipeline creation">(E_INVALIDARG); } struct GraphicsPipelineStream { @@ -775,8 +755,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( } stream{ .root_signature = rootsig, .flags = desc->flags & WisPipelineFlagsEnablePrimitiveRestart - ? D3D12_PIPELINE_STATE_FLAG_DYNAMIC_INDEX_BUFFER_STRIP_CUT - : D3D12_PIPELINE_STATE_FLAG_NONE, + ? D3D12_PIPELINE_STATE_FLAG_DYNAMIC_INDEX_BUFFER_STRIP_CUT + : D3D12_PIPELINE_STATE_FLAG_NONE, }; static constexpr size_t shader_stage_count = 5; @@ -794,7 +774,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( stream.vertex_shader = {{bytecode.data(), bytecode.size()}}; } else { return wis::detail:: - make_result(E_INVALIDARG); + make_result(E_INVALIDARG); } if (auto ps = shader_headers[1]) { auto bytecode = ps->GetBytecode(); @@ -816,7 +796,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( //--Render targets if (desc->render_attachments.attachments_count > wis::MaxRenderTargets) { return wis::detail:: - make_result(E_INVALIDARG); + make_result(E_INVALIDARG); } D3D12_RT_FORMAT_ARRAY& rtv_formats = stream.rtv_formats; @@ -829,7 +809,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( } //--Multiview - D3D12_VIEW_INSTANCE_LOCATION view_locs[wis::MaxRenderTargets] {}; + D3D12_VIEW_INSTANCE_LOCATION view_locs[wis::MaxRenderTargets]{}; if (desc->render_attachments.view_mask) { uint32_t view_mask = desc->render_attachments.view_mask; for (uint32_t i = 0u; i < wis::MaxRenderTargets; i++) { @@ -852,7 +832,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( //--Input layout wis::span slots{desc->input_layout.bindings, desc->input_layout.binding_count}; wis::span attrs{desc->input_layout.attributes, desc->input_layout.attribute_count}; - D3D12_INPUT_ELEMENT_DESC reasonable_max_input_elements[wis::MinSupportedInputAttributes * 2] {}; + D3D12_INPUT_ELEMENT_DESC reasonable_max_input_elements[wis::MinSupportedInputAttributes * 2]{}; std::unique_ptr input_elements; wis::span input_elements_span; if (!slots.empty() && !attrs.empty()) { @@ -892,16 +872,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( } stream.rasterizer = CD3DX12_RASTERIZER_DESC2{D3D12_RASTERIZER_DESC2{ - .FillMode = wis::detail::DX12Convert(raster.fill_mode), - .CullMode = wis::detail::DX12Convert(raster.cull_mode), - .FrontCounterClockwise = wis::detail::DX12Convert(raster.front_face), - .DepthBias = bias ? raster.depth_bias : 0.0f, - .DepthBiasClamp = bias ? raster.depth_bias_clamp : 0.0f, - .SlopeScaledDepthBias = bias ? raster.depth_bias_slope_factor : 0.0f, - .DepthClipEnable = raster.depth_clip_enable, - .LineRasterizationMode = wis::detail::DX12Convert(raster.line_rasterization), - .ConservativeRaster = wis::detail::DX12Convert(raster.conservative_rasterization) - }}; + .FillMode = wis::detail::DX12Convert(raster.fill_mode), + .CullMode = wis::detail::DX12Convert(raster.cull_mode), + .FrontCounterClockwise = wis::detail::DX12Convert(raster.front_face), + .DepthBias = bias ? raster.depth_bias : 0.0f, + .DepthBiasClamp = bias ? raster.depth_bias_clamp : 0.0f, + .SlopeScaledDepthBias = bias ? raster.depth_bias_slope_factor : 0.0f, + .DepthClipEnable = raster.depth_clip_enable, + .LineRasterizationMode = wis::detail::DX12Convert(raster.line_rasterization), + .ConservativeRaster = wis::detail::DX12Convert(raster.conservative_rasterization) + }}; } //--Multisample @@ -922,30 +902,29 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( if (desc->depth_stencil_desc) { auto& ds = *desc->depth_stencil_desc; stream.depth_stencil = CD3DX12_DEPTH_STENCIL_DESC2{ - { .DepthEnable = ds.depth_enable, - .DepthWriteMask = D3D12_DEPTH_WRITE_MASK(ds.depth_write_enable), - .DepthFunc = wis::detail::DX12Convert(ds.depth_comp), - .StencilEnable = ds.stencil_enable, - .FrontFace = - D3D12_DEPTH_STENCILOP_DESC1{ - .StencilFailOp = wis::detail::DX12Convert(ds.stencil_front.fail_op), - .StencilDepthFailOp = wis::detail::DX12Convert(ds.stencil_front.depth_fail_op), - .StencilPassOp = wis::detail::DX12Convert(ds.stencil_front.pass_op), - .StencilFunc = wis::detail::DX12Convert(ds.stencil_front.stencil_comp), - .StencilReadMask = ds.stencil_front.read_mask, - .StencilWriteMask = ds.stencil_front.write_mask, - }, - .BackFace = - D3D12_DEPTH_STENCILOP_DESC1{ - .StencilFailOp = wis::detail::DX12Convert(ds.stencil_back.fail_op), - .StencilDepthFailOp = wis::detail::DX12Convert(ds.stencil_back.depth_fail_op), - .StencilPassOp = wis::detail::DX12Convert(ds.stencil_back.pass_op), - .StencilFunc = wis::detail::DX12Convert(ds.stencil_back.stencil_comp), - .StencilReadMask = ds.stencil_back.read_mask, - .StencilWriteMask = ds.stencil_back.write_mask, - }, - .DepthBoundsTestEnable = ds.depth_bound_test - } + {.DepthEnable = ds.depth_enable, + .DepthWriteMask = D3D12_DEPTH_WRITE_MASK(ds.depth_write_enable), + .DepthFunc = wis::detail::DX12Convert(ds.depth_comp), + .StencilEnable = ds.stencil_enable, + .FrontFace = + D3D12_DEPTH_STENCILOP_DESC1{ + .StencilFailOp = wis::detail::DX12Convert(ds.stencil_front.fail_op), + .StencilDepthFailOp = wis::detail::DX12Convert(ds.stencil_front.depth_fail_op), + .StencilPassOp = wis::detail::DX12Convert(ds.stencil_front.pass_op), + .StencilFunc = wis::detail::DX12Convert(ds.stencil_front.stencil_comp), + .StencilReadMask = ds.stencil_front.read_mask, + .StencilWriteMask = ds.stencil_front.write_mask, + }, + .BackFace = + D3D12_DEPTH_STENCILOP_DESC1{ + .StencilFailOp = wis::detail::DX12Convert(ds.stencil_back.fail_op), + .StencilDepthFailOp = wis::detail::DX12Convert(ds.stencil_back.depth_fail_op), + .StencilPassOp = wis::detail::DX12Convert(ds.stencil_back.pass_op), + .StencilFunc = wis::detail::DX12Convert(ds.stencil_back.stencil_comp), + .StencilReadMask = ds.stencil_back.read_mask, + .StencilWriteMask = ds.stencil_back.write_mask, + }, + .DepthBoundsTestEnable = ds.depth_bound_test} }; } else { // Fix for depth stencil @@ -1037,11 +1016,10 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( rehash_input.multiview_mask = desc->render_attachments.view_mask; // Hash pso stream - wis::span pso_stream_bytes{ - // start after bytecodes - reinterpret_cast(&stream.flags), - // end at the end of the struct - reinterpret_cast(&stream + 1) + wis::span pso_stream_bytes{// start after bytecodes + reinterpret_cast(&stream.flags), + // end at the end of the struct + reinterpret_cast(&stream + 1) }; XXH128_hash_t stream_hash = XXH3_128bits(pso_stream_bytes.data(), pso_stream_bytes.size()); rehash_input.pso_hash[0] = stream_hash.low64; @@ -1061,11 +1039,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( // Try to load pipeline from cache first if available HRESULT hr = cache->LoadPipeline( - name_buffer, - &psstream_desc, - IID_ID3D12PipelineState, - pipeline_state.put_void_unchecked() - ); + name_buffer, + &psstream_desc, + IID_ID3D12PipelineState, + pipeline_state.put_void_unchecked() + ); if (wis::detail::succeeded(hr)) { auto& pipeline_impl = *new (pipeline) wis::impl::DX12PipelineImpl{ .pipeline_state = pipeline_state.detach(), @@ -1076,16 +1054,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateGraphicsPipeline( // Cache miss if (desc->flags & WisPipelineFlagsFailOnCacheMiss) { return wis::detail::make_result< - wis::detail::Func(), - "Pipeline not found in cache and creation is set to fail on cache miss">(WisStatusError, E_FAIL); + wis::detail::Func(), + "Pipeline not found in cache and creation is set to fail on cache miss">(WisStatusError, E_FAIL); } } HRESULT hr = device.device->CreatePipelineState( - &psstream_desc, - IID_ID3D12PipelineState, - pipeline_state.put_void_unchecked() - ); + &psstream_desc, + IID_ID3D12PipelineState, + pipeline_state.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -1120,11 +1098,8 @@ WIS_EXTERN_C WISDOM_API bool wisDX12DeviceGetFormatPresentationSupport( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceGetSurfaceParameters( - const WisDX12Device* self, - WisDX12SurfaceView surface, - WisSurfaceParameters* params -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12DeviceGetSurfaceParameters(const WisDX12Device* self, WisDX12SurfaceView surface, WisSurfaceParameters* params) { auto& impl = wis::from_handle_ref(self); *params = { @@ -1132,8 +1107,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceGetSurfaceParameters( .max_swapchain_images = DXGI_MAX_SWAP_CHAIN_BUFFERS, .alpha_modes_supported = 0b0000'1111, // Support all alpha modes (premultiplied, postmultiplied, opaque, custom) .texture_usage_flags_supported = static_cast( - WisTextureUsageFlagsRenderTarget | WisTextureUsageFlagsShaderResource | WisTextureUsageFlagsCopySrc - | WisTextureUsageFlagsCopyDst | WisTextureUsageFlagsUnorderedAccess + WisTextureUsageFlagsRenderTarget | WisTextureUsageFlagsShaderResource | WisTextureUsageFlagsCopySrc + | WisTextureUsageFlagsCopyDst | WisTextureUsageFlagsUnorderedAccess ), .stereo_supported = impl.factory->IsWindowedStereoEnabled() > 0, }; @@ -1158,8 +1133,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateSwapchain( BOOL xtearing = FALSE; device.factory->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &xtearing, sizeof(xtearing)); return bool(xtearing); - } - (); + }(); DXGI_USAGE usage = 0; switch (desc->texture_usage_flags) { @@ -1196,21 +1170,21 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateSwapchain( HRESULT hr = S_OK; if (surface_impl.uwp) { hr = device.factory->CreateSwapChainForCoreWindow( - queue_impl.queue, - static_cast(surface_impl.surface), - &swap_chain_desc, - nullptr, - swap_chain1.put_unchecked() - ); + queue_impl.queue, + static_cast(surface_impl.surface), + &swap_chain_desc, + nullptr, + swap_chain1.put_unchecked() + ); } else { hr = device.factory->CreateSwapChainForHwnd( - queue_impl.queue, - static_cast(surface_impl.surface), - &swap_chain_desc, - nullptr, - nullptr, - swap_chain1.put_unchecked() - ); + queue_impl.queue, + static_cast(surface_impl.surface), + &swap_chain_desc, + nullptr, + nullptr, + swap_chain1.put_unchecked() + ); } if (!wis::detail::succeeded(hr)) { @@ -1233,11 +1207,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceCreateSwapchain( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12DeviceGetFormatProperties( - const WisDX12Device* self, - WisDataFormat format, - WisFormatProperties* properties -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12DeviceGetFormatProperties(const WisDX12Device* self, WisDataFormat format, WisFormatProperties* properties) { auto& impl = wis::from_handle_ref(self); D3D12_FEATURE_DATA_FORMAT_SUPPORT formatSupport = {.Format = wis::detail::DX12Convert(format)}; diff --git a/src/include/wisdom/dx12/dx12_impl.cpp b/src/include/wisdom/dx12/dx12_impl.cpp index 04693d45d..43b6cfeca 100644 --- a/src/include/wisdom/dx12/dx12_impl.cpp +++ b/src/include/wisdom/dx12/dx12_impl.cpp @@ -90,20 +90,20 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12TextureWriteSubresource( UINT row_pitch = 0; UINT slice_pitch = 0; auto hr = D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::CalculateMinimumRowMajorRowPitch( - desc.Format, - target_region->box.width, - row_pitch - ); + desc.Format, + target_region->box.width, + row_pitch + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } hr = D3D12_PROPERTY_LAYOUT_FORMAT_TABLE::CalculateMinimumRowMajorSlicePitch( - desc.Format, - row_pitch, - target_region->box.height, - slice_pitch - ); + desc.Format, + row_pitch, + target_region->box.height, + slice_pitch + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); } @@ -117,12 +117,12 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12TextureWriteSubresource( .back = is_3d ? target_region->box.z + target_region->box.depth : 1, }; auto subresource = D3D12CalcSubresource( - target_region->target_subresource.mip_level, - target_region->target_subresource.array_layer, - target_region->target_subresource.plane_slice, - desc.MipLevels, - is_3d ? 1 : desc.DepthOrArraySize - ); + target_region->target_subresource.mip_level, + target_region->target_subresource.array_layer, + target_region->target_subresource.plane_slice, + desc.MipLevels, + is_3d ? 1 : desc.DepthOrArraySize + ); hr = resource->WriteToSubresource(subresource, &dst_box, source_data, row_pitch, slice_pitch); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); diff --git a/src/include/wisdom/dx12/dx12_instance.cpp b/src/include/wisdom/dx12/dx12_instance.cpp index 32c68488b..1e2df1bda 100644 --- a/src/include/wisdom/dx12/dx12_instance.cpp +++ b/src/include/wisdom/dx12/dx12_instance.cpp @@ -30,9 +30,9 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12CreateInstance( if (debug_layer) { wis::com_ptr debug_controller; auto hr2 = D3D12GetDebugInterface( - IID_ID3D12Debug, - reinterpret_cast(debug_controller.put_void_unchecked()) - ); + IID_ID3D12Debug, + reinterpret_cast(debug_controller.put_void_unchecked()) + ); if (wis::detail::succeeded(hr2)) { debug_controller->EnableDebugLayer(); wis::com_ptr debug_layer_impl{ @@ -51,7 +51,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12CreateInstance( }; WisResult res = wis::detail::dx_success; - for (auto* ext : wis::span {extensions, extension_count}) { + for (auto* ext : wis::span{extensions, extension_count}) { if (auto* table = wis::from_handle(ext); table && table->init_fptr) { res = table->init_fptr(table, impl); if (res.status != WisStatusOk) { @@ -80,11 +80,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12DestroyInstance(WisDX12Instance* self) } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12InstanceQueryAdapters( - const WisDX12Instance* self, - WisAdapterPreference preference, - WisDX12AdapterQuery* query -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12InstanceQueryAdapters(const WisDX12Instance* self, WisAdapterPreference preference, WisDX12AdapterQuery* query) { const auto& instance_impl = wis::from_handle_ref(self); wis::com_ptr factory_ref{instance_impl.factory}; // hold a reference @@ -103,11 +100,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12InstanceQueryAdapters( // Dynamic reallocation loop while (true) { auto hr = factory_ref->EnumAdapterByGpuPreference( - static_cast(count), - wis::detail::DX12Convert(preference), - IID_IDXGIAdapter4, - reinterpret_cast(adapters.get() + count) - ); + static_cast(count), + wis::detail::DX12Convert(preference), + IID_IDXGIAdapter4, + reinterpret_cast(adapters.get() + count) + ); if (hr == DXGI_ERROR_NOT_FOUND) { break; @@ -126,8 +123,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12InstanceQueryAdapters( auto new_adapters = wis::make_unique(capacity); if (!new_adapters) { return wis::detail::make_result( - E_OUTOFMEMORY - ); + E_OUTOFMEMORY + ); } std::memmove(new_adapters.get(), adapters.get(), count * sizeof(IDXGIAdapter4*)); diff --git a/src/include/wisdom/dx12/dx12_pipeline_cache.cpp b/src/include/wisdom/dx12/dx12_pipeline_cache.cpp index 2ceab33ed..06abe6c55 100644 --- a/src/include/wisdom/dx12/dx12_pipeline_cache.cpp +++ b/src/include/wisdom/dx12/dx12_pipeline_cache.cpp @@ -20,11 +20,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12DestroyPipelineCache(WisDX12PipelineCache* s } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12PipelineCacheSerialize( - const WisDX12PipelineCache* self, - uint8_t* data, - size_t data_size -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12PipelineCacheSerialize(const WisDX12PipelineCache* self, uint8_t* data, size_t data_size) { auto& [cache, xx] = wis::from_handle_ref(self); auto hr = cache->Serialize(data, data_size); diff --git a/src/include/wisdom/dx12/dx12_resource_allocator.cpp b/src/include/wisdom/dx12/dx12_resource_allocator.cpp index 6a9f2d63d..07f15e736 100644 --- a/src/include/wisdom/dx12/dx12_resource_allocator.cpp +++ b/src/include/wisdom/dx12/dx12_resource_allocator.cpp @@ -21,23 +21,23 @@ inline WisResult DX12CreateResource( { if (all_desc.HeapType == D3D12_HEAP_TYPE_GPU_UPLOAD && !allocator->IsGPUUploadHeapSupported()) { return wis::detail::make_result( - E_NOTIMPL - ); + E_NOTIMPL + ); } wis::com_ptr resource; wis::com_ptr allocation; HRESULT hr = allocator->CreateResource3( - &all_desc, - &res_desc, - initial_layout, - nullptr, - static_cast(cast_formats.size()), - cast_formats.data(), - allocation.put_unchecked(), - resource.iid(), - resource.put_void_unchecked() - ); + &all_desc, + &res_desc, + initial_layout, + nullptr, + static_cast(cast_formats.size()), + cast_formats.data(), + allocation.put_unchecked(), + resource.iid(), + resource.put_void_unchecked() + ); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); @@ -131,9 +131,9 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12ResourceAllocatorCreateBuffer( { auto& [allocator, device] = wis::from_handle_ref(self); uint64_t size = wis::aligned_size( - desc->size_bytes, - static_cast(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT) - ); + desc->size_bytes, + static_cast(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT) + ); D3D12_RESOURCE_DESC1 buffer_desc{ .Dimension = D3D12_RESOURCE_DIMENSION_BUFFER, .Alignment = 0, @@ -153,13 +153,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12ResourceAllocatorCreateBuffer( .HeapType = wis::detail::DX12Convert(desc->memory_type), }; return wis::detail::DX12CreateResource( - all_desc, - buffer_desc, - D3D12_BARRIER_LAYOUT_UNDEFINED, - allocator, - {}, - buffer - ); + all_desc, + buffer_desc, + D3D12_BARRIER_LAYOUT_UNDEFINED, + allocator, + {}, + buffer + ); } //---------------------------------------------------------------------------------------------------------------------- @@ -179,13 +179,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12ResourceAllocatorCreateTexture( // planar formats are uncastable if (desc->format >= WisDataFormatNV12) { return wis::detail::DX12CreateResource( - all_desc, - tex_desc, - D3D12_BARRIER_LAYOUT_UNDEFINED, - impl.allocator, - {}, - buffer - ); + all_desc, + tex_desc, + D3D12_BARRIER_LAYOUT_UNDEFINED, + impl.allocator, + {}, + buffer + ); } static constexpr uint32_t max_cast_formats = 16; @@ -221,22 +221,22 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12ResourceAllocatorCreateTexture( if (directly_mappable) { return wis::detail::DX12CreateResource( - all_desc, - tex_desc, - D3D12_BARRIER_LAYOUT_UNDEFINED, - impl.allocator, - {reinterpret_cast(desc->cast_formats), desc->cast_format_count}, - buffer - ); + all_desc, + tex_desc, + D3D12_BARRIER_LAYOUT_UNDEFINED, + impl.allocator, + {reinterpret_cast(desc->cast_formats), desc->cast_format_count}, + buffer + ); } return wis::detail::DX12CreateResource( - all_desc, - tex_desc, - D3D12_BARRIER_LAYOUT_UNDEFINED, - impl.allocator, - cast_formats_span, - buffer - ); + all_desc, + tex_desc, + D3D12_BARRIER_LAYOUT_UNDEFINED, + impl.allocator, + cast_formats_span, + buffer + ); } #endif // WIS_DX12_RESOURCE_ALLOCATOR_CPP diff --git a/src/include/wisdom/dx12/dx12_swapchain.cpp b/src/include/wisdom/dx12/dx12_swapchain.cpp index 5671c227b..4fdd87cc3 100644 --- a/src/include/wisdom/dx12/dx12_swapchain.cpp +++ b/src/include/wisdom/dx12/dx12_swapchain.cpp @@ -16,12 +16,8 @@ WIS_EXTERN_C WISDOM_API void wisDX12DestroySwapchain(WisDX12Swapchain* self) } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12SwapchainPresent( - const WisDX12Swapchain* self, - WisPresentFlags flags, - const WisRect* rects, - size_t rect_count -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12SwapchainPresent(const WisDX12Swapchain* self, WisPresentFlags flags, const WisRect* rects, size_t rect_count) { auto& swapchain = wis::from_handle_ref(self); UINT dx_flags = swapchain.vsync ? 0 : swapchain.flags & DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; @@ -50,8 +46,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12SwapchainPresent( if (hr == DXGI_ERROR_WAS_STILL_DRAWING) { return wis::detail::make_result< - wis::detail::Func(), - "Previous frame is still being presented, cannot present again yet">(WisStatusTimeout, hr); + wis::detail::Func(), + "Previous frame is still being presented, cannot present again yet">(WisStatusTimeout, hr); } if (!wis::detail::succeeded(hr)) { @@ -68,10 +64,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12SwapchainGetCurrentIndex(const WisDX12S } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12SwapchainUpdate( - const WisDX12Swapchain* self, - const WisSwapchainUpdateDesc* desc -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12SwapchainUpdate(const WisDX12Swapchain* self, const WisSwapchainUpdateDesc* desc) { auto& swapchain = wis::from_handle_ref(self); @@ -91,7 +85,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12SwapchainUpdate( } auto hr = swapchain.swapchain - ->ResizeBuffers(image_count, width, height, wis::detail::DX12Convert(desc->format), swapchain.flags); + ->ResizeBuffers(image_count, width, height, wis::detail::DX12Convert(desc->format), swapchain.flags); if (!wis::detail::succeeded(hr)) { return wis::detail::make_result(hr); @@ -104,17 +98,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisDX12SwapchainUpdate( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisDX12SwapchainGetTextures( - const WisDX12Swapchain* self, - WisDX12Texture* buffers, - size_t buffer_count -) +WIS_EXTERN_C WISDOM_API WisResult +wisDX12SwapchainGetTextures(const WisDX12Swapchain* self, WisDX12Texture* buffers, size_t buffer_count) { auto& impl = wis::from_handle_ref(self); if (buffer_count < impl.backbuffer_count) { return wis::detail::make_result< - wis::detail::Func(), - "Provided buffer count is less than the number of swapchain backbuffers">(E_INVALIDARG); + wis::detail::Func(), + "Provided buffer count is less than the number of swapchain backbuffers">(E_INVALIDARG); } for (uint32_t i = 0; i < impl.backbuffer_count; i++) { diff --git a/src/include/wisdom/generated/c_api.h b/src/include/wisdom/generated/c_api.h index 8de7f22c8..27a008d61 100644 --- a/src/include/wisdom/generated/c_api.h +++ b/src/include/wisdom/generated/c_api.h @@ -3198,11 +3198,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12CreateInstance( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12InstanceQueryAdapters( - const WisDX12Instance* self, - WisAdapterPreference preference, - WisDX12AdapterQuery* query -); +WIS_INLINE WISDOM_API WisResult +wisDX12InstanceQueryAdapters(const WisDX12Instance* self, WisAdapterPreference preference, WisDX12AdapterQuery* query); /** * @brief Provided by Wisdom 0.7.0. Returns the number of adapters present on the system at the time of the query. @@ -3221,11 +3218,8 @@ WIS_INLINE WISDOM_API size_t wisDX12AdapterQueryGetAdapterCount(const WisDX12Ada * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12AdapterQueryGetAdapterDesc( - const WisDX12AdapterQuery* self, - size_t index, - WisAdapterDesc* desc -); +WIS_INLINE WISDOM_API WisResult +wisDX12AdapterQueryGetAdapterDesc(const WisDX12AdapterQuery* self, size_t index, WisAdapterDesc* desc); /** * @brief Provided by Wisdom 0.7.0. Checks if the adapter at given index supports presentation to given surface. @@ -3268,11 +3262,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12AdapterQueryCreateDevice( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12DeviceCreateCommandQueue( - const WisDX12Device* self, - WisCommandQueueType type, - WisDX12CommandQueue* queue -); +WIS_INLINE WISDOM_API WisResult +wisDX12DeviceCreateCommandQueue(const WisDX12Device* self, WisCommandQueueType type, WisDX12CommandQueue* queue); /** * @brief Provided by Wisdom 0.7.0. Creates a command allocator to allocate command lists with. @@ -3296,11 +3287,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12DeviceCreateCommandAllocator( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12DeviceCreateFence( - const WisDX12Device* self, - uint64_t initial_value, - WisDX12Fence* fence -); +WIS_INLINE WISDOM_API WisResult +wisDX12DeviceCreateFence(const WisDX12Device* self, uint64_t initial_value, WisDX12Fence* fence); /** * @brief Provided by Wisdom 0.7.0. Creates a resource allocator for managing GPU resources. @@ -3309,10 +3297,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12DeviceCreateFence( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12DeviceGetResourceAllocator( - const WisDX12Device* self, - WisDX12ResourceAllocator* allocator -); +WIS_INLINE WISDOM_API WisResult +wisDX12DeviceGetResourceAllocator(const WisDX12Device* self, WisDX12ResourceAllocator* allocator); /** * @brief Provided by Wisdom 0.7.0. Creates a pipeline layout with given descriptor. @@ -3416,12 +3402,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12DeviceCreatePipelineCache( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12DeviceCreateShader( - const WisDX12Device* self, - const uint8_t* data, - size_t size, - WisDX12Shader* shader -); +WIS_INLINE WISDOM_API WisResult +wisDX12DeviceCreateShader(const WisDX12Device* self, const uint8_t* data, size_t size, WisDX12Shader* shader); /** * @brief Provided by Wisdom 0.7.0. Creates a compute pipeline state object with given descriptor. @@ -3474,11 +3456,8 @@ WIS_INLINE WISDOM_API bool wisDX12DeviceGetFormatPresentationSupport( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12DeviceGetSurfaceParameters( - const WisDX12Device* self, - WisDX12SurfaceView surface, - WisSurfaceParameters* params -); +WIS_INLINE WISDOM_API WisResult +wisDX12DeviceGetSurfaceParameters(const WisDX12Device* self, WisDX12SurfaceView surface, WisSurfaceParameters* params); /** * @brief Provided by Wisdom 0.7.0. Creates a swapchain for given surface with given descriptor. @@ -3507,11 +3486,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12DeviceCreateSwapchain( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12DeviceGetFormatProperties( - const WisDX12Device* self, - WisDataFormat format, - WisFormatProperties* properties -); +WIS_INLINE WISDOM_API WisResult +wisDX12DeviceGetFormatProperties(const WisDX12Device* self, WisDataFormat format, WisFormatProperties* properties); /** * @brief Provided by Wisdom 0.7.0. Get the current value of the fence. @@ -3548,11 +3524,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12FenceSignal(const WisDX12Fence* self, uin * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12CommandQueueSubmit( - const WisDX12CommandQueue* self, - const WisDX12CommandListView* lists, - size_t list_count -); +WIS_INLINE WISDOM_API WisResult +wisDX12CommandQueueSubmit(const WisDX12CommandQueue* self, const WisDX12CommandListView* lists, size_t list_count); /** * @brief Provided by Wisdom 0.7.0. Enqueue the signal to the queue, that gets executed after all the work has been @@ -3563,11 +3536,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12CommandQueueSubmit( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12CommandQueueSignalFence( - const WisDX12CommandQueue* self, - WisDX12FenceView fence, - uint64_t value -); +WIS_INLINE WISDOM_API WisResult +wisDX12CommandQueueSignalFence(const WisDX12CommandQueue* self, WisDX12FenceView fence, uint64_t value); /** * @brief Provided by Wisdom 0.7.0. Enqueues wait operation to the command queue. Queue then waits for the fence to be @@ -3578,11 +3548,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12CommandQueueSignalFence( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12CommandQueueWaitFence( - const WisDX12CommandQueue* self, - WisDX12FenceView fence, - uint64_t value -); +WIS_INLINE WISDOM_API WisResult +wisDX12CommandQueueWaitFence(const WisDX12CommandQueue* self, WisDX12FenceView fence, uint64_t value); /** * @brief Provided by Wisdom 0.7.0. Creates a buffer with given descriptor. @@ -3707,11 +3674,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12DescriptorHeapWriteRWStructuredBuffer( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12DescriptorHeapWriteSampler( - const WisDX12DescriptorHeap* self, - const WisSamplerDesc* sampler, - uint32_t index -); +WIS_INLINE WISDOM_API WisResult +wisDX12DescriptorHeapWriteSampler(const WisDX12DescriptorHeap* self, const WisSamplerDesc* sampler, uint32_t index); /** * @brief Provided by Wisdom 0.7.0. Writes a descriptor to the descriptor heap. @@ -3753,11 +3717,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12DescriptorHeapWriteRWTexture( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12DescriptorHeapWriteAccelerationStructure( - const WisDX12DescriptorHeap* self, - uint64_t address, - uint32_t index -); +WIS_INLINE WISDOM_API WisResult +wisDX12DescriptorHeapWriteAccelerationStructure(const WisDX12DescriptorHeap* self, uint64_t address, uint32_t index); /** * @brief Provided by Wisdom 0.7.0. Copies descriptors from one heap to another. @@ -3877,10 +3838,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12CommandAllocatorReset(const WisDX12Comman * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12CommandAllocatorCreateCommandList( - const WisDX12CommandAllocator* self, - WisDX12CommandList* list -); +WIS_INLINE WISDOM_API WisResult +wisDX12CommandAllocatorCreateCommandList(const WisDX12CommandAllocator* self, WisDX12CommandList* list); /** * @brief Provided by Wisdom 0.7.0. Opens the command list, so commands can be recorded to it. @@ -4279,11 +4238,8 @@ WIS_INLINE WISDOM_API void wisDX12CommandListSetBlendFactors( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12PipelineCacheSerialize( - const WisDX12PipelineCache* self, - uint8_t* data, - size_t data_size -); +WIS_INLINE WISDOM_API WisResult +wisDX12PipelineCacheSerialize(const WisDX12PipelineCache* self, uint8_t* data, size_t data_size); /** * @brief Provided by Wisdom 0.7.0. Gets the size of the data in the pipeline cache. @@ -4302,12 +4258,8 @@ WIS_INLINE WISDOM_API size_t wisDX12PipelineCacheGetSerializedSize(const WisDX12 * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12SwapchainPresent( - const WisDX12Swapchain* self, - WisPresentFlags flags, - const WisRect* rects, - size_t rect_count -); +WIS_INLINE WISDOM_API WisResult +wisDX12SwapchainPresent(const WisDX12Swapchain* self, WisPresentFlags flags, const WisRect* rects, size_t rect_count); /** * @brief Provided by Wisdom 0.7.0. Gets the index of the current backbuffer. In case of lazy indexing it may wait for @@ -4327,10 +4279,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12SwapchainGetCurrentIndex(const WisDX12Swa * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12SwapchainUpdate( - const WisDX12Swapchain* self, - const WisSwapchainUpdateDesc* desc -); +WIS_INLINE WISDOM_API WisResult +wisDX12SwapchainUpdate(const WisDX12Swapchain* self, const WisSwapchainUpdateDesc* desc); /** * @brief Provided by Wisdom 0.7.0. Gets the swapchain buffers. The textures are in `WisTextureStateCommon`. @@ -4341,11 +4291,8 @@ WIS_INLINE WISDOM_API WisResult wisDX12SwapchainUpdate( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisDX12SwapchainGetTextures( - const WisDX12Swapchain* self, - WisDX12Texture* buffers, - size_t buffer_count -); +WIS_INLINE WISDOM_API WisResult +wisDX12SwapchainGetTextures(const WisDX12Swapchain* self, WisDX12Texture* buffers, size_t buffer_count); #endif // WISDOM_DX12 @@ -4909,11 +4856,8 @@ WIS_INLINE WISDOM_API WisResult wisVKCreateInstance( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKInstanceQueryAdapters( - const WisVKInstance* self, - WisAdapterPreference preference, - WisVKAdapterQuery* query -); +WIS_INLINE WISDOM_API WisResult +wisVKInstanceQueryAdapters(const WisVKInstance* self, WisAdapterPreference preference, WisVKAdapterQuery* query); /** * @brief Provided by Wisdom 0.7.0. Returns the number of adapters present on the system at the time of the query. @@ -4932,11 +4876,8 @@ WIS_INLINE WISDOM_API size_t wisVKAdapterQueryGetAdapterCount(const WisVKAdapter * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKAdapterQueryGetAdapterDesc( - const WisVKAdapterQuery* self, - size_t index, - WisAdapterDesc* desc -); +WIS_INLINE WISDOM_API WisResult +wisVKAdapterQueryGetAdapterDesc(const WisVKAdapterQuery* self, size_t index, WisAdapterDesc* desc); /** * @brief Provided by Wisdom 0.7.0. Checks if the adapter at given index supports presentation to given surface. @@ -4979,11 +4920,8 @@ WIS_INLINE WISDOM_API WisResult wisVKAdapterQueryCreateDevice( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKDeviceCreateCommandQueue( - const WisVKDevice* self, - WisCommandQueueType type, - WisVKCommandQueue* queue -); +WIS_INLINE WISDOM_API WisResult +wisVKDeviceCreateCommandQueue(const WisVKDevice* self, WisCommandQueueType type, WisVKCommandQueue* queue); /** * @brief Provided by Wisdom 0.7.0. Creates a command allocator to allocate command lists with. @@ -4993,11 +4931,8 @@ WIS_INLINE WISDOM_API WisResult wisVKDeviceCreateCommandQueue( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKDeviceCreateCommandAllocator( - const WisVKDevice* self, - WisCommandQueueType type, - WisVKCommandAllocator* allocator -); +WIS_INLINE WISDOM_API WisResult +wisVKDeviceCreateCommandAllocator(const WisVKDevice* self, WisCommandQueueType type, WisVKCommandAllocator* allocator); /** * @brief Provided by Wisdom 0.7.0. Creates a fence for GPU-CPU and GPU-GPU synchronization. @@ -5007,11 +4942,8 @@ WIS_INLINE WISDOM_API WisResult wisVKDeviceCreateCommandAllocator( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKDeviceCreateFence( - const WisVKDevice* self, - uint64_t initial_value, - WisVKFence* fence -); +WIS_INLINE WISDOM_API WisResult +wisVKDeviceCreateFence(const WisVKDevice* self, uint64_t initial_value, WisVKFence* fence); /** * @brief Provided by Wisdom 0.7.0. Creates a resource allocator for managing GPU resources. @@ -5020,10 +4952,8 @@ WIS_INLINE WISDOM_API WisResult wisVKDeviceCreateFence( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKDeviceGetResourceAllocator( - const WisVKDevice* self, - WisVKResourceAllocator* allocator -); +WIS_INLINE WISDOM_API WisResult +wisVKDeviceGetResourceAllocator(const WisVKDevice* self, WisVKResourceAllocator* allocator); /** * @brief Provided by Wisdom 0.7.0. Creates a pipeline layout with given descriptor. @@ -5033,11 +4963,8 @@ WIS_INLINE WISDOM_API WisResult wisVKDeviceGetResourceAllocator( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKDeviceCreateRootSignature( - const WisVKDevice* self, - const WisRootSignatureDesc* desc, - WisVKRootSignature* layout -); +WIS_INLINE WISDOM_API WisResult +wisVKDeviceCreateRootSignature(const WisVKDevice* self, const WisRootSignatureDesc* desc, WisVKRootSignature* layout); /** * @brief Provided by Wisdom 0.7.0. Creates a descriptor storage with given description. @@ -5047,11 +4974,8 @@ WIS_INLINE WISDOM_API WisResult wisVKDeviceCreateRootSignature( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( - const WisVKDevice* self, - const WisDescriptorHeapDesc* desc, - WisVKDescriptorHeap* heap -); +WIS_INLINE WISDOM_API WisResult +wisVKDeviceCreateDescriptorHeap(const WisVKDevice* self, const WisDescriptorHeapDesc* desc, WisVKDescriptorHeap* heap); /** * @brief Provided by Wisdom 0.7.0. Creates a view storage with given descriptor. @@ -5127,12 +5051,8 @@ WIS_INLINE WISDOM_API WisResult wisVKDeviceCreatePipelineCache( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKDeviceCreateShader( - const WisVKDevice* self, - const uint8_t* data, - size_t size, - WisVKShader* shader -); +WIS_INLINE WISDOM_API WisResult +wisVKDeviceCreateShader(const WisVKDevice* self, const uint8_t* data, size_t size, WisVKShader* shader); /** * @brief Provided by Wisdom 0.7.0. Creates a compute pipeline state object with given descriptor. @@ -5185,11 +5105,8 @@ WIS_INLINE WISDOM_API bool wisVKDeviceGetFormatPresentationSupport( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKDeviceGetSurfaceParameters( - const WisVKDevice* self, - WisVKSurfaceView surface, - WisSurfaceParameters* params -); +WIS_INLINE WISDOM_API WisResult +wisVKDeviceGetSurfaceParameters(const WisVKDevice* self, WisVKSurfaceView surface, WisSurfaceParameters* params); /** * @brief Provided by Wisdom 0.7.0. Creates a swapchain for given surface with given descriptor. @@ -5218,11 +5135,8 @@ WIS_INLINE WISDOM_API WisResult wisVKDeviceCreateSwapchain( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKDeviceGetFormatProperties( - const WisVKDevice* self, - WisDataFormat format, - WisFormatProperties* properties -); +WIS_INLINE WISDOM_API WisResult +wisVKDeviceGetFormatProperties(const WisVKDevice* self, WisDataFormat format, WisFormatProperties* properties); /** * @brief Provided by Wisdom 0.7.0. Get the current value of the fence. @@ -5259,11 +5173,8 @@ WIS_INLINE WISDOM_API WisResult wisVKFenceSignal(const WisVKFence* self, uint64_ * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKCommandQueueSubmit( - const WisVKCommandQueue* self, - const WisVKCommandListView* lists, - size_t list_count -); +WIS_INLINE WISDOM_API WisResult +wisVKCommandQueueSubmit(const WisVKCommandQueue* self, const WisVKCommandListView* lists, size_t list_count); /** * @brief Provided by Wisdom 0.7.0. Enqueue the signal to the queue, that gets executed after all the work has been @@ -5274,11 +5185,8 @@ WIS_INLINE WISDOM_API WisResult wisVKCommandQueueSubmit( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKCommandQueueSignalFence( - const WisVKCommandQueue* self, - WisVKFenceView fence, - uint64_t value -); +WIS_INLINE WISDOM_API WisResult +wisVKCommandQueueSignalFence(const WisVKCommandQueue* self, WisVKFenceView fence, uint64_t value); /** * @brief Provided by Wisdom 0.7.0. Enqueues wait operation to the command queue. Queue then waits for the fence to be @@ -5289,11 +5197,8 @@ WIS_INLINE WISDOM_API WisResult wisVKCommandQueueSignalFence( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKCommandQueueWaitFence( - const WisVKCommandQueue* self, - WisVKFenceView fence, - uint64_t value -); +WIS_INLINE WISDOM_API WisResult +wisVKCommandQueueWaitFence(const WisVKCommandQueue* self, WisVKFenceView fence, uint64_t value); /** * @brief Provided by Wisdom 0.7.0. Creates a buffer with given descriptor. @@ -5303,11 +5208,8 @@ WIS_INLINE WISDOM_API WisResult wisVKCommandQueueWaitFence( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKResourceAllocatorCreateBuffer( - const WisVKResourceAllocator* self, - const WisBufferDesc* desc, - WisVKBuffer* buffer -); +WIS_INLINE WISDOM_API WisResult +wisVKResourceAllocatorCreateBuffer(const WisVKResourceAllocator* self, const WisBufferDesc* desc, WisVKBuffer* buffer); /** * @brief Provided by Wisdom 0.7.0. Creates a texture with given descriptor. @@ -5349,11 +5251,8 @@ WIS_INLINE WISDOM_API uint64_t wisVKBufferGetGPUAddress(const WisVKBuffer* self) * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKTextureWriteSubresource( - const WisVKTexture* self, - const void* source_data, - const WisTextureRegion* target_region -); +WIS_INLINE WISDOM_API WisResult +wisVKTextureWriteSubresource(const WisVKTexture* self, const void* source_data, const WisTextureRegion* target_region); /** * @brief Provided by Wisdom 0.7.0. Returns the CPU descriptor handle for the descriptor heap. @@ -5418,11 +5317,8 @@ WIS_INLINE WISDOM_API WisResult wisVKDescriptorHeapWriteRWStructuredBuffer( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKDescriptorHeapWriteSampler( - const WisVKDescriptorHeap* self, - const WisSamplerDesc* sampler, - uint32_t index -); +WIS_INLINE WISDOM_API WisResult +wisVKDescriptorHeapWriteSampler(const WisVKDescriptorHeap* self, const WisSamplerDesc* sampler, uint32_t index); /** * @brief Provided by Wisdom 0.7.0. Writes a descriptor to the descriptor heap. @@ -5464,11 +5360,8 @@ WIS_INLINE WISDOM_API WisResult wisVKDescriptorHeapWriteRWTexture( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKDescriptorHeapWriteAccelerationStructure( - const WisVKDescriptorHeap* self, - uint64_t address, - uint32_t index -); +WIS_INLINE WISDOM_API WisResult +wisVKDescriptorHeapWriteAccelerationStructure(const WisVKDescriptorHeap* self, uint64_t address, uint32_t index); /** * @brief Provided by Wisdom 0.7.0. Copies descriptors from one heap to another. @@ -5588,10 +5481,8 @@ WIS_INLINE WISDOM_API WisResult wisVKCommandAllocatorReset(const WisVKCommandAll * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKCommandAllocatorCreateCommandList( - const WisVKCommandAllocator* self, - WisVKCommandList* list -); +WIS_INLINE WISDOM_API WisResult +wisVKCommandAllocatorCreateCommandList(const WisVKCommandAllocator* self, WisVKCommandList* list); /** * @brief Provided by Wisdom 0.7.0. Opens the command list, so commands can be recorded to it. @@ -5984,11 +5875,8 @@ WIS_INLINE WISDOM_API void wisVKCommandListSetBlendFactors( * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKPipelineCacheSerialize( - const WisVKPipelineCache* self, - uint8_t* data, - size_t data_size -); +WIS_INLINE WISDOM_API WisResult +wisVKPipelineCacheSerialize(const WisVKPipelineCache* self, uint8_t* data, size_t data_size); /** * @brief Provided by Wisdom 0.7.0. Gets the size of the data in the pipeline cache. @@ -6007,12 +5895,8 @@ WIS_INLINE WISDOM_API size_t wisVKPipelineCacheGetSerializedSize(const WisVKPipe * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKSwapchainPresent( - const WisVKSwapchain* self, - WisPresentFlags flags, - const WisRect* rects, - size_t rect_count -); +WIS_INLINE WISDOM_API WisResult +wisVKSwapchainPresent(const WisVKSwapchain* self, WisPresentFlags flags, const WisRect* rects, size_t rect_count); /** * @brief Provided by Wisdom 0.7.0. Gets the index of the current backbuffer. In case of lazy indexing it may wait for @@ -6043,11 +5927,8 @@ WIS_INLINE WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* self, * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_API WisResult wisVKSwapchainGetTextures( - const WisVKSwapchain* self, - WisVKTexture* buffers, - size_t buffer_count -); +WIS_INLINE WISDOM_API WisResult +wisVKSwapchainGetTextures(const WisVKSwapchain* self, WisVKTexture* buffers, size_t buffer_count); #endif // WISDOM_VULKAN diff --git a/src/include/wisdom/generated/cpp_api.hpp b/src/include/wisdom/generated/cpp_api.hpp index 7951d18bf..ba95d0031 100644 --- a/src/include/wisdom/generated/cpp_api.hpp +++ b/src/include/wisdom/generated/cpp_api.hpp @@ -2868,9 +2868,7 @@ struct DX12IndexBufferDesc { }; struct DX12TextureDeleter { - void operator()(WisDX12Texture* handle) noexcept { - ::wisDX12DestroyTexture(handle); - } + void operator()(WisDX12Texture* handle) noexcept { ::wisDX12DestroyTexture(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU texture resource. @@ -2888,9 +2886,7 @@ class DX12Texture : public wis::impl::Implements(&target_region) - ); + &_impl_storage, + source_data, + reinterpret_cast(&target_region) + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } }; struct DX12BufferDeleter { - void operator()(WisDX12Buffer* handle) noexcept { - ::wisDX12DestroyBuffer(handle); - } + void operator()(WisDX12Buffer* handle) noexcept { ::wisDX12DestroyBuffer(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU buffer resource. @@ -2932,17 +2926,13 @@ class DX12Buffer : public wis::impl::Implements rects) const noexcept { const WisResult wis_result = ::wisDX12SwapchainPresent( - &_impl_storage, - static_cast(flags), - reinterpret_cast(rects.data()), - rects.size() - ); + &_impl_storage, + static_cast(flags), + reinterpret_cast(rects.data()), + rects.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -2999,9 +2987,9 @@ class DX12Swapchain { std::uint32_t index{}; const WisResult wis_result = ::wisDX12SwapchainGetCurrentIndex( - &_impl_storage, - reinterpret_cast(&index) - ); + &_impl_storage, + reinterpret_cast(&index) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -3019,9 +3007,9 @@ class DX12Swapchain inline wis::Result Update(const wis::SwapchainUpdateDesc& desc) const noexcept { const WisResult wis_result = ::wisDX12SwapchainUpdate( - &_impl_storage, - reinterpret_cast(&desc) - ); + &_impl_storage, + reinterpret_cast(&desc) + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3033,18 +3021,16 @@ class DX12Swapchain inline wis::Result GetTextures(wis::span buffers) const noexcept { const WisResult wis_result = ::wisDX12SwapchainGetTextures( - &_impl_storage, - reinterpret_cast(buffers.data()), - buffers.size() - ); + &_impl_storage, + reinterpret_cast(buffers.data()), + buffers.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } }; struct DX12SurfaceDeleter { - void operator()(WisDX12Surface* handle) noexcept { - ::wisDX12DestroySurface(handle); - } + void operator()(WisDX12Surface* handle) noexcept { ::wisDX12DestroySurface(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU surface, which can be used as a target for rendering and @@ -3063,15 +3049,11 @@ class DX12Surface : public wis::impl::Implements(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.0. Writes a depth stencil view to the view heap and returns the CPU descriptor @@ -3124,11 +3106,11 @@ class DX12ViewHeap ) const noexcept { return (::wisDX12ViewHeapWriteDepthStencil( - &_impl_storage, - reinterpret_cast(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.1. Writes a texture view for video decode output and returns the texture view @@ -3146,11 +3128,11 @@ class DX12ViewHeap ) const noexcept { return (::wisDX12ViewHeapWriteVideoDecodeTarget( - &_impl_storage, - reinterpret_cast(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.0. Returns the CPU descriptor handle for the view heap. @@ -3191,9 +3173,7 @@ class DX12ViewHeap }; struct DX12PipelineDeleter { - void operator()(WisDX12Pipeline* handle) noexcept { - ::wisDX12DestroyPipeline(handle); - } + void operator()(WisDX12Pipeline* handle) noexcept { ::wisDX12DestroyPipeline(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU pipeline state object, which encapsulates the state of the @@ -3213,15 +3193,11 @@ class DX12Pipeline std::memcpy(&v, &_impl_storage, sizeof(v)); return v; } - WIS_NODISCARD operator DX12PipelineView() const noexcept { - return GetView(); - } + WIS_NODISCARD operator DX12PipelineView() const noexcept { return GetView(); } }; struct DX12ShaderDeleter { - void operator()(WisDX12Shader* handle) noexcept { - ::wisDX12DestroyShader(handle); - } + void operator()(WisDX12Shader* handle) noexcept { ::wisDX12DestroyShader(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU shader module, which contains shader code and allows to @@ -3240,15 +3216,11 @@ class DX12Shader : public wis::impl::Implements + Implements { public: using ImplType::ImplType; @@ -3269,9 +3241,7 @@ class DX12PipelineCache std::memcpy(&v, &_impl_storage, sizeof(v)); return v; } - WIS_NODISCARD operator DX12PipelineCacheView() const noexcept { - return GetView(); - } + WIS_NODISCARD operator DX12PipelineCacheView() const noexcept { return GetView(); } /** * @brief Provided by Wisdom 0.7.0. Gets the data from the pipeline cache. * @param data points to an array that is filled with serialized cache data on success. @@ -3281,10 +3251,10 @@ class DX12PipelineCache inline wis::Result Serialize(wis::span data) const noexcept { const WisResult wis_result = ::wisDX12PipelineCacheSerialize( - &_impl_storage, - reinterpret_cast(data.data()), - data.size() - ); + &_impl_storage, + reinterpret_cast(data.data()), + data.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3299,9 +3269,7 @@ class DX12PipelineCache }; struct DX12DescriptorHeapDeleter { - void operator()(WisDX12DescriptorHeap* handle) noexcept { - ::wisDX12DestroyDescriptorHeap(handle); - } + void operator()(WisDX12DescriptorHeap* handle) noexcept { ::wisDX12DestroyDescriptorHeap(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a storage for descriptors used in contiguous array. @@ -3309,7 +3277,7 @@ struct DX12DescriptorHeapDeleter { * */ class DX12DescriptorHeap : public wis::impl:: - Implements + Implements { public: using ImplType::ImplType; @@ -3335,10 +3303,10 @@ class DX12DescriptorHeap inline wis::Result WriteConstantBuffer(const wis::ConstantBufferBinding& data, std::uint32_t index) const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteConstantBuffer( - &_impl_storage, - reinterpret_cast(&data), - index - ); + &_impl_storage, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3357,11 +3325,11 @@ class DX12DescriptorHeap ) const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteStructuredBuffer( - &_impl_storage, - buffer, - reinterpret_cast(&data), - index - ); + &_impl_storage, + buffer, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3380,11 +3348,11 @@ class DX12DescriptorHeap ) const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteRWStructuredBuffer( - &_impl_storage, - buffer, - reinterpret_cast(&data), - index - ); + &_impl_storage, + buffer, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3397,10 +3365,10 @@ class DX12DescriptorHeap inline wis::Result WriteSampler(const wis::SamplerDesc& sampler, std::uint32_t index) const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteSampler( - &_impl_storage, - reinterpret_cast(&sampler), - index - ); + &_impl_storage, + reinterpret_cast(&sampler), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3411,18 +3379,15 @@ class DX12DescriptorHeap * @return Result denoting the outcome of operation. * * */ - inline wis::Result WriteTexture( - wis::DX12TextureView texture, - const wis::TextureBinding& data, - std::uint32_t index - ) const noexcept + inline wis::Result WriteTexture(wis::DX12TextureView texture, const wis::TextureBinding& data, std::uint32_t index) + const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteTexture( - &_impl_storage, - texture, - reinterpret_cast(&data), - index - ); + &_impl_storage, + texture, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3440,11 +3405,11 @@ class DX12DescriptorHeap ) const noexcept { const WisResult wis_result = ::wisDX12DescriptorHeapWriteRWTexture( - &_impl_storage, - texture, - reinterpret_cast(&data), - index - ); + &_impl_storage, + texture, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -3480,9 +3445,7 @@ class DX12DescriptorHeap }; struct DX12RootSignatureDeleter { - void operator()(WisDX12RootSignature* handle) noexcept { - ::wisDX12DestroyRootSignature(handle); - } + void operator()(WisDX12RootSignature* handle) noexcept { ::wisDX12DestroyRootSignature(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a pipeline layout and a constant data storage, which defines @@ -3491,7 +3454,7 @@ struct DX12RootSignatureDeleter { * */ class DX12RootSignature : public wis::impl:: - Implements + Implements { public: using ImplType::ImplType; @@ -3503,15 +3466,11 @@ class DX12RootSignature std::memcpy(&v, &_impl_storage, sizeof(v)); return v; } - WIS_NODISCARD operator DX12RootSignatureView() const noexcept { - return GetView(); - } + WIS_NODISCARD operator DX12RootSignatureView() const noexcept { return GetView(); } }; struct DX12ResourceAllocatorDeleter { - void operator()(WisDX12ResourceAllocator* handle) noexcept { - ::wisDX12DestroyResourceAllocator(handle); - } + void operator()(WisDX12ResourceAllocator* handle) noexcept { ::wisDX12DestroyResourceAllocator(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class for allocating and managing GPU resources like buffers and textures. @@ -3519,7 +3478,7 @@ struct DX12ResourceAllocatorDeleter { * */ class DX12ResourceAllocator : public wis::impl:: - Implements + Implements { public: using ImplType::ImplType; @@ -3532,17 +3491,15 @@ class DX12ResourceAllocator * @return buffer points to wis::Buffer, which is initialized on success. * * */ - WIS_NODISCARD inline wis::DX12Buffer CreateBuffer( - const wis::BufferDesc& desc, - wis::Result& out_result - ) const noexcept + WIS_NODISCARD inline wis::DX12Buffer CreateBuffer(const wis::BufferDesc& desc, wis::Result& out_result) + const noexcept { wis::DX12Buffer buffer{}; const WisResult wis_result = ::wisDX12ResourceAllocatorCreateBuffer( - &_impl_storage, - reinterpret_cast(&desc), - buffer.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + buffer.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -3557,17 +3514,15 @@ class DX12ResourceAllocator * @return texture points to wis::Texture, which is initialized on success. * * */ - WIS_NODISCARD inline wis::DX12Texture CreateTexture( - const wis::TextureDesc& desc, - wis::Result& out_result - ) const noexcept + WIS_NODISCARD inline wis::DX12Texture CreateTexture(const wis::TextureDesc& desc, wis::Result& out_result) + const noexcept { wis::DX12Texture texture{}; const WisResult wis_result = ::wisDX12ResourceAllocatorCreateTexture( - &_impl_storage, - reinterpret_cast(&desc), - texture.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + texture.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -3578,9 +3533,7 @@ class DX12ResourceAllocator }; struct DX12FenceDeleter { - void operator()(WisDX12Fence* handle) noexcept { - ::wisDX12DestroyFence(handle); - } + void operator()(WisDX12Fence* handle) noexcept { ::wisDX12DestroyFence(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a fence for GPU-CPU and GPU-GPU synchronization. @@ -3598,9 +3551,7 @@ class DX12Fence : public wis::impl::Implements + Implements { public: using ImplType::ImplType; @@ -4137,9 +4073,7 @@ class DX12CommandAllocator }; struct DX12CommandQueueDeleter { - void operator()(WisDX12CommandQueue* handle) noexcept { - ::wisDX12DestroyCommandQueue(handle); - } + void operator()(WisDX12CommandQueue* handle) noexcept { ::wisDX12DestroyCommandQueue(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a command queue for submitting command lists to the GPU. @@ -4161,10 +4095,10 @@ class DX12CommandQueue inline wis::Result Submit(wis::span lists) const noexcept { const WisResult wis_result = ::wisDX12CommandQueueSubmit( - &_impl_storage, - reinterpret_cast(lists.data()), - lists.size() - ); + &_impl_storage, + reinterpret_cast(lists.data()), + lists.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -4196,9 +4130,7 @@ class DX12CommandQueue }; struct DX12DeviceDeleter { - void operator()(WisDX12Device* handle) noexcept { - ::wisDX12DestroyDevice(handle); - } + void operator()(WisDX12Device* handle) noexcept { ::wisDX12DestroyDevice(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Central class representing logical device. @@ -4217,17 +4149,15 @@ class DX12Device : public wis::impl::Implements(type), - queue.GetStorage() - ); + &_impl_storage, + static_cast(type), + queue.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4249,10 +4179,10 @@ class DX12Device : public wis::impl::Implements(type), - allocator.GetStorage() - ); + &_impl_storage, + static_cast(type), + allocator.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4309,10 +4239,10 @@ class DX12Device : public wis::impl::Implements(&desc), - layout.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + layout.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4334,10 +4264,10 @@ class DX12Device : public wis::impl::Implements(&desc), - heap.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + heap.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4363,12 +4293,12 @@ class DX12Device : public wis::impl::Implements(type), - capacity, - static_cast(flags), - heap.GetStorage() - ); + &_impl_storage, + static_cast(type), + capacity, + static_cast(flags), + heap.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4407,13 +4337,13 @@ class DX12Device : public wis::impl::Implements(wait_for), - timeout - ); + &_impl_storage, + fences, + fence_values, + fence_count, + static_cast(wait_for), + timeout + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -4430,11 +4360,11 @@ class DX12Device : public wis::impl::Implements(initial_data.data()), - initial_data.size(), - cache.GetStorage() - ); + &_impl_storage, + reinterpret_cast(initial_data.data()), + initial_data.size(), + cache.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4449,18 +4379,16 @@ class DX12Device : public wis::impl::Implements data, - wis::Result& out_result - ) const noexcept + WIS_NODISCARD inline wis::DX12Shader CreateShader(wis::span data, wis::Result& out_result) + const noexcept { wis::DX12Shader shader{}; const WisResult wis_result = ::wisDX12DeviceCreateShader( - &_impl_storage, - reinterpret_cast(data.data()), - data.size(), - shader.GetStorage() - ); + &_impl_storage, + reinterpret_cast(data.data()), + data.size(), + shader.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4482,10 +4410,10 @@ class DX12Device : public wis::impl::Implements(&desc), - pipeline.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + pipeline.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4507,10 +4435,10 @@ class DX12Device : public wis::impl::Implements(&desc), - pipeline.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + pipeline.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4526,14 +4454,11 @@ class DX12Device : public wis::impl::Implements(format)) - ); + return (::wisDX12DeviceGetFormatPresentationSupport(&_impl_storage, surface, static_cast(format)) + ); } /** * @brief Provided by Wisdom 0.7.0. Gets presentation parameters for the specified surface. @@ -4549,10 +4474,10 @@ class DX12Device : public wis::impl::Implements(¶ms) - ); + &_impl_storage, + surface, + reinterpret_cast(¶ms) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4579,12 +4504,12 @@ class DX12Device : public wis::impl::Implements(&surface), - reinterpret_cast(&queue), - reinterpret_cast(&desc), - swapchain.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&surface), + reinterpret_cast(&queue), + reinterpret_cast(&desc), + swapchain.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4599,17 +4524,15 @@ class DX12Device : public wis::impl::Implements(format), - reinterpret_cast(&properties) - ); + &_impl_storage, + static_cast(format), + reinterpret_cast(&properties) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4620,9 +4543,7 @@ class DX12Device : public wis::impl::Implements(&desc) - ); + &_impl_storage, + index, + reinterpret_cast(&desc) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4697,11 +4618,11 @@ class DX12AdapterQuery { wis::DX12Device device{}; const WisResult wis_result = ::wisDX12AdapterQueryCreateDevice( - &_impl_storage, - index, - reinterpret_cast(&requirements), - device.GetStorage() - ); + &_impl_storage, + index, + reinterpret_cast(&requirements), + device.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4712,9 +4633,7 @@ class DX12AdapterQuery }; struct DX12InstanceDeleter { - void operator()(WisDX12Instance* handle) noexcept { - ::wisDX12DestroyInstance(handle); - } + void operator()(WisDX12Instance* handle) noexcept { ::wisDX12DestroyInstance(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class for creating adapters. @@ -4737,17 +4656,15 @@ class DX12Instance * @return query points to wis::AdapterQuery, which is initialized on success. * * */ - WIS_NODISCARD inline wis::DX12AdapterQuery QueryAdapters( - wis::AdapterPreference preference, - wis::Result& out_result - ) const noexcept + WIS_NODISCARD inline wis::DX12AdapterQuery QueryAdapters(wis::AdapterPreference preference, wis::Result& out_result) + const noexcept { wis::DX12AdapterQuery query{}; const WisResult wis_result = ::wisDX12InstanceQueryAdapters( - &_impl_storage, - static_cast(preference), - query.GetStorage() - ); + &_impl_storage, + static_cast(preference), + query.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -4775,11 +4692,11 @@ WIS_NODISCARD inline wis::DX12Instance DX12CreateInstance( { wis::DX12Instance instance{}; const WisResult wis_result = ::wisDX12CreateInstance( - reinterpret_cast(debug_desc), - reinterpret_cast(extensions.data()), - extensions.size(), - instance.GetStorage() - ); + reinterpret_cast(debug_desc), + reinterpret_cast(extensions.data()), + extensions.size(), + instance.GetStorage() + ); out_result = wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; return instance; } @@ -4993,9 +4910,7 @@ struct VKIndexBufferDesc { }; struct VKTextureDeleter { - void operator()(WisVKTexture* handle) noexcept { - ::wisVKDestroyTexture(handle); - } + void operator()(WisVKTexture* handle) noexcept { ::wisVKDestroyTexture(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU texture resource. @@ -5013,9 +4928,7 @@ class VKTexture : public wis::impl::Implements(&target_region) - ); + &_impl_storage, + source_data, + reinterpret_cast(&target_region) + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } }; struct VKBufferDeleter { - void operator()(WisVKBuffer* handle) noexcept { - ::wisVKDestroyBuffer(handle); - } + void operator()(WisVKBuffer* handle) noexcept { ::wisVKDestroyBuffer(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU buffer resource. @@ -5057,17 +4968,13 @@ class VKBuffer : public wis::impl::Implements rects) const noexcept { const WisResult wis_result = ::wisVKSwapchainPresent( - &_impl_storage, - static_cast(flags), - reinterpret_cast(rects.data()), - rects.size() - ); + &_impl_storage, + static_cast(flags), + reinterpret_cast(rects.data()), + rects.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5123,9 +5028,9 @@ class VKSwapchain : public wis::impl::Implements(&index) - ); + &_impl_storage, + reinterpret_cast(&index) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -5143,9 +5048,9 @@ class VKSwapchain : public wis::impl::Implements(&desc) - ); + &_impl_storage, + reinterpret_cast(&desc) + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5157,18 +5062,16 @@ class VKSwapchain : public wis::impl::Implements buffers) const noexcept { const WisResult wis_result = ::wisVKSwapchainGetTextures( - &_impl_storage, - reinterpret_cast(buffers.data()), - buffers.size() - ); + &_impl_storage, + reinterpret_cast(buffers.data()), + buffers.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } }; struct VKSurfaceDeleter { - void operator()(WisVKSurface* handle) noexcept { - ::wisVKDestroySurface(handle); - } + void operator()(WisVKSurface* handle) noexcept { ::wisVKDestroySurface(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a GPU surface, which can be used as a target for rendering and @@ -5187,15 +5090,11 @@ class VKSurface : public wis::impl::Implements(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.0. Writes a depth stencil view to the view heap and returns the CPU descriptor @@ -5247,11 +5146,11 @@ class VKViewHeap : public wis::impl::Implements(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.1. Writes a texture view for video decode output and returns the texture view @@ -5269,11 +5168,11 @@ class VKViewHeap : public wis::impl::Implements(&texture), - reinterpret_cast(&render_target), - index - )); + &_impl_storage, + reinterpret_cast(&texture), + reinterpret_cast(&render_target), + index + )); } /** * @brief Provided by Wisdom 0.7.0. Returns the CPU descriptor handle for the view heap. @@ -5314,9 +5213,7 @@ class VKViewHeap : public wis::impl::Implements data) const noexcept { const WisResult wis_result = ::wisVKPipelineCacheSerialize( - &_impl_storage, - reinterpret_cast(data.data()), - data.size() - ); + &_impl_storage, + reinterpret_cast(data.data()), + data.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5420,9 +5307,7 @@ class VKPipelineCache }; struct VKDescriptorHeapDeleter { - void operator()(WisVKDescriptorHeap* handle) noexcept { - ::wisVKDestroyDescriptorHeap(handle); - } + void operator()(WisVKDescriptorHeap* handle) noexcept { ::wisVKDestroyDescriptorHeap(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a storage for descriptors used in contiguous array. @@ -5455,10 +5340,10 @@ class VKDescriptorHeap inline wis::Result WriteConstantBuffer(const wis::ConstantBufferBinding& data, std::uint32_t index) const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteConstantBuffer( - &_impl_storage, - reinterpret_cast(&data), - index - ); + &_impl_storage, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5477,11 +5362,11 @@ class VKDescriptorHeap ) const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteStructuredBuffer( - &_impl_storage, - buffer, - reinterpret_cast(&data), - index - ); + &_impl_storage, + buffer, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5500,11 +5385,11 @@ class VKDescriptorHeap ) const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteRWStructuredBuffer( - &_impl_storage, - buffer, - reinterpret_cast(&data), - index - ); + &_impl_storage, + buffer, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5517,10 +5402,10 @@ class VKDescriptorHeap inline wis::Result WriteSampler(const wis::SamplerDesc& sampler, std::uint32_t index) const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteSampler( - &_impl_storage, - reinterpret_cast(&sampler), - index - ); + &_impl_storage, + reinterpret_cast(&sampler), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5531,18 +5416,15 @@ class VKDescriptorHeap * @return Result denoting the outcome of operation. * * */ - inline wis::Result WriteTexture( - wis::VKTextureView texture, - const wis::TextureBinding& data, - std::uint32_t index - ) const noexcept + inline wis::Result WriteTexture(wis::VKTextureView texture, const wis::TextureBinding& data, std::uint32_t index) + const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteTexture( - &_impl_storage, - texture, - reinterpret_cast(&data), - index - ); + &_impl_storage, + texture, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5553,18 +5435,15 @@ class VKDescriptorHeap * @return Result denoting the outcome of operation. * * */ - inline wis::Result WriteRWTexture( - wis::VKTextureView texture, - const wis::TextureBinding& data, - std::uint32_t index - ) const noexcept + inline wis::Result WriteRWTexture(wis::VKTextureView texture, const wis::TextureBinding& data, std::uint32_t index) + const noexcept { const WisResult wis_result = ::wisVKDescriptorHeapWriteRWTexture( - &_impl_storage, - texture, - reinterpret_cast(&data), - index - ); + &_impl_storage, + texture, + reinterpret_cast(&data), + index + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -5600,9 +5479,7 @@ class VKDescriptorHeap }; struct VKRootSignatureDeleter { - void operator()(WisVKRootSignature* handle) noexcept { - ::wisVKDestroyRootSignature(handle); - } + void operator()(WisVKRootSignature* handle) noexcept { ::wisVKDestroyRootSignature(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a pipeline layout and a constant data storage, which defines @@ -5622,15 +5499,11 @@ class VKRootSignature std::memcpy(&v, &_impl_storage, sizeof(v)); return v; } - WIS_NODISCARD operator VKRootSignatureView() const noexcept { - return GetView(); - } + WIS_NODISCARD operator VKRootSignatureView() const noexcept { return GetView(); } }; struct VKResourceAllocatorDeleter { - void operator()(WisVKResourceAllocator* handle) noexcept { - ::wisVKDestroyResourceAllocator(handle); - } + void operator()(WisVKResourceAllocator* handle) noexcept { ::wisVKDestroyResourceAllocator(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class for allocating and managing GPU resources like buffers and textures. @@ -5638,7 +5511,7 @@ struct VKResourceAllocatorDeleter { * */ class VKResourceAllocator : public wis::impl:: - Implements + Implements { public: using ImplType::ImplType; @@ -5655,10 +5528,10 @@ class VKResourceAllocator { wis::VKBuffer buffer{}; const WisResult wis_result = ::wisVKResourceAllocatorCreateBuffer( - &_impl_storage, - reinterpret_cast(&desc), - buffer.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + buffer.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -5673,17 +5546,15 @@ class VKResourceAllocator * @return texture points to wis::Texture, which is initialized on success. * * */ - WIS_NODISCARD inline wis::VKTexture CreateTexture( - const wis::TextureDesc& desc, - wis::Result& out_result - ) const noexcept + WIS_NODISCARD inline wis::VKTexture CreateTexture(const wis::TextureDesc& desc, wis::Result& out_result) + const noexcept { wis::VKTexture texture{}; const WisResult wis_result = ::wisVKResourceAllocatorCreateTexture( - &_impl_storage, - reinterpret_cast(&desc), - texture.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + texture.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -5694,9 +5565,7 @@ class VKResourceAllocator }; struct VKFenceDeleter { - void operator()(WisVKFence* handle) noexcept { - ::wisVKDestroyFence(handle); - } + void operator()(WisVKFence* handle) noexcept { ::wisVKDestroyFence(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a fence for GPU-CPU and GPU-GPU synchronization. @@ -5714,9 +5583,7 @@ class VKFence : public wis::impl::Implements + Implements { public: using ImplType::ImplType; @@ -6250,9 +6102,7 @@ class VKCommandAllocator }; struct VKCommandQueueDeleter { - void operator()(WisVKCommandQueue* handle) noexcept { - ::wisVKDestroyCommandQueue(handle); - } + void operator()(WisVKCommandQueue* handle) noexcept { ::wisVKDestroyCommandQueue(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class representing a command queue for submitting command lists to the GPU. @@ -6274,10 +6124,10 @@ class VKCommandQueue inline wis::Result Submit(wis::span lists) const noexcept { const WisResult wis_result = ::wisVKCommandQueueSubmit( - &_impl_storage, - reinterpret_cast(lists.data()), - lists.size() - ); + &_impl_storage, + reinterpret_cast(lists.data()), + lists.size() + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -6309,9 +6159,7 @@ class VKCommandQueue }; struct VKDeviceDeleter { - void operator()(WisVKDevice* handle) noexcept { - ::wisVKDestroyDevice(handle); - } + void operator()(WisVKDevice* handle) noexcept { ::wisVKDestroyDevice(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Central class representing logical device. @@ -6330,17 +6178,15 @@ class VKDevice : public wis::impl::Implements(type), - queue.GetStorage() - ); + &_impl_storage, + static_cast(type), + queue.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6362,10 +6208,10 @@ class VKDevice : public wis::impl::Implements(type), - allocator.GetStorage() - ); + &_impl_storage, + static_cast(type), + allocator.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6422,10 +6268,10 @@ class VKDevice : public wis::impl::Implements(&desc), - layout.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + layout.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6447,10 +6293,10 @@ class VKDevice : public wis::impl::Implements(&desc), - heap.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + heap.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6476,12 +6322,12 @@ class VKDevice : public wis::impl::Implements(type), - capacity, - static_cast(flags), - heap.GetStorage() - ); + &_impl_storage, + static_cast(type), + capacity, + static_cast(flags), + heap.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6520,13 +6366,13 @@ class VKDevice : public wis::impl::Implements(wait_for), - timeout - ); + &_impl_storage, + fences, + fence_values, + fence_count, + static_cast(wait_for), + timeout + ); return wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; } /** @@ -6543,11 +6389,11 @@ class VKDevice : public wis::impl::Implements(initial_data.data()), - initial_data.size(), - cache.GetStorage() - ); + &_impl_storage, + reinterpret_cast(initial_data.data()), + initial_data.size(), + cache.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6562,18 +6408,16 @@ class VKDevice : public wis::impl::Implements data, - wis::Result& out_result - ) const noexcept + WIS_NODISCARD inline wis::VKShader CreateShader(wis::span data, wis::Result& out_result) + const noexcept { wis::VKShader shader{}; const WisResult wis_result = ::wisVKDeviceCreateShader( - &_impl_storage, - reinterpret_cast(data.data()), - data.size(), - shader.GetStorage() - ); + &_impl_storage, + reinterpret_cast(data.data()), + data.size(), + shader.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6595,10 +6439,10 @@ class VKDevice : public wis::impl::Implements(&desc), - pipeline.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + pipeline.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6620,10 +6464,10 @@ class VKDevice : public wis::impl::Implements(&desc), - pipeline.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&desc), + pipeline.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6639,10 +6483,8 @@ class VKDevice : public wis::impl::Implements(format))); } @@ -6660,10 +6502,10 @@ class VKDevice : public wis::impl::Implements(¶ms) - ); + &_impl_storage, + surface, + reinterpret_cast(¶ms) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6690,12 +6532,12 @@ class VKDevice : public wis::impl::Implements(&surface), - reinterpret_cast(&queue), - reinterpret_cast(&desc), - swapchain.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&surface), + reinterpret_cast(&queue), + reinterpret_cast(&desc), + swapchain.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6710,17 +6552,15 @@ class VKDevice : public wis::impl::Implements(format), - reinterpret_cast(&properties) - ); + &_impl_storage, + static_cast(format), + reinterpret_cast(&properties) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6731,9 +6571,7 @@ class VKDevice : public wis::impl::Implements(&desc) - ); + &_impl_storage, + index, + reinterpret_cast(&desc) + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6808,11 +6646,11 @@ class VKAdapterQuery { wis::VKDevice device{}; const WisResult wis_result = ::wisVKAdapterQueryCreateDevice( - &_impl_storage, - index, - reinterpret_cast(&requirements), - device.GetStorage() - ); + &_impl_storage, + index, + reinterpret_cast(&requirements), + device.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6823,9 +6661,7 @@ class VKAdapterQuery }; struct VKInstanceDeleter { - void operator()(WisVKInstance* handle) noexcept { - ::wisVKDestroyInstance(handle); - } + void operator()(WisVKInstance* handle) noexcept { ::wisVKDestroyInstance(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Class for creating adapters. @@ -6847,17 +6683,15 @@ class VKInstance : public wis::impl::Implements(preference), - query.GetStorage() - ); + &_impl_storage, + static_cast(preference), + query.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -6885,11 +6719,11 @@ WIS_NODISCARD inline wis::VKInstance VKCreateInstance( { wis::VKInstance instance{}; const WisResult wis_result = ::wisVKCreateInstance( - reinterpret_cast(debug_desc), - reinterpret_cast(extensions.data()), - extensions.size(), - instance.GetStorage() - ); + reinterpret_cast(debug_desc), + reinterpret_cast(extensions.data()), + extensions.size(), + instance.GetStorage() + ); out_result = wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; return instance; } diff --git a/src/include/wisdom/generated/dx12_convert.hpp b/src/include/wisdom/generated/dx12_convert.hpp index e2095a1bc..4465c66ac 100644 --- a/src/include/wisdom/generated/dx12_convert.hpp +++ b/src/include/wisdom/generated/dx12_convert.hpp @@ -160,9 +160,7 @@ constexpr inline DXGI_FORMAT DX12Convert(WisDataFormat value) noexcept } } -constexpr inline uint32_t DX12Convert(WisSampleCount value) noexcept { - return static_cast(value); -} +constexpr inline uint32_t DX12Convert(WisSampleCount value) noexcept { return static_cast(value); } constexpr inline DXGI_GPU_PREFERENCE DX12Convert(WisAdapterPreference value) noexcept { @@ -404,17 +402,11 @@ constexpr inline D3D12_PRIMITIVE_TOPOLOGY_TYPE DX12Convert(WisTopologyType value } } -constexpr inline D3D12_FILL_MODE DX12Convert(WisFillMode value) noexcept { - return static_cast(value); -} +constexpr inline D3D12_FILL_MODE DX12Convert(WisFillMode value) noexcept { return static_cast(value); } -constexpr inline D3D12_CULL_MODE DX12Convert(WisCullMode value) noexcept { - return static_cast(value); -} +constexpr inline D3D12_CULL_MODE DX12Convert(WisCullMode value) noexcept { return static_cast(value); } -constexpr inline BOOL DX12Convert(WisWindingOrder value) noexcept { - return static_cast(value); -} +constexpr inline BOOL DX12Convert(WisWindingOrder value) noexcept { return static_cast(value); } constexpr inline D3D12_CONSERVATIVE_RASTERIZATION_MODE DX12Convert(WisConservativeRasterization value) noexcept { @@ -426,17 +418,11 @@ constexpr inline D3D12_LINE_RASTERIZATION_MODE DX12Convert(WisLineRasterization return static_cast(value); } -constexpr inline D3D12_BLEND DX12Convert(WisBlendFactor value) noexcept { - return static_cast(value); -} +constexpr inline D3D12_BLEND DX12Convert(WisBlendFactor value) noexcept { return static_cast(value); } -constexpr inline D3D12_BLEND_OP DX12Convert(WisBlendOp value) noexcept { - return static_cast(value); -} +constexpr inline D3D12_BLEND_OP DX12Convert(WisBlendOp value) noexcept { return static_cast(value); } -constexpr inline D3D12_LOGIC_OP DX12Convert(WisLogicOp value) noexcept { - return static_cast(value); -} +constexpr inline D3D12_LOGIC_OP DX12Convert(WisLogicOp value) noexcept { return static_cast(value); } constexpr inline D3D_PRIMITIVE_TOPOLOGY DX12Convert(WisPrimitiveTopology value) noexcept { diff --git a/src/include/wisdom/generated/vk_convert.hpp b/src/include/wisdom/generated/vk_convert.hpp index 8628bbd48..24abc9e40 100644 --- a/src/include/wisdom/generated/vk_convert.hpp +++ b/src/include/wisdom/generated/vk_convert.hpp @@ -371,7 +371,7 @@ constexpr inline VkMemoryPropertyFlags VKConvert(WisMemoryType value) noexcept return VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT; case WisMemoryTypeGPUUpload: return VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT - | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; default: return static_cast(0); } @@ -855,9 +855,9 @@ constexpr inline VkPipelineStageFlags2 VKConvert(WisBarrierSync value) noexcept } if (value & WisBarrierSyncDraw) { result |= VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT | VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT - | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT - | VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT - | VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; + | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT + | VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT + | VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT; } if (value & WisBarrierSyncIndexInput) { result |= VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT; @@ -885,14 +885,14 @@ constexpr inline VkPipelineStageFlags2 VKConvert(WisBarrierSync value) noexcept } if (value & WisBarrierSyncResolve) { result |= VK_PIPELINE_STAGE_2_COPY_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT - | VK_PIPELINE_STAGE_2_RESOLVE_BIT | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; + | VK_PIPELINE_STAGE_2_RESOLVE_BIT | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; } if (value & WisBarrierSyncExecuteIndirect) { result |= VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; } if (value & WisBarrierSyncAllShading) { result |= VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT - | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; + | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; } if (value & WisBarrierSyncNonPixelShading) { result |= VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; diff --git a/src/include/wisdom/global/internal.hpp b/src/include/wisdom/global/internal.hpp index 29cca6a0a..c1ac2ff2b 100644 --- a/src/include/wisdom/global/internal.hpp +++ b/src/include/wisdom/global/internal.hpp @@ -78,9 +78,7 @@ struct Implements { } /// @brief Destructor, calls the Deleter on the internal implementation - ~Implements() noexcept { - Deleter{}(GetStorage()); - } + ~Implements() noexcept { Deleter{}(GetStorage()); } public: /// @brief Get the immutable internal implementation @@ -99,9 +97,7 @@ struct Implements { /// @brief Get the storage pointer /// @return Pointer to the storage - [[nodiscard]] Storage* GetStorage() noexcept { - return &_impl_storage; - } + [[nodiscard]] Storage* GetStorage() noexcept { return &_impl_storage; } /// @brief Check if the handle holds a valid object /// @return true if the first 8 bytes of storage are non-zero @@ -112,9 +108,7 @@ struct Implements { } /// @brief Bool conversion, checks handle validity - explicit operator bool() const noexcept { - return IsValid(); - } + explicit operator bool() const noexcept { return IsValid(); } public: Storage _impl_storage; diff --git a/src/include/wisdom/vulkan/detail/vk_detail.hpp b/src/include/wisdom/vulkan/detail/vk_detail.hpp index 32741f140..44e833c4b 100644 --- a/src/include/wisdom/vulkan/detail/vk_detail.hpp +++ b/src/include/wisdom/vulkan/detail/vk_detail.hpp @@ -11,11 +11,11 @@ #include +#include #include #include #include #include -#include #include namespace wis::impl { @@ -43,12 +43,8 @@ struct VKScopeGuard { VKScopeGuard(const VKScopeGuard&) = delete; VKScopeGuard& operator=(const VKScopeGuard&) = delete; - HandleType* PutUnchecked() noexcept { - return &handle; - } - HandleType Release() noexcept { - return std::exchange(handle, nullptr); - } + HandleType* PutUnchecked() noexcept { return &handle; } + HandleType Release() noexcept { return std::exchange(handle, nullptr); } }; template @@ -147,7 +143,7 @@ struct VKDebugCallbackThunk { // Get device handle if possible uint64_t device = 0; for (auto&& obj : - wis::span {pCallbackData->pObjects, pCallbackData->objectCount}) { + wis::span{pCallbackData->pObjects, pCallbackData->objectCount}) { if (obj.objectType == VK_OBJECT_TYPE_DEVICE) { device = obj.objectHandle; break; @@ -273,8 +269,8 @@ struct VKDeviceHeader { // Destroy semaphores auto& last_family = queue_families[family_count - 1]; std::binary_semaphore* begin = reinterpret_cast( - reinterpret_cast(this) + sizeof(*this) - ); + reinterpret_cast(this) + sizeof(*this) + ); std::binary_semaphore* end = last_family.semaphore_offset + last_family.queue_count + begin; for (std::binary_semaphore* sem = begin; sem < end; ++sem) { sem->release(); @@ -295,7 +291,7 @@ struct VKDeviceHeader { return nullptr; // No valid family index for this queue type } return reinterpret_cast(reinterpret_cast(this) + sizeof(*this)) - + queue_families[type].semaphore_offset + queue_index; + + queue_families[type].semaphore_offset + queue_index; } }; @@ -328,11 +324,11 @@ struct VKSwapchainHeader { VkSurfaceKHR surface; // store surface handle for later use in presentation and swapchain recreation VkPhysicalDevice physical_device; // store physical device for later use in swapchain recreation PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR - vkGetPhysicalDeviceSurfaceCapabilities2KHR; // store function pointer for later use in swapchain recreation + vkGetPhysicalDeviceSurfaceCapabilities2KHR; // store function pointer for later use in swapchain recreation VkSwapchainCreateInfoKHR create_info; // store create info for later use in presentation and swapchain recreation VkSwapchainPresentScalingCreateInfoKHR - scaling_create_info; // store scaling create info for later use in presentation and swapchain recreation + scaling_create_info; // store scaling create info for later use in presentation and swapchain recreation VkPresentModeKHR modes[reasonable_mode_count]; uint8_t mode_count; @@ -341,29 +337,29 @@ struct VKSwapchainHeader { wis::span GetImageAvailableSemaphores() const noexcept { - return wis::span {reinterpret_cast(this + 1), create_info.minImageCount}; + return wis::span{reinterpret_cast(this + 1), create_info.minImageCount}; } wis::span GetRenderFinishedSemaphores() const noexcept { - return wis::span { + return wis::span{ reinterpret_cast(this + 1) + create_info.minImageCount, create_info.minImageCount }; } wis::span GetSemaphores() const noexcept { - return wis::span { + return wis::span{ reinterpret_cast(this + 1), create_info.minImageCount * 2 }; } wis::span GetSupportedPresentModes() const noexcept { - return wis::span {modes, mode_count}; + return wis::span{modes, mode_count}; } wis::span GetSupportedFormats() noexcept { - return wis::span { + return wis::span{ reinterpret_cast(this + 1) + create_info.minImageCount * 2, format_count }; @@ -400,24 +396,24 @@ struct alignas(void*) VKRootSignatureControlBlock { wis::span GetRootBindingOffsets() const noexcept { - return wis::span {reinterpret_cast(this + 1), root_parameter_count}; + return wis::span{reinterpret_cast(this + 1), root_parameter_count}; } wis::span GetRootBindingOffsets() noexcept { - return wis::span {reinterpret_cast(this + 1), root_parameter_count}; + return wis::span{reinterpret_cast(this + 1), root_parameter_count}; } wis::span GetMappings() noexcept { - return wis::span { + return wis::span{ reinterpret_cast(GetRootBindingOffsets().end()), mapping_count }; } wis::span GetMappings() const noexcept { - return wis::span { + return wis::span{ reinterpret_cast(GetRootBindingOffsets().end()), mapping_count }; @@ -626,8 +622,8 @@ inline void VKReleaseSwapchain(VkSwapchainKHR swap, VKSwapchainControlBlock* hea //---------------------------------------------------------------------------------------------------------------------- // Barrier helper constants constexpr static uint32_t vk_max_barrier_size = std::max( -{sizeof(VkBufferMemoryBarrier), sizeof(VkImageMemoryBarrier2), sizeof(VkMemoryBarrier2)} - ); + {sizeof(VkBufferMemoryBarrier), sizeof(VkImageMemoryBarrier2), sizeof(VkMemoryBarrier2)} +); constexpr static uint32_t vk_static_barrier_size = WIS_TRANSIENT_MAX_BARRIER_COUNT * vk_max_barrier_size; template @@ -650,8 +646,8 @@ inline std::array, 3> VKAllocateBarriers( { std::array, 3> spans; std::size_t needed_size = barriers.buffer_barrier_count * sizeof(VkBufferMemoryBarrier2) - + barriers.texture_barrier_count * sizeof(VkImageMemoryBarrier2) - + barriers.global_barrier_count * sizeof(VkMemoryBarrier2); + + barriers.texture_barrier_count * sizeof(VkImageMemoryBarrier2) + + barriers.global_barrier_count * sizeof(VkMemoryBarrier2); if (needed_size <= vk_static_barrier_size) { spans[0] = {local_scratch, barriers.buffer_barrier_count * sizeof(VkBufferMemoryBarrier2)}; @@ -735,7 +731,7 @@ inline void VKInsertBarriers(const Impl& impl, const WisVKBarrierGroup* barriers return; } - uint8_t local_scratch[vk_static_barrier_size] {}; + uint8_t local_scratch[vk_static_barrier_size]{}; auto [buffer_span, texture_span, global_span] = VKAllocateBarriers(impl, local_scratch, *barriers); @@ -787,8 +783,8 @@ inline void VKInsertBarriers(const Impl& impl, const WisVKBarrierGroup* barriers if (src.queue_type_before != src.queue_type_after) { if (impl.maintenance9 - && (impl.queue_indices[src.queue_type_before].compatible_to_families - & (1 << impl.queue_indices[src.queue_type_after].family_index))) { + && (impl.queue_indices[src.queue_type_before].compatible_to_families + & (1 << impl.queue_indices[src.queue_type_after].family_index))) { if (src.queue_type_before == impl.queue_type) { real_texture_barrier_count--; continue; diff --git a/src/include/wisdom/vulkan/detail/vk_ext1.hpp b/src/include/wisdom/vulkan/detail/vk_ext1.hpp index 9a937716a..443490af3 100644 --- a/src/include/wisdom/vulkan/detail/vk_ext1.hpp +++ b/src/include/wisdom/vulkan/detail/vk_ext1.hpp @@ -165,34 +165,33 @@ struct DeviceExtension1 : VKDeviceExtensionImpl { if (features.descriptor_heap) { // Descriptor heap properties auto& descriptor_heap_properties = *collector.GetEnabledPropertyStruct< - VkPhysicalDeviceDescriptorHeapPropertiesEXT>( - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_HEAP_PROPERTIES_EXT - ); + VkPhysicalDeviceDescriptorHeapPropertiesEXT>( + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_HEAP_PROPERTIES_EXT + ); // A lot of space is going to be wasted, but the usage will be simpler and more efficient if we use the same // size for both resource and sampler descriptors, so we take the max of the two alignments as the // descriptor size features.resource_desc_size = static_cast(std::max( - descriptor_heap_properties.imageDescriptorAlignment, - descriptor_heap_properties.bufferDescriptorAlignment - )); + descriptor_heap_properties.imageDescriptorAlignment, + descriptor_heap_properties.bufferDescriptorAlignment + )); features.sampler_desc_size = static_cast(descriptor_heap_properties.samplerDescriptorAlignment); features.max_root_space = static_cast(descriptor_heap_properties.maxPushDataSize); features.descriptor_heap_reserved_size = wis::aligned_size( - static_cast(descriptor_heap_properties.minResourceHeapReservedRange), - features.resource_desc_size - ); + static_cast(descriptor_heap_properties.minResourceHeapReservedRange), + features.resource_desc_size + ); features.sampler_heap_reserved_size = wis::aligned_size( - static_cast(descriptor_heap_properties.minSamplerHeapReservedRange), - features.sampler_desc_size - ); + static_cast(descriptor_heap_properties.minSamplerHeapReservedRange), + features.sampler_desc_size + ); features.sampler_heap_reserved_size_with_embedded = wis::aligned_size( - static_cast(descriptor_heap_properties.minSamplerHeapReservedRangeWithEmbedded), - features.sampler_desc_size - ); - features.descriptor_heap_alignment = static_cast( - descriptor_heap_properties.resourceHeapAlignment - ); + static_cast(descriptor_heap_properties.minSamplerHeapReservedRangeWithEmbedded), + features.sampler_desc_size + ); + features.descriptor_heap_alignment = static_cast(descriptor_heap_properties.resourceHeapAlignment + ); features.sampler_heap_alignment = static_cast(descriptor_heap_properties.samplerHeapAlignment); features.max_descriptor_heap_size = descriptor_heap_properties.maxResourceHeapSize; features.max_sampler_heap_size = descriptor_heap_properties.maxSamplerHeapSize; @@ -200,11 +199,11 @@ struct DeviceExtension1 : VKDeviceExtensionImpl { // Get Device properties auto& device_properties = *collector.GetEnabledPropertyStruct( - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 - ); + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 + ); features.max_vertex_attributes = static_cast( - device_properties.properties.limits.maxVertexInputAttributes - ); + device_properties.properties.limits.maxVertexInputAttributes + ); features.max_vertex_bindings = static_cast(device_properties.properties.limits.maxVertexInputBindings); features.multiple_viewports = device_properties.properties.limits.maxViewports > 1 ? 1 : 0; diff --git a/src/include/wisdom/vulkan/vk_adapter_query.cpp b/src/include/wisdom/vulkan/vk_adapter_query.cpp index cfdb254fb..829e96ef3 100644 --- a/src/include/wisdom/vulkan/vk_adapter_query.cpp +++ b/src/include/wisdom/vulkan/vk_adapter_query.cpp @@ -40,7 +40,7 @@ struct VKQueueResidencyInfo { //---------------------------------------------------------------------------------------------------------------------- // For simplicity, we assign the same global priority to all queues. // In a real implementation, you might want to differentiate based on queue type. -static constexpr VkDeviceQueueGlobalPriorityCreateInfo vk_global_priorities[] { +static constexpr VkDeviceQueueGlobalPriorityCreateInfo vk_global_priorities[]{ { .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO, .pNext = nullptr, @@ -132,19 +132,15 @@ inline std::array VKGetSortedQueueFamilies( // Scenario B: We found a shared G+C queue, but now we found a DISTINCT Compute queue. // Overwrite the previous choice! This is how you get Async Compute. - else if ( - (props_span[current].queueFamilyProperties.queueFlags & VK_QUEUE_GRAPHICS_BIT) - && !(flags & VK_QUEUE_GRAPHICS_BIT) - ) { + else if ((props_span[current].queueFamilyProperties.queueFlags & VK_QUEUE_GRAPHICS_BIT) + && !(flags & VK_QUEUE_GRAPHICS_BIT)) { qcom[WisCommandQueueTypeCompute] = i; } // Scenario C: We have found another G+C, but it is different from WisCommandQueueTypeGraphics (probably // impossible) - else if ( - (props_span[current].queueFamilyProperties.queueFlags & VK_QUEUE_GRAPHICS_BIT) - && qcom[WisCommandQueueTypeGraphics] != i - ) { + else if ((props_span[current].queueFamilyProperties.queueFlags & VK_QUEUE_GRAPHICS_BIT) + && qcom[WisCommandQueueTypeGraphics] != i) { qcom[WisCommandQueueTypeCompute] = i; } } @@ -159,7 +155,7 @@ inline std::array VKGetSortedQueueFamilies( } constexpr static VkQueueFlags transfer_safe_mask = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT - | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT; + | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT; // --- TRANSFER SELECTION --- // Goal: Dedicated Transfer > Compute (Async) > Graphics (Fallback). @@ -231,8 +227,8 @@ inline VKQueueResidencyInfo VKGetQueueResidencyInfo( if (queue_descs.size() > WisCommandQueueTypeCount) { out_result = wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); return info; } @@ -247,8 +243,8 @@ inline VKQueueResidencyInfo VKGetQueueResidencyInfo( // No queues available, return empty info if (!queue_descs.empty()) { out_result = wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } return info; } @@ -276,8 +272,8 @@ inline VKQueueResidencyInfo VKGetQueueResidencyInfo( if (props_span.data() == nullptr) { out_result = wis::detail::make_result< - wis::detail::Func(), - "Not enough memory for device queue family properties array">(VK_ERROR_OUT_OF_HOST_MEMORY); + wis::detail::Func(), + "Not enough memory for device queue family properties array">(VK_ERROR_OUT_OF_HOST_MEMORY); } adapter_table.vkGetPhysicalDeviceQueueFamilyProperties2(adapter, &queue_family_count, props_span.data()); @@ -289,15 +285,14 @@ inline VKQueueResidencyInfo VKGetQueueResidencyInfo( std::array pQueuePriorities; std::fill_n(pQueuePriorities.data(), pQueuePriorities.size(), 1.0f); return pQueuePriorities; - } - (); + }(); for (std::size_t i = 0; i < queue_descs.size(); ++i) { auto& desc = queue_descs[i]; if (desc.type >= WisCommandQueueTypeCount) { out_result = wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); return info; } @@ -339,7 +334,7 @@ inline VKQueueResidencyInfo VKGetQueueResidencyInfo( } info.residency[desc.type] = family_props - .queueFlags = allocated_queue_count; // Store where the family is allocated in + .queueFlags = allocated_queue_count; // Store where the family is allocated in // the residency field (abusing queueFlags // for this purpose) @@ -463,17 +458,14 @@ WIS_EXTERN_C WISDOM_API size_t wisVKAdapterQueryGetAdapterCount(const WisVKAdapt } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryGetAdapterDesc( - const WisVKAdapterQuery* self, - size_t index, - WisAdapterDesc* desc -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKAdapterQueryGetAdapterDesc(const WisVKAdapterQuery* self, size_t index, WisAdapterDesc* desc) { const auto& impl = *wis::from_handle(self); if (index >= impl.adapter_count) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } const auto& atable = impl.shared_header->header.adapter_table; auto adapter = impl.physical_devices[index]; @@ -495,11 +487,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryGetAdapterDesc( // Get flags WisAdapterFlags flag{}; if ((got_desc.deviceType & VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) - == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) { + == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) { flag = static_cast(flag | WisAdapterFlags::WisAdapterFlagsRemote); } if ((got_desc.deviceType & VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_CPU) - == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_CPU) { + == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_CPU) { flag = static_cast(flag | WisAdapterFlags::WisAdapterFlagsSoftware); } @@ -509,8 +501,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryGetAdapterDesc( wis::span types{memory_props.memoryTypes}; for (auto& i : types) { if (i.propertyFlags & VkMemoryPropertyFlagBits::VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT - && memory_props.memoryHeaps[i.heapIndex].flags - & VkMemoryPropertyFlagBits::VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) { + && memory_props.memoryHeaps[i.heapIndex].flags + & VkMemoryPropertyFlagBits::VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) { dedicated_video_memory = memory_props.memoryHeaps[i.heapIndex].size; } @@ -564,11 +556,11 @@ WIS_EXTERN_C WISDOM_API bool wisVKAdapterQueryGetSurfaceSupport( if (props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { VkBool32 supported = VK_FALSE; auto vr = atable.vkGetPhysicalDeviceSurfaceSupportKHR( - impl.physical_devices[index], - i, - vk_surface, - &supported - ); + impl.physical_devices[index], + i, + vk_surface, + &supported + ); if (wis::detail::succeeded(vr) && supported == VK_TRUE) { return true; } @@ -588,8 +580,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( auto& impl = *wis::from_handle(self); if (index >= impl.adapter_count) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } auto& atable = impl.shared_header->header.adapter_table; @@ -605,7 +597,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( if (requirements) { for (size_t i = 0; i < requirements->extension_count; ++i) { if (auto* ext_header = wis::from_handle(requirements->extensions[i]); - ext_header && ext_header->init_fptr) { + ext_header && ext_header->init_fptr) { auto res2 = ext_header->init_fptr(ext_header, nullptr, &collector); // Non-fatal, allow to silently fail (void)res2; @@ -708,13 +700,12 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( } control_block_size += sizeof(std::binary_semaphore) * semaphore_count; - std::unique_ptr header_storage{ - static_cast(operator new(control_block_size, std::nothrow)) + std::unique_ptr header_storage{static_cast(operator new(control_block_size, std::nothrow)) }; if (!header_storage) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } // Start header lifetime @@ -741,11 +732,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( if (queue_family.pNext) { // Global priority info is present in the pNext chain, store it in the device header const auto* global_priority_info = reinterpret_cast( - queue_family.pNext - ); + queue_family.pNext + ); family_info.queue_priority = static_cast( - wis::detail::VKConvertGlobalPriority(global_priority_info->globalPriority) - ); + wis::detail::VKConvertGlobalPriority(global_priority_info->globalPriority) + ); } semaphore_offset += family_info.queue_count; @@ -774,31 +765,31 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( if (!device_table.Init(device_handle, gtable.vkGetDeviceProcAddr)) { device_table.vkDestroyDevice(device_handle, nullptr); // cleanup return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } // Initialize command queue table if (!header->header.command_queue_table.Init(device_handle, gtable.vkGetDeviceProcAddr)) { device_table.vkDestroyDevice(device_handle, nullptr); // cleanup return wis::detail::make_result< - wis::detail::Func(), - "Failed to initialize Vulkan command queue function table">(VK_ERROR_UNKNOWN); + wis::detail::Func(), + "Failed to initialize Vulkan command queue function table">(VK_ERROR_UNKNOWN); } // Initialize command list table if (!header->header.command_list_table.Init(device_handle, gtable.vkGetDeviceProcAddr)) { device_table.vkDestroyDevice(device_handle, nullptr); // cleanup return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } if (!header->header.swapchain_table.Init(device_handle, gtable.vkGetDeviceProcAddr)) { device_table.vkDestroyDevice(device_handle, nullptr); // cleanup return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } // Create resource allocator @@ -832,11 +823,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKAdapterQueryCreateDevice( // Initialize device extensions if (requirements) { for (auto* ext : - wis::span {requirements->extensions, requirements->extension_count}) { + wis::span{requirements->extensions, requirements->extension_count}) { if (auto* ext_header = wis::from_handle(ext); - ext_header && ext_header->init_fptr) { + ext_header && ext_header->init_fptr) { if (auto yres = ext_header->init_fptr(ext_header, &device_impl, &collector); - yres.status != WisStatusOk) { + yres.status != WisStatusOk) { res.status = WisStatusPartial; // mark as partial success if any extension fails res.error = yres.error; res.platform_code = yres.platform_code; diff --git a/src/include/wisdom/vulkan/vk_command_allocator.cpp b/src/include/wisdom/vulkan/vk_command_allocator.cpp index af6f2e153..593164f5a 100644 --- a/src/include/wisdom/vulkan/vk_command_allocator.cpp +++ b/src/include/wisdom/vulkan/vk_command_allocator.cpp @@ -22,10 +22,10 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCommandAllocatorReset(const WisVKCommandA auto& header = impl.command_pool_header->header; auto& device_header = header.device_header->header; auto result = device_header.device_table.vkResetCommandPool( - header.device, - impl.command_pool, - VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT - ); + header.device, + impl.command_pool, + VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT + ); if (!wis::detail::succeeded(result)) { return wis::detail::make_result(result); @@ -35,10 +35,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCommandAllocatorReset(const WisVKCommandA } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKCommandAllocatorCreateCommandList( - const WisVKCommandAllocator* self, - WisVKCommandList* list -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKCommandAllocatorCreateCommandList(const WisVKCommandAllocator* self, WisVKCommandList* list) { auto& impl = wis::from_handle_ref(self); auto& header = impl.command_pool_header->header; diff --git a/src/include/wisdom/vulkan/vk_command_list.cpp b/src/include/wisdom/vulkan/vk_command_list.cpp index 9b9df387e..149a867c3 100644 --- a/src/include/wisdom/vulkan/vk_command_list.cpp +++ b/src/include/wisdom/vulkan/vk_command_list.cpp @@ -60,9 +60,9 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetDescriptorHeaps( if (resource_heap) { auto& res_heap = wis::from_handle_ref(resource_heap); VkDeviceSize reserved_resource_descriptor_size = static_cast(res_heap.reserved_size) - * res_heap.descriptor_size; + * res_heap.descriptor_size; VkDeviceSize total_resource_heap_size = static_cast(res_heap.heap_size) * res_heap.descriptor_size - + reserved_resource_descriptor_size; + + reserved_resource_descriptor_size; VkBindHeapInfoEXT bind_resource_info{ .sType = VK_STRUCTURE_TYPE_BIND_HEAP_INFO_EXT, .pNext = nullptr, @@ -76,9 +76,9 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetDescriptorHeaps( if (sampler_heap) { auto& samp_heap = wis::from_handle_ref(sampler_heap); VkDeviceSize reserved_sampler_descriptor_size = static_cast(samp_heap.reserved_size) - * samp_heap.descriptor_size; + * samp_heap.descriptor_size; VkDeviceSize total_sampler_heap_size = static_cast(samp_heap.heap_size) * samp_heap.descriptor_size - + reserved_sampler_descriptor_size; + + reserved_sampler_descriptor_size; VkBindHeapInfoEXT bind_sampler_info{ .sType = VK_STRUCTURE_TYPE_BIND_HEAP_INFO_EXT, .pNext = nullptr, @@ -204,7 +204,7 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetViewports( }; } impl.command_list_table - ->vkCmdSetViewportWithCount(impl.command_buffer, static_cast(max_count), vk_viewports); + ->vkCmdSetViewportWithCount(impl.command_buffer, static_cast(max_count), vk_viewports); } //---------------------------------------------------------------------------------------------------------------------- @@ -240,7 +240,7 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetDepthBias( { auto& impl = wis::from_handle_ref(self); impl.command_list_table - ->vkCmdSetDepthBias(impl.command_buffer, depth_bias, depth_bias_clamp, slope_scaled_depth_bias); + ->vkCmdSetDepthBias(impl.command_buffer, depth_bias, depth_bias_clamp, slope_scaled_depth_bias); } //---------------------------------------------------------------------------------------------------------------------- @@ -428,7 +428,7 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListDrawIndexed( { auto& impl = wis::from_handle_ref(self); impl.command_list_table - ->vkCmdDrawIndexed(impl.command_buffer, index_count, instance_count, start_index, base_vertex, start_instance); + ->vkCmdDrawIndexed(impl.command_buffer, index_count, instance_count, start_index, base_vertex, start_instance); } //---------------------------------------------------------------------------------------------------------------------- @@ -469,8 +469,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyBufferToTexture( while (region_offset < region_count) { uint32_t current_region_count = static_cast( - std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) - ); + std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) + ); for (size_t i = 0; i < current_region_count; ++i) { const auto& region = regions[region_offset + i]; @@ -487,8 +487,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyBufferToTexture( } if (aspect_mask == 0) { aspect_mask = (region.texture_region.flags & WisBarrierFlagsPlanarImage) - ? (VK_IMAGE_ASPECT_PLANE_0_BIT << subresource.plane_slice) - : VK_IMAGE_ASPECT_COLOR_BIT; + ? (VK_IMAGE_ASPECT_PLANE_0_BIT << subresource.plane_slice) + : VK_IMAGE_ASPECT_COLOR_BIT; } convert_regions[i] = { @@ -496,18 +496,18 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyBufferToTexture( .bufferRowLength = region.buffer_row_length, .bufferImageHeight = region.buffer_image_height, .imageSubresource = - { - .aspectMask = aspect_mask, - .mipLevel = subresource.mip_level, - .baseArrayLayer = subresource.array_layer, - .layerCount = 1, - }, + { + .aspectMask = aspect_mask, + .mipLevel = subresource.mip_level, + .baseArrayLayer = subresource.array_layer, + .layerCount = 1, + }, .imageOffset = - { - .x = static_cast(box.x), - .y = static_cast(box.y), - .z = static_cast(box.z), - }, + { + .x = static_cast(box.x), + .y = static_cast(box.y), + .z = static_cast(box.z), + }, .imageExtent = {.width = box.width, .height = box.height, .depth = box.depth}, }; } @@ -540,8 +540,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTextureToBuffer( while (region_offset < region_count) { uint32_t current_region_count = static_cast( - std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) - ); + std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) + ); for (size_t i = 0; i < current_region_count; ++i) { const auto& region = regions[region_offset + i]; @@ -558,8 +558,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTextureToBuffer( } if (aspect_mask == 0) { aspect_mask = (region.texture_region.flags & WisBarrierFlagsPlanarImage) - ? (VK_IMAGE_ASPECT_PLANE_0_BIT << subresource.plane_slice) - : VK_IMAGE_ASPECT_COLOR_BIT; + ? (VK_IMAGE_ASPECT_PLANE_0_BIT << subresource.plane_slice) + : VK_IMAGE_ASPECT_COLOR_BIT; } convert_regions[i] = { @@ -567,18 +567,18 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTextureToBuffer( .bufferRowLength = region.buffer_row_length, .bufferImageHeight = region.buffer_image_height, .imageSubresource = - { - .aspectMask = aspect_mask, - .mipLevel = subresource.mip_level, - .baseArrayLayer = subresource.array_layer, - .layerCount = 1, - }, + { + .aspectMask = aspect_mask, + .mipLevel = subresource.mip_level, + .baseArrayLayer = subresource.array_layer, + .layerCount = 1, + }, .imageOffset = - { - .x = static_cast(box.x), - .y = static_cast(box.y), - .z = static_cast(box.z), - }, + { + .x = static_cast(box.x), + .y = static_cast(box.y), + .z = static_cast(box.z), + }, .imageExtent = {.width = box.width, .height = box.height, .depth = box.depth}, }; } @@ -611,8 +611,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTexture( while (region_offset < region_count) { uint32_t current_region_count = static_cast( - std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) - ); + std::min(region_count - region_offset, static_cast(wis::MaxCopyRegions)) + ); for (size_t i = 0; i < current_region_count; ++i) { const auto& region = regions[region_offset + i]; @@ -630,8 +630,8 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTexture( } if (src_aspect_mask == 0) { src_aspect_mask = (region.src_region.flags & WisBarrierFlagsPlanarImage) - ? (VK_IMAGE_ASPECT_PLANE_0_BIT << src_subresource.plane_slice) - : VK_IMAGE_ASPECT_COLOR_BIT; + ? (VK_IMAGE_ASPECT_PLANE_0_BIT << src_subresource.plane_slice) + : VK_IMAGE_ASPECT_COLOR_BIT; } VkImageAspectFlags dst_aspect_mask = 0; @@ -643,37 +643,37 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListCopyTexture( } if (dst_aspect_mask == 0) { dst_aspect_mask = (region.dst_region.flags & WisBarrierFlagsPlanarImage) - ? (VK_IMAGE_ASPECT_PLANE_0_BIT << dst_subresource.plane_slice) - : VK_IMAGE_ASPECT_COLOR_BIT; + ? (VK_IMAGE_ASPECT_PLANE_0_BIT << dst_subresource.plane_slice) + : VK_IMAGE_ASPECT_COLOR_BIT; } convert_regions[i] = { .srcSubresource = - { - .aspectMask = src_aspect_mask, - .mipLevel = src_subresource.mip_level, - .baseArrayLayer = src_subresource.array_layer, - .layerCount = 1, - }, + { + .aspectMask = src_aspect_mask, + .mipLevel = src_subresource.mip_level, + .baseArrayLayer = src_subresource.array_layer, + .layerCount = 1, + }, .srcOffset = - { - .x = static_cast(src_box.x), - .y = static_cast(src_box.y), - .z = static_cast(src_box.z), - }, + { + .x = static_cast(src_box.x), + .y = static_cast(src_box.y), + .z = static_cast(src_box.z), + }, .dstSubresource = - { - .aspectMask = dst_aspect_mask, - .mipLevel = dst_subresource.mip_level, - .baseArrayLayer = dst_subresource.array_layer, - .layerCount = 1, - }, + { + .aspectMask = dst_aspect_mask, + .mipLevel = dst_subresource.mip_level, + .baseArrayLayer = dst_subresource.array_layer, + .layerCount = 1, + }, .dstOffset = - { - .x = static_cast(dst_box.x), - .y = static_cast(dst_box.y), - .z = static_cast(dst_box.z), - }, + { + .x = static_cast(dst_box.x), + .y = static_cast(dst_box.y), + .z = static_cast(dst_box.z), + }, .extent = {.width = src_box.width, .height = src_box.height, .depth = src_box.depth}, }; } @@ -717,7 +717,7 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetVertexBuffers( } impl.command_list_table - ->vkCmdBindVertexBuffers2(impl.command_buffer, start_slot, count, buffers_vk, offsets, sizes, strides); + ->vkCmdBindVertexBuffers2(impl.command_buffer, start_slot, count, buffers_vk, offsets, sizes, strides); } //---------------------------------------------------------------------------------------------------------------------- @@ -738,17 +738,17 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetVertexBuffers2( .pNext = nullptr, .setStride = VK_TRUE, .addressRange = - { - .address = buffers[i].buffer, - .size = buffers[i].size, - .stride = buffers[i].stride, - }, + { + .address = buffers[i].buffer, + .size = buffers[i].size, + .stride = buffers[i].stride, + }, .addressFlags = 0, // reserved for future use }; } impl.command_list_table - ->vkCmdBindVertexBuffers3KHR(impl.command_buffer, start_slot, count, bind_vertex_buffer_infos); + ->vkCmdBindVertexBuffers3KHR(impl.command_buffer, start_slot, count, bind_vertex_buffer_infos); } //---------------------------------------------------------------------------------------------------------------------- @@ -781,10 +781,10 @@ WIS_EXTERN_C WISDOM_API void wisVKCommandListSetIndexBuffer2( .sType = VK_STRUCTURE_TYPE_BIND_INDEX_BUFFER_3_INFO_KHR, .pNext = nullptr, .addressRange = - { - .address = buffer->buffer, - .size = buffer->size, - }, + { + .address = buffer->buffer, + .size = buffer->size, + }, .addressFlags = 0, // reserved for future use .indexType = wis::detail::VKConvert(index_type), }; diff --git a/src/include/wisdom/vulkan/vk_command_queue.cpp b/src/include/wisdom/vulkan/vk_command_queue.cpp index 1e34aa161..f071115e7 100644 --- a/src/include/wisdom/vulkan/vk_command_queue.cpp +++ b/src/include/wisdom/vulkan/vk_command_queue.cpp @@ -21,11 +21,8 @@ WIS_EXTERN_C WISDOM_API void wisVKDestroyCommandQueue(WisVKCommandQueue* self) } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKCommandQueueSubmit( - const WisVKCommandQueue* self, - const WisVKCommandListView* lists, - size_t count -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKCommandQueueSubmit(const WisVKCommandQueue* self, const WisVKCommandListView* lists, size_t count) { auto& impl = wis::from_handle_ref(self); @@ -46,11 +43,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCommandQueueSubmit( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKCommandQueueSignalFence( - const WisVKCommandQueue* self, - WisVKFenceView fence, - uint64_t value -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKCommandQueueSignalFence(const WisVKCommandQueue* self, WisVKFenceView fence, uint64_t value) { auto& impl = wis::from_handle_ref(self); VkQueue queue = impl.queue; @@ -75,11 +69,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCommandQueueSignalFence( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKCommandQueueWaitFence( - const WisVKCommandQueue* self, - WisVKFenceView fence, - uint64_t value -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKCommandQueueWaitFence(const WisVKCommandQueue* self, WisVKFenceView fence, uint64_t value) { auto& impl = wis::from_handle_ref(self); VkQueue queue = impl.queue; diff --git a/src/include/wisdom/vulkan/vk_descriptor_heap.cpp b/src/include/wisdom/vulkan/vk_descriptor_heap.cpp index bbb49b38d..ca54117a7 100644 --- a/src/include/wisdom/vulkan/vk_descriptor_heap.cpp +++ b/src/include/wisdom/vulkan/vk_descriptor_heap.cpp @@ -12,12 +12,12 @@ namespace wis::detail { inline VkImageAspectFlags VKGetAspectFlags(const WisTextureBinding& binding) noexcept { if ((binding.flags & WisTextureBindingFlagsStencilView) - && (binding.format == WisDataFormatD24UnormS8Uint || binding.format == WisDataFormatD32FloatS8Uint)) { + && (binding.format == WisDataFormatD24UnormS8Uint || binding.format == WisDataFormatD32FloatS8Uint)) { return VK_IMAGE_ASPECT_STENCIL_BIT; } if ((binding.flags & WisTextureBindingFlagsDepthView) && (binding.format == WisDataFormatD32FloatS8Uint || binding.format == WisDataFormatD24UnormS8Uint) - || (binding.format == WisDataFormatD16Unorm || binding.format == WisDataFormatD32Float)) { + || (binding.format == WisDataFormatD16Unorm || binding.format == WisDataFormatD32Float)) { return VK_IMAGE_ASPECT_DEPTH_BIT; } if (binding.range.plane_slice) { @@ -33,12 +33,13 @@ inline VkImageViewCreateInfo VKGetSRVDesc(const WisTextureBinding& binding) noex .pNext = nullptr, .flags = 0, .format = wis::detail::VKConvert(binding.format), - .components = { - .r = wis::detail::VKConvert(binding.component_mapping.r), - .g = wis::detail::VKConvert(binding.component_mapping.g), - .b = wis::detail::VKConvert(binding.component_mapping.b), - .a = wis::detail::VKConvert(binding.component_mapping.a), - }, + .components = + { + .r = wis::detail::VKConvert(binding.component_mapping.r), + .g = wis::detail::VKConvert(binding.component_mapping.g), + .b = wis::detail::VKConvert(binding.component_mapping.b), + .a = wis::detail::VKConvert(binding.component_mapping.a), + }, }; auto aspect_flags = VKGetAspectFlags(binding); @@ -97,7 +98,7 @@ inline VkImageViewCreateInfo VKGetSRVDesc(const WisTextureBinding& binding) noex case WisTextureLayoutTexture2DMS: srv_desc.viewType = VK_IMAGE_VIEW_TYPE_2D; srv_desc.subresourceRange = - {.aspectMask = aspect_flags, .baseMipLevel = 0, .levelCount = 1, .baseArrayLayer = 0, .layerCount = 1}; + {.aspectMask = aspect_flags, .baseMipLevel = 0, .levelCount = 1, .baseArrayLayer = 0, .layerCount = 1}; break; case WisTextureLayoutTexture2DMSArray: srv_desc.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; @@ -342,7 +343,7 @@ WIS_EXTERN_C WISDOM_API void wisVKDestroyViewHeap(WisVKViewHeap* self) for (uint32_t i = 0; i < impl.capacity; ++i) { if (impl.view_heap[i].view != VK_NULL_HANDLE) { impl.device_header->header.device_table - .vkDestroyImageView(impl.device_header->header.device, impl.view_heap[i].view, nullptr); + .vkDestroyImageView(impl.device_header->header.device, impl.view_heap[i].view, nullptr); } } @@ -387,7 +388,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteConstantBuffer( VkResult result = table.vkWriteResourceDescriptorsEXT(heap.device, 1, &resource_desc, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } @@ -429,7 +430,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteStructuredBuffer( VkResult result = table.vkWriteResourceDescriptorsEXT(heap.device, 1, &resource_desc, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } @@ -447,11 +448,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteRWStructuredBuffer( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteSampler( - const WisVKDescriptorHeap* self, - const WisSamplerDesc* sampler, - uint32_t index -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDescriptorHeapWriteSampler(const WisVKDescriptorHeap* self, const WisSamplerDesc* sampler, uint32_t index) { auto& heap = wis::from_handle_ref(self); auto& table = heap.device_header->header.device_table; @@ -466,7 +464,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteSampler( .sType = VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO, .pNext = nullptr, // Custom border? .reductionMode = sampler->comparison_op != WisCompareOpNever ? VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE - : wis::detail::VKConvert(sampler->reduction_mode) + : wis::detail::VKConvert(sampler->reduction_mode) }; VkSamplerCreateInfo sampler_info{ .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, @@ -491,7 +489,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteSampler( VkResult result = table.vkWriteSamplerDescriptorsEXT(heap.device, 1, &sampler_info, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } @@ -536,7 +534,7 @@ WISDOM_API WisResult wisVKDescriptorHeapWriteTexture( VkResult result = table.vkWriteResourceDescriptorsEXT(heap.device, 1, &resource_desc, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } @@ -575,17 +573,14 @@ WISDOM_API WisResult wisVKDescriptorHeapWriteRWTexture( VkResult result = table.vkWriteResourceDescriptorsEXT(heap.device, 1, &resource_desc, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteAccelerationStructure( - const WisVKDescriptorHeap* self, - uint64_t address, - uint32_t index -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDescriptorHeapWriteAccelerationStructure(const WisVKDescriptorHeap* self, uint64_t address, uint32_t index) { auto& heap = wis::from_handle_ref(self); auto& table = heap.device_header->header.device_table; @@ -607,7 +602,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDescriptorHeapWriteAccelerationStructure( VkResult result = table.vkWriteResourceDescriptorsEXT(heap.device, 1, &resource_desc, &host_range); if (!wis::detail::succeeded(result)) { return wis::detail:: - make_result(result); + make_result(result); } return wis::detail::vk_success; } @@ -693,13 +688,13 @@ WIS_EXTERN_C WISDOM_API void wisVKViewHeapCopyViews( return; // Invalid range, do nothing } auto* src_views = reinterpret_cast(std::bit_cast(src_ptr)) - + src_index; + + src_index; auto* dst_views = heap.view_heap + dst_index; for (uint32_t i = 0; i < count; ++i) { // Destroy existing view at destination if it's not null if (dst_views[i].view != VK_NULL_HANDLE) { heap.device_header->header.device_table - .vkDestroyImageView(heap.device_header->header.device, dst_views[i].view, nullptr); + .vkDestroyImageView(heap.device_header->header.device, dst_views[i].view, nullptr); } dst_views[i] = src_views[i]; } diff --git a/src/include/wisdom/vulkan/vk_device.cpp b/src/include/wisdom/vulkan/vk_device.cpp index bddf2d1c2..b9474aced 100644 --- a/src/include/wisdom/vulkan/vk_device.cpp +++ b/src/include/wisdom/vulkan/vk_device.cpp @@ -29,7 +29,7 @@ constexpr VkSpirvResourceTypeFlagsEXT GetResourceTypeFlags(const WisDescriptorTy return VK_SPIRV_RESOURCE_TYPE_READ_WRITE_STORAGE_BUFFER_BIT_EXT; case WisDescriptorTypeBuffer: return VK_SPIRV_RESOURCE_TYPE_READ_WRITE_STORAGE_BUFFER_BIT_EXT - | VK_SPIRV_RESOURCE_TYPE_READ_ONLY_STORAGE_BUFFER_BIT_EXT; + | VK_SPIRV_RESOURCE_TYPE_READ_ONLY_STORAGE_BUFFER_BIT_EXT; case WisDescriptorTypeAccelerationStructure: return VK_SPIRV_RESOURCE_TYPE_ACCELERATION_STRUCTURE_BIT_EXT; default: @@ -37,8 +37,7 @@ constexpr VkSpirvResourceTypeFlagsEXT GetResourceTypeFlags(const WisDescriptorTy } } -inline std::array GetMapCountPerShaderType( - const WisRootSignatureDesc& desc +inline std::array GetMapCountPerShaderType(const WisRootSignatureDesc& desc ) noexcept { std::array counts{}; @@ -118,11 +117,8 @@ WIS_EXTERN_C WISDOM_API void wisVKDestroyDevice(WisVKDevice* self) } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateCommandQueue( - const WisVKDevice* self, - WisCommandQueueType type, - WisVKCommandQueue* queue -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDeviceCreateCommandQueue(const WisVKDevice* self, WisCommandQueueType type, WisVKCommandQueue* queue) { WisResult res = wis::detail::vk_success; auto& device = *wis::from_handle(self); @@ -132,16 +128,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateCommandQueue( using QueueTypeUnderlying = std::underlying_type_t; if (static_cast(type) < 0 || static_cast(type) >= WisCommandQueueTypeCount) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } // Get queue family index based on type uint8_t queue_family_index = device.device_header->header.queue_residency[static_cast(type)]; if (queue_family_index == wis::detail::VKQueueFamilyProperties::invalid_family_index) { return wis::detail::make_result< - wis::detail::Func(), - "No suitable queue family found for the requested queue type">(VK_ERROR_FEATURE_NOT_PRESENT); + wis::detail::Func(), + "No suitable queue family found for the requested queue type">(VK_ERROR_FEATURE_NOT_PRESENT); } auto& queue_family = device.device_header->header.queue_families[queue_family_index]; @@ -170,11 +166,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateCommandQueue( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateCommandAllocator( - const WisVKDevice* self, - WisCommandQueueType type, - WisVKCommandAllocator* allocator -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDeviceCreateCommandAllocator(const WisVKDevice* self, WisCommandQueueType type, WisVKCommandAllocator* allocator) { auto& device = *wis::from_handle(self); auto& table = device.device_header->header.device_table; @@ -183,24 +176,24 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateCommandAllocator( using QueueTypeUnderlying = std::underlying_type_t; if (static_cast(type) < 0 || static_cast(type) >= WisCommandQueueTypeCount) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } // Get queue family index based on type uint8_t queue_family_index = device.device_header->header.queue_residency[static_cast(type)]; if (queue_family_index == wis::detail::VKQueueFamilyProperties::invalid_family_index) { return wis::detail::make_result< - wis::detail::Func(), - "No suitable queue family found for the requested queue type">(VK_ERROR_FEATURE_NOT_PRESENT); + wis::detail::Func(), + "No suitable queue family found for the requested queue type">(VK_ERROR_FEATURE_NOT_PRESENT); } std::unique_ptr - pool_control_block = wis::make_unique(); + pool_control_block = wis::make_unique(); if (!pool_control_block) { return wis::detail::make_result< - wis::detail::Func(), - "Failed to allocate memory for command pool control block">(VK_ERROR_OUT_OF_HOST_MEMORY); + wis::detail::Func(), + "Failed to allocate memory for command pool control block">(VK_ERROR_OUT_OF_HOST_MEMORY); } uint8_t queue_family = device.device_header->header.queue_families[queue_family_index].family_index; @@ -231,11 +224,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateCommandAllocator( return wis::detail::vk_success; } -WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateFence( - const WisVKDevice* self, - uint64_t initial_value, - WisVKFence* fence -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDeviceCreateFence(const WisVKDevice* self, uint64_t initial_value, WisVKFence* fence) { WisResult res = wis::detail::vk_success; auto& device = *wis::from_handle(self); @@ -269,10 +259,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateFence( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetResourceAllocator( - const WisVKDevice* self, - WisVKResourceAllocator* allocator -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDeviceGetResourceAllocator(const WisVKDevice* self, WisVKResourceAllocator* allocator) { auto& device = *wis::from_handle(self); @@ -287,11 +275,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetResourceAllocator( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( - const WisVKDevice* self, - const WisDescriptorHeapDesc* desc, - WisVKDescriptorHeap* heap -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDeviceCreateDescriptorHeap(const WisVKDevice* self, const WisDescriptorHeapDesc* desc, WisVKDescriptorHeap* heap) { auto& device = *wis::from_handle(self); auto& header = device.device_header->header; @@ -301,8 +286,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( // 0. If heap is supported if (!features.descriptor_heap) { return wis::detail::make_result< - wis::detail::Func(), - "Descriptor heaps are not supported by this Vulkan device">(VK_ERROR_FEATURE_NOT_PRESENT); + wis::detail::Func(), + "Descriptor heaps are not supported by this Vulkan device">(VK_ERROR_FEATURE_NOT_PRESENT); } // 1. Calculate descriptor memory requirements based on desc @@ -311,32 +296,32 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( bool embedded_samplers = !(desc->flags & WisDescriptorHeapFlagsDisallowEmbeddedSamplers); std::size_t heap_alignment = is_shader_heap ? is_sampler_heap ? features.sampler_heap_alignment - : features.descriptor_heap_alignment - : __STDCPP_DEFAULT_NEW_ALIGNMENT__; + : features.descriptor_heap_alignment + : __STDCPP_DEFAULT_NEW_ALIGNMENT__; std::size_t descriptor_size = is_sampler_heap ? features.sampler_desc_size : features.resource_desc_size; std::size_t reserved_size = is_shader_heap ? is_sampler_heap ? embedded_samplers - ? features.sampler_heap_reserved_size_with_embedded - : features.sampler_heap_reserved_size - : features.descriptor_heap_reserved_size - : 0; + ? features.sampler_heap_reserved_size_with_embedded + : features.sampler_heap_reserved_size + : features.descriptor_heap_reserved_size + : 0; std::size_t max_heap_size = is_shader_heap - ? is_sampler_heap ? features.max_sampler_heap_size : features.max_descriptor_heap_size - : std::numeric_limits::max(); + ? is_sampler_heap ? features.max_sampler_heap_size : features.max_descriptor_heap_size + : std::numeric_limits::max(); std::size_t required_size = wis::aligned_size( - desc->descriptor_count * descriptor_size + reserved_size, - heap_alignment - ); + desc->descriptor_count * descriptor_size + reserved_size, + heap_alignment + ); if (is_shader_heap && required_size > max_heap_size) { return wis::detail::make_result< - wis::detail::Func(), - "Requested descriptor heap size exceeds the maximum supported by this Vulkan device">( - VK_ERROR_INITIALIZATION_FAILED - ); + wis::detail::Func(), + "Requested descriptor heap size exceeds the maximum supported by this Vulkan device">( + VK_ERROR_INITIALIZATION_FAILED + ); } if (!is_shader_heap) { @@ -344,8 +329,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( VkBuffer buffer = reinterpret_cast(std::malloc(required_size)); if (!buffer) { return wis::detail::make_result< - wis::detail::Func(), - "Failed to allocate memory for non-shader visible descriptor heap">(VK_ERROR_OUT_OF_HOST_MEMORY); + wis::detail::Func(), + "Failed to allocate memory for non-shader visible descriptor heap">(VK_ERROR_OUT_OF_HOST_MEMORY); } // Fill descriptor heap impl @@ -375,7 +360,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( }; VmaAllocationCreateInfo alloc_info{ .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT - | VMA_ALLOCATION_CREATE_MAPPED_BIT, + | VMA_ALLOCATION_CREATE_MAPPED_BIT, .usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE, .requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, .preferredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, @@ -385,18 +370,18 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateDescriptorHeap( VmaAllocation allocation = VK_NULL_HANDLE; VmaAllocationInfo alloc_info_out{}; VkResult vr = vmaCreateBufferWithAlignment( - header.allocator, - &buffer_info, - &alloc_info, - heap_alignment, - &buffer, - &allocation, - &alloc_info_out - ); + header.allocator, + &buffer_info, + &alloc_info, + heap_alignment, + &buffer, + &allocation, + &alloc_info_out + ); if (!wis::detail::succeeded(vr)) { return wis::detail:: - make_result(vr); + make_result(vr); } // Get GPU address of the buffer @@ -432,11 +417,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateViewHeap( { (void)flags; auto& device = *wis::from_handle(self); - wis::detail::VKRenderTargetView* view_heap = new (std::nothrow) wis::detail::VKRenderTargetView[capacity] {}; + wis::detail::VKRenderTargetView* view_heap = new (std::nothrow) wis::detail::VKRenderTargetView[capacity]{}; if (!view_heap) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } new (heap) wis::impl::VKViewHeapImpl{ @@ -449,11 +434,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateViewHeap( } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( - const WisVKDevice* self, - const WisRootSignatureDesc* desc, - WisVKRootSignature* layout -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDeviceCreateRootSignature(const WisVKDevice* self, const WisRootSignatureDesc* desc, WisVKRootSignature* layout) { auto& device = *wis::from_handle(self); auto& header = device.device_header->header; @@ -461,8 +443,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( if (!features.descriptor_heap) { return wis::detail::make_result< - wis::detail::Func(), - "Descriptor heaps are not supported by this Vulkan device">(VK_ERROR_FEATURE_NOT_PRESENT); + wis::detail::Func(), + "Descriptor heaps are not supported by this Vulkan device">(VK_ERROR_FEATURE_NOT_PRESENT); } // Use only 64 DWORDs, same as DX12 @@ -472,8 +454,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( const auto& push_constant = desc->push_constants[i]; if (push_constant.size_bytes % 4 != 0) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } push_constant_size += push_constant.size_bytes; } @@ -481,36 +463,35 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( // 1. Count the number of root parameters needed std::size_t total_dwords_needed = push_constant_size + desc->push_descriptor_count * 2 - + desc->descriptor_table_count; + + desc->descriptor_table_count; if (total_dwords_needed > max_root_parameters) { return wis::detail::make_result< - wis::detail::Func(), - "Root signature requires more than 64 DWORDs, which is not supported by this implementation">( - VK_ERROR_INITIALIZATION_FAILED - ); + wis::detail::Func(), + "Root signature requires more than 64 DWORDs, which is not supported by this implementation">( + VK_ERROR_INITIALIZATION_FAILED + ); } // 2. Count the number of VkDescriptorSetAndBindingMappingEXT structures // Hard part is to pack the tables into a contiguous arrays for each shader type uint32_t total_table_count = 0; - std::array table_counts_per_shader = wis::detail::GetMapCountPerShaderType( - *desc - ); + std::array table_counts_per_shader = wis::detail::GetMapCountPerShaderType(*desc + ); std::array - local_offsets_per_shader = wis::detail::GetMappingOffsetPerShaderType( - table_counts_per_shader, - total_table_count - ); + local_offsets_per_shader = wis::detail::GetMappingOffsetPerShaderType( + table_counts_per_shader, + total_table_count + ); std::size_t root_param_count = desc->push_constant_count + desc->push_descriptor_count - + desc->descriptor_table_count; + + desc->descriptor_table_count; std::size_t static_sampler_count = 0; // allocate root signature table std::size_t root_sig_size = sizeof(wis::detail::VKRootSignatureControlBlock) - + wis::aligned_size(root_param_count, 2u) * sizeof(uint32_t) - + // Root parameter binding indices, aligned to 8 bytes + + wis::aligned_size(root_param_count, 2u) * sizeof(uint32_t) + + // Root parameter binding indices, aligned to 8 bytes total_table_count * sizeof(VkDescriptorSetAndBindingMappingEXT); std::unique_ptr root_sig_control_block{ @@ -532,17 +513,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( } rootsig_header->shader_mapping_offset[i] = local_offsets_per_shader[i].offset - - (local_offsets_per_shader[i].even - ? 0 - : table_counts_per_shader[0]); // If even, "all" maps are after + - (local_offsets_per_shader[i].even ? 0 : table_counts_per_shader[0] + ); // If even, "all" maps are after // this stage, if odd, "all" maps // are before this stage - rootsig_header - ->shader_mapping_sizes[i] = table_counts_per_shader[i] - + (local_offsets_per_shader[i].even - ? 0 - : table_counts_per_shader[0]); // If even, this stage maps + "all" + rootsig_header->shader_mapping_sizes[i] = table_counts_per_shader[i] + + (local_offsets_per_shader[i].even ? 0 : table_counts_per_shader[0] + ); // If even, this stage maps + "all" // maps, if odd, only this stage maps if (!all_offset) { @@ -608,16 +586,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( uint32_t local_count = entry.count; uint32_t local_offset = heap_byte_offset; uint32_t heap_stride = entry.type == WisDescriptorTypeSampler ? features.sampler_desc_size - : features.resource_desc_size; + : features.resource_desc_size; // Check for unbounded array if (entry.count == std::numeric_limits::max()) { if (j != src.entry_count - 1) { return wis::detail::make_result< - wis::detail::Func(), - "Unbounded array descriptor table entry must be the last entry in the table">( - VK_ERROR_INITIALIZATION_FAILED - ); + wis::detail::Func(), + "Unbounded array descriptor table entry must be the last entry in the table">( + VK_ERROR_INITIALIZATION_FAILED + ); } local_count = 1; } @@ -628,23 +606,21 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateRootSignature( } heap_byte_offset = local_offset + local_count * heap_stride; - auto& mapping = mappings[local_offsets_per_shader[visibility].offset++] = { - .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_AND_BINDING_MAPPING_EXT, - .pNext = nullptr, - .descriptorSet = entry.bind_space, - .firstBinding = entry.bind_register, - .bindingCount = local_count, - .resourceMask = wis::detail::GetResourceTypeFlags(entry.type), - .source = VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_PUSH_INDEX_EXT, - .sourceData = { - .pushIndex = { - .heapOffset = local_offset, - .pushOffset = push_address_offset, - .heapIndexStride = 1, - .heapArrayStride = heap_stride, - } - } - }; + auto& mapping = mappings[local_offsets_per_shader[visibility].offset++] = + {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_AND_BINDING_MAPPING_EXT, + .pNext = nullptr, + .descriptorSet = entry.bind_space, + .firstBinding = entry.bind_register, + .bindingCount = local_count, + .resourceMask = wis::detail::GetResourceTypeFlags(entry.type), + .source = VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_PUSH_INDEX_EXT, + .sourceData = + {.pushIndex = { + .heapOffset = local_offset, + .pushOffset = push_address_offset, + .heapIndexStride = 1, + .heapArrayStride = heap_stride, + }}}; } root_param_offsets[root_param_index++] = push_address_offset; @@ -698,15 +674,14 @@ WIS_EXTERN_C WISDOM_API void wisVKDeviceQueryProperties(const WisVKDevice* self, auto& family_index = header.queue_residency[i]; bool supported = family_index != wis::detail::VKQueueFamilyProperties::invalid_family_index; WisCommandQueuePriority priority = WisCommandQueuePriority( - supported ? (header.queue_families[family_index].queue_priority) : 0 - ); + supported ? (header.queue_families[family_index].queue_priority) : 0 + ); props->supported_queues[i] = supported; props->max_queue_priority[i] = priority; } props->relaxed_queue_transition = header.features.maintenance9; - } - break; + } break; case WisQueryPropertyTypeDeviceDescriptorHeapProperties: { auto* props = static_cast(next); if (!header.features.descriptor_heap) { @@ -714,21 +689,20 @@ WIS_EXTERN_C WISDOM_API void wisVKDeviceQueryProperties(const WisVKDevice* self, } auto real_dheap_size = header.features.max_descriptor_heap_size - - header.features.descriptor_heap_reserved_size; + - header.features.descriptor_heap_reserved_size; auto real_sheap_size = header.features.max_sampler_heap_size - header.features.sampler_heap_reserved_size; auto real_sheap_size_with_embedded = header.features.max_sampler_heap_size - - header.features.sampler_heap_reserved_size_with_embedded; + - header.features.sampler_heap_reserved_size_with_embedded; props->max_descriptor_heap_size = real_dheap_size / header.features.resource_desc_size; props->max_sampler_heap_size = real_sheap_size / header.features.sampler_desc_size; props->max_sampler_heap_size_with_embedded = real_sheap_size_with_embedded - / header.features.sampler_desc_size; + / header.features.sampler_desc_size; props->descriptor_increment_size = header.features.resource_desc_size; props->sampler_increment_size = header.features.sampler_desc_size; props->render_target_increment_size = sizeof(wis::detail::VKRenderTargetView); props->depth_stencil_increment_size = sizeof(wis::detail::VKRenderTargetView); - } - break; + } break; case WisQueryPropertyTypeDeviceMemoryProperties: { auto* props = static_cast(next); props->host_image_copy_supported = header.features.host_image_copy; @@ -759,22 +733,20 @@ WIS_EXTERN_C WISDOM_API void wisVKDeviceQueryProperties(const WisVKDevice* self, const VkMemoryPropertyFlags flags = mem_props->memoryTypes[i].propertyFlags; if ((flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) && (flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) - && (flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) { + && (flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) { props->gpu_upload_supported = true; break; } } - } - break; + } break; case WisQueryPropertyTypeDeviceBindingProperties: { auto* props = static_cast(next); props->max_vertex_input_bindings = header.features.max_vertex_bindings; props->max_vertex_input_attributes = header.features.max_vertex_attributes; props->multiple_viewports_supported = header.features.multiple_viewports; props->address_commands_supported = header.features.address_commands; - } - break; + } break; default: break; } @@ -818,8 +790,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreatePipelineCache( { if (data_size > 0 && data_size < sizeof(VkPipelineCacheHeaderVersionOne)) { return wis::detail::make_result< - wis::detail::Func(), - "Data size is too small to contain a valid pipeline cache header">(VK_ERROR_INITIALIZATION_FAILED); + wis::detail::Func(), + "Data size is too small to contain a valid pipeline cache header">(VK_ERROR_INITIALIZATION_FAILED); } auto& device = *wis::from_handle(self); @@ -846,9 +818,9 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreatePipelineCache( if (std::memcmp(initial_data, &cache_header_correct, sizeof(VkPipelineCacheHeaderVersionOne)) != 0) { return wis::detail::make_result< - wis::detail::Func(), - "Initial data pipeline cache header does not match the device's pipeline cache header, indicating it " - "is incompatible">(VK_ERROR_INITIALIZATION_FAILED); + wis::detail::Func(), + "Initial data pipeline cache header does not match the device's pipeline cache header, indicating it " + "is incompatible">(VK_ERROR_INITIALIZATION_FAILED); } } @@ -867,19 +839,15 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreatePipelineCache( } auto& cache_impl = *new (cache) - wis::impl::VKPipelineCacheImpl{.cache = cache_handle, .device_header = device.device_header}; + wis::impl::VKPipelineCacheImpl{.cache = cache_handle, .device_header = device.device_header}; device.device_header->AddRef(); return wis::detail::vk_success; } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateShader( - const WisVKDevice* self, - const uint8_t* data, - size_t size, - WisVKShader* shader -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDeviceCreateShader(const WisVKDevice* self, const uint8_t* data, size_t size, WisVKShader* shader) { auto& device = *wis::from_handle(self); auto& table = device.device_header->header.device_table; @@ -898,19 +866,15 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateShader( return wis::detail::make_result(vr); } - auto& shader_impl = *new ( - shader - ) wis::impl::VKShaderImpl{.shader_module = shader_handle, .device_header = device.device_header}; + auto& shader_impl = *new (shader + ) wis::impl::VKShaderImpl{.shader_module = shader_handle, .device_header = device.device_header}; device.device_header->AddRef(); return wis::detail::vk_success; } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateComputePipeline( - const WisVKDevice* self, - const WisVKComputePipelineDesc* desc, - WisVKPipeline* pipeline -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDeviceCreateComputePipeline(const WisVKDevice* self, const WisVKComputePipelineDesc* desc, WisVKPipeline* pipeline) { auto& device = *wis::from_handle(self); auto& table = device.device_header->header.device_table; @@ -940,14 +904,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateComputePipeline( .pNext = &pipeline_flags_info, .flags = 0, .stage = - { .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, - .pNext = &mapping, - .flags = 0, - .stage = VK_SHADER_STAGE_COMPUTE_BIT, - .module = shader, - .pName = "main", - .pSpecializationInfo = nullptr - }, + {.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, + .pNext = &mapping, + .flags = 0, + .stage = VK_SHADER_STAGE_COMPUTE_BIT, + .module = shader, + .pName = "main", + .pSpecializationInfo = nullptr}, .layout = nullptr }; @@ -958,9 +921,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateComputePipeline( return wis::detail::make_result(vr); } - auto& pipeline_impl = *new ( - pipeline - ) wis::impl::VKPipelineImpl{.pipeline = pipeline_handle, .device_header = device.device_header}; + auto& pipeline_impl = *new (pipeline + ) wis::impl::VKPipelineImpl{.pipeline = pipeline_handle, .device_header = device.device_header}; pipeline_impl.device_header->AddRef(); return wis::detail::vk_success; } @@ -979,8 +941,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( if (!rsig) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } //--Shader stages @@ -1002,7 +964,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( }; VkShaderDescriptorSetAndBindingMappingInfoEXT mappings[max_shader_stages]; VkPipelineShaderStageCreateInfo - shader_stages[max_shader_stages]; // intentionally uninitialized, will be filled based on provided shaders + shader_stages[max_shader_stages]; // intentionally uninitialized, will be filled based on provided shaders for (uint32_t i = 0; i < max_shader_stages; i++) { auto smodule = shader_modules[i]; @@ -1053,12 +1015,12 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( uint32_t ia_count = desc->input_layout.attribute_count; if (desc->input_layout.attribute_count > wis::MinSupportedInputAttributes * 2) { dynamic_vertex_attributes = wis::make_unique( - desc->input_layout.attribute_count - ); + desc->input_layout.attribute_count + ); if (!dynamic_vertex_attributes) { return wis::detail::make_result< - wis::detail::Func(), - "Failed to allocate memory for vertex input attribute descriptions">(VK_ERROR_OUT_OF_HOST_MEMORY); + wis::detail::Func(), + "Failed to allocate memory for vertex input attribute descriptions">(VK_ERROR_OUT_OF_HOST_MEMORY); } ia_span = {dynamic_vertex_attributes.get(), ia_count}; @@ -1082,11 +1044,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( .flags = 0, .vertexBindingDescriptionCount = static_cast(desc->input_layout.binding_count), .pVertexBindingDescriptions = desc->input_layout.binding_count - ? reinterpret_cast( - desc->input_layout.bindings - ) // strict aliasing violation, but we control the data and it's guaranteed - // to be compatible - : nullptr, + ? reinterpret_cast( + desc->input_layout.bindings + ) // strict aliasing violation, but we control the data and it's guaranteed + // to be compatible + : nullptr, .vertexAttributeDescriptionCount = static_cast(desc->input_layout.attribute_count), .pVertexAttributeDescriptions = desc->input_layout.attribute_count ? ia_span.data() : nullptr, }; @@ -1178,8 +1140,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( uint32_t rt_count = desc->render_attachments.attachments_count; if (rt_count > wis::MaxRenderTargets) { return wis::detail::make_result< - wis::detail::Func(), - "Exceeded maximum number of render target attachments (8)">(VK_ERROR_UNKNOWN); + wis::detail::Func(), + "Exceeded maximum number of render target attachments (8)">(VK_ERROR_UNKNOWN); } VkFormat rt_formats[wis::MaxRenderTargets]; for (uint32_t i = 0; i < rt_count; i++) { @@ -1247,25 +1209,25 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( .depthBoundsTestEnable = ds.depth_bound_test, .stencilTestEnable = ds.stencil_enable, .front = - VkStencilOpState{ - .failOp = wis::detail::VKConvert(ds.stencil_front.fail_op), - .passOp = wis::detail::VKConvert(ds.stencil_front.pass_op), - .depthFailOp = wis::detail::VKConvert(ds.stencil_front.depth_fail_op), - .compareOp = wis::detail::VKConvert(ds.stencil_front.stencil_comp), - .compareMask = ds.stencil_front.read_mask, - .writeMask = ds.stencil_front.write_mask, - .reference = 0, - }, + VkStencilOpState{ + .failOp = wis::detail::VKConvert(ds.stencil_front.fail_op), + .passOp = wis::detail::VKConvert(ds.stencil_front.pass_op), + .depthFailOp = wis::detail::VKConvert(ds.stencil_front.depth_fail_op), + .compareOp = wis::detail::VKConvert(ds.stencil_front.stencil_comp), + .compareMask = ds.stencil_front.read_mask, + .writeMask = ds.stencil_front.write_mask, + .reference = 0, + }, .back = - VkStencilOpState{ - .failOp = wis::detail::VKConvert(ds.stencil_back.fail_op), - .passOp = wis::detail::VKConvert(ds.stencil_back.pass_op), - .depthFailOp = wis::detail::VKConvert(ds.stencil_back.depth_fail_op), - .compareOp = wis::detail::VKConvert(ds.stencil_back.stencil_comp), - .compareMask = ds.stencil_back.read_mask, - .writeMask = ds.stencil_back.write_mask, - .reference = 0, - }, + VkStencilOpState{ + .failOp = wis::detail::VKConvert(ds.stencil_back.fail_op), + .passOp = wis::detail::VKConvert(ds.stencil_back.pass_op), + .depthFailOp = wis::detail::VKConvert(ds.stencil_back.depth_fail_op), + .compareOp = wis::detail::VKConvert(ds.stencil_back.stencil_comp), + .compareMask = ds.stencil_back.read_mask, + .writeMask = ds.stencil_back.write_mask, + .reference = 0, + }, .minDepthBounds = 0.0f, .maxDepthBounds = 1.0f, }; @@ -1281,7 +1243,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( .dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO, .alphaBlendOp = VK_BLEND_OP_ADD, .colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT - | VK_COLOR_COMPONENT_A_BIT, + | VK_COLOR_COMPONENT_A_BIT, }; VkPipelineColorBlendAttachmentState color_blend_attachment[wis::MaxRenderTargets]; VkPipelineColorBlendStateCreateInfo color_blending; @@ -1404,32 +1366,28 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateGraphicsPipeline( VkPipeline pipeline_handle = VK_NULL_HANDLE; auto vr = table.vkCreateGraphicsPipelines( - device.device, - std::bit_cast(desc->cache), - 1u, - &info, - nullptr, - &pipeline_handle - ); + device.device, + std::bit_cast(desc->cache), + 1u, + &info, + nullptr, + &pipeline_handle + ); if (!wis::detail::succeeded(vr)) { return wis::detail::make_result(vr); } - auto& pipeline_impl = *new ( - pipeline - ) wis::impl::VKPipelineImpl{.pipeline = pipeline_handle, .device_header = device.device_header}; + auto& pipeline_impl = *new (pipeline + ) wis::impl::VKPipelineImpl{.pipeline = pipeline_handle, .device_header = device.device_header}; device.device_header->AddRef(); return wis::detail::vk_success; } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetSurfaceParameters( - const WisVKDevice* self, - WisVKSurfaceView surface, - WisSurfaceParameters* params -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDeviceGetSurfaceParameters(const WisVKDevice* self, WisVKSurfaceView surface, WisSurfaceParameters* params) { auto& device = wis::from_handle_ref(self); auto atable = device.device_header->header.shared_header->header.adapter_table; @@ -1458,8 +1416,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetSurfaceParameters( *params = { .min_swapchain_images = capabilities.surfaceCapabilities.minImageCount, .max_swapchain_images = capabilities.surfaceCapabilities.maxImageCount == 0 - ? wis::AbsoluteMaxSwapchainImages - : capabilities.surfaceCapabilities.maxImageCount, + ? wis::AbsoluteMaxSwapchainImages + : capabilities.surfaceCapabilities.maxImageCount, .alpha_modes_supported = alpha, .texture_usage_flags_supported = wis::detail::VKConvert(capabilities.surfaceCapabilities.supportedUsageFlags), .stereo_supported = capabilities.surfaceCapabilities.maxImageArrayLayers > 1, @@ -1501,11 +1459,11 @@ WIS_EXTERN_C WISDOM_API bool wisVKDeviceGetFormatPresentationSupport( } vr = atable.vkGetPhysicalDeviceSurfaceFormatsKHR( - device.physical_device, - vk_surface, - &format_count, - format_span.data() - ); + device.physical_device, + vk_surface, + &format_count, + format_span.data() + ); if (!wis::detail::succeeded(vr)) { return false; } @@ -1542,15 +1500,15 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( uint32_t format_count = 0; auto vr = atable.vkGetPhysicalDeviceSurfaceFormatsKHR( - device.physical_device, - surface_impl.surface, - &format_count, - nullptr - ); + device.physical_device, + surface_impl.surface, + &format_count, + nullptr + ); if (!wis::detail::succeeded(vr) || format_count == 0) { return wis::detail::make_result< - wis::detail::Func(), - "Failed to get surface formats or no formats supported by the surface">(VK_ERROR_INITIALIZATION_FAILED); + wis::detail::Func(), + "Failed to get surface formats or no formats supported by the surface">(VK_ERROR_INITIALIZATION_FAILED); } if (format_count > reasonable_format_count) { @@ -1565,11 +1523,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( } vr = atable.vkGetPhysicalDeviceSurfaceFormatsKHR( - device.physical_device, - surface_impl.surface, - &format_count, - format_span.data() - ); + device.physical_device, + surface_impl.surface, + &format_count, + format_span.data() + ); if (!wis::detail::succeeded(vr)) { return wis::detail::make_result(vr); } @@ -1581,10 +1539,9 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( if (format_it == format_span.end()) { return wis::detail::make_result< - wis::detail::Func(), - "The requested format is not supported for presentation on the given surface">( - VK_ERROR_FORMAT_NOT_SUPPORTED - ); + wis::detail::Func(), + "The requested format is not supported for presentation on the given surface">(VK_ERROR_FORMAT_NOT_SUPPORTED + ); } // Query surface props @@ -1602,19 +1559,19 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( // validate requested parameters against capabilities if (desc->image_count < capabilities.surfaceCapabilities.minImageCount - || (capabilities.surfaceCapabilities.maxImageCount != 0 - && desc->image_count > capabilities.surfaceCapabilities.maxImageCount)) { + || (capabilities.surfaceCapabilities.maxImageCount != 0 + && desc->image_count > capabilities.surfaceCapabilities.maxImageCount)) { return wis::detail::make_result< - wis::detail::Func(), - "Requested swapchain image count is out of bounds for the given surface">(VK_ERROR_INITIALIZATION_FAILED); + wis::detail::Func(), + "Requested swapchain image count is out of bounds for the given surface">(VK_ERROR_INITIALIZATION_FAILED); } if (desc->flags & WisSwapchainFlagsStereo) { if (capabilities.surfaceCapabilities.maxImageArrayLayers == 1) { return wis::detail::make_result< - wis::detail::Func(), - "Stereo swapchain requested but the surface does not support image array layers">( - VK_ERROR_INITIALIZATION_FAILED - ); + wis::detail::Func(), + "Stereo swapchain requested but the surface does not support image array layers">( + VK_ERROR_INITIALIZATION_FAILED + ); } array_layer_count++; } @@ -1645,9 +1602,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( } else if ((tearing = std::ranges::count(modes, VK_PRESENT_MODE_FIFO_RELAXED_KHR) > 0)) { present_mode = VK_PRESENT_MODE_FIFO_RELAXED_KHR; } - } else if ( - std::ranges::count(modes, VK_PRESENT_MODE_MAILBOX_KHR) > 0 && !(desc->flags & WisSwapchainFlagsStereo) - ) { + } else if (std::ranges::count(modes, VK_PRESENT_MODE_MAILBOX_KHR) > 0 + && !(desc->flags & WisSwapchainFlagsStereo)) { present_mode = VK_PRESENT_MODE_MAILBOX_KHR; } } @@ -1655,14 +1611,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( // Create swapchain control block in a single allocation with the header to ensure they are close together in // memory, which is important for cache performance since the header is accessed on every frame. std::size_t header_size = sizeof(wis::detail::VKSwapchainControlBlock) + desc->image_count * sizeof(VkSemaphore) * 2 - + // semaphores for present and render complete for each image + + // semaphores for present and render complete for each image format_count - * sizeof(VkSurfaceFormatKHR); // store supported formats for use in mode switching + * sizeof(VkSurfaceFormatKHR); // store supported formats for use in mode switching std::unique_ptr header_storage{new (std::nothrow) std::byte[header_size]}; if (!header_storage) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } wis::detail::VKSwapchainControlBlock* header = new (header_storage.get()) wis::detail::VKSwapchainControlBlock; @@ -1677,8 +1633,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( // Copy the supported formats for use in mode switching auto* format_storage = reinterpret_cast( - reinterpret_cast(header + 1) + desc->image_count * 2 - ); // format storage is immediately after the semaphores + reinterpret_cast(header + 1) + desc->image_count * 2 + ); // format storage is immediately after the semaphores for (uint32_t i = 0; i < format_count; i++) { format_storage[i] = format_span[i]; } @@ -1705,18 +1661,18 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( .imageFormat = vk_format, .imageColorSpace = format_it->colorSpace, .imageExtent = - { - .width = std::clamp( - desc->width, - capabilities.surfaceCapabilities.minImageExtent.width, - capabilities.surfaceCapabilities.maxImageExtent.width - ), - .height = std::clamp( - desc->height, - capabilities.surfaceCapabilities.minImageExtent.height, - capabilities.surfaceCapabilities.maxImageExtent.height - ), - }, + { + .width = std::clamp( + desc->width, + capabilities.surfaceCapabilities.minImageExtent.width, + capabilities.surfaceCapabilities.maxImageExtent.width + ), + .height = std::clamp( + desc->height, + capabilities.surfaceCapabilities.minImageExtent.height, + capabilities.surfaceCapabilities.maxImageExtent.height + ), + }, .imageArrayLayers = array_layer_count, .imageUsage = wis::detail::VKConvert(desc->texture_usage_flags), .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE, @@ -1756,7 +1712,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( } stable.vkDestroySwapchainKHR(device.device, swapchain_handle, nullptr); return wis::detail:: - make_result(vr); + make_result(vr); } } @@ -1774,7 +1730,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( } stable.vkDestroySwapchainKHR(device.device, swapchain_handle, nullptr); return wis::detail:: - make_result(vr); + make_result(vr); } swap_head.surface_header = surface_impl.surface_header; @@ -1800,13 +1756,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( // Acquire the next image index for the new swapchain to update internal state auto result = impl.swapchain_table->vkAcquireNextImageKHR( - impl.device, - impl.swapchain, - impl.lazy_acquire ? 0 : std::numeric_limits::max(), - semaphores[impl.acquire_index], - nullptr, - &impl.present_index - ); + impl.device, + impl.swapchain, + impl.lazy_acquire ? 0 : std::numeric_limits::max(), + semaphores[impl.acquire_index], + nullptr, + &impl.present_index + ); if (result != VK_SUCCESS) { return result; // Caller can choose to handle timeout differently (e.g. by skipping rendering and trying @@ -1831,8 +1787,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( }; impl.acquire_index = (impl.acquire_index + 1) % swapchain_header.create_info.minImageCount; return swapchain_table.vkQueueSubmit2(impl.present_queue, 1, &desc2, nullptr); - } - (swap_impl); + }(swap_impl); if (!wis::detail::succeeded(vr)) { for (uint32_t j = 0; j < desc->image_count * 2; j++) { @@ -1847,18 +1802,15 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceCreateSwapchain( ); // ensure the destructor doesn't attempt to clean up a partially initialized swapchain return wis::detail:: - make_result(vr); + make_result(vr); } return wis::detail::vk_success; } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetFormatProperties( - const WisVKDevice* self, - WisDataFormat format, - WisFormatProperties* properties -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKDeviceGetFormatProperties(const WisVKDevice* self, WisDataFormat format, WisFormatProperties* properties) { auto& device = wis::from_handle_ref(self); auto atable = device.device_header->header.shared_header->header.adapter_table; @@ -1880,8 +1832,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetFormatProperties( if (features & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) { support_flags |= WisFormatSupportFlagsShaderResource | WisFormatSupportFlagsTexture1D - | WisFormatSupportFlagsTexture2D | WisFormatSupportFlagsTexture3D - | WisFormatSupportFlagsTextureCube; + | WisFormatSupportFlagsTexture2D | WisFormatSupportFlagsTexture3D + | WisFormatSupportFlagsTextureCube; } if (features & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) { support_flags |= WisFormatSupportFlagsRenderTarget; @@ -1900,42 +1852,42 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetFormatProperties( if (features & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) { VkImageFormatProperties image_props{}; if (wis::detail::succeeded(atable.vkGetPhysicalDeviceImageFormatProperties( - device.physical_device, - vk_format, - VK_IMAGE_TYPE_2D, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_SAMPLED_BIT, - 0, - &image_props - ))) { + device.physical_device, + vk_format, + VK_IMAGE_TYPE_2D, + VK_IMAGE_TILING_OPTIMAL, + VK_IMAGE_USAGE_SAMPLED_BIT, + 0, + &image_props + ))) { sample_counts |= image_props.sampleCounts; } } if (features & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) { VkImageFormatProperties image_props{}; if (wis::detail::succeeded(atable.vkGetPhysicalDeviceImageFormatProperties( - device.physical_device, - vk_format, - VK_IMAGE_TYPE_2D, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, - 0, - &image_props - ))) { + device.physical_device, + vk_format, + VK_IMAGE_TYPE_2D, + VK_IMAGE_TILING_OPTIMAL, + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, + 0, + &image_props + ))) { sample_counts |= image_props.sampleCounts; } } if (features & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { VkImageFormatProperties image_props{}; if (wis::detail::succeeded(atable.vkGetPhysicalDeviceImageFormatProperties( - device.physical_device, - vk_format, - VK_IMAGE_TYPE_2D, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, - 0, - &image_props - ))) { + device.physical_device, + vk_format, + VK_IMAGE_TYPE_2D, + VK_IMAGE_TILING_OPTIMAL, + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, + 0, + &image_props + ))) { sample_counts |= image_props.sampleCounts; } } @@ -1953,7 +1905,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKDeviceGetFormatProperties( if (max_sample_count > WisSampleCountS1) { if (features & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT - || features & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { + || features & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { support_flags |= WisFormatSupportFlagsMultisampleRenderTarget; } support_flags |= WisFormatSupportFlagsMultisampleResolve; diff --git a/src/include/wisdom/vulkan/vk_extensions.cpp b/src/include/wisdom/vulkan/vk_extensions.cpp index ef1e81310..240f1bb3f 100644 --- a/src/include/wisdom/vulkan/vk_extensions.cpp +++ b/src/include/wisdom/vulkan/vk_extensions.cpp @@ -16,14 +16,14 @@ GetInstanceExtensions(WisResult& result, const wis::impl::VKMainGlobal& table) n VkResult vr = table.vkEnumerateInstanceExtensionProperties(nullptr, &ext_count, nullptr); if (!wis::detail::succeeded(vr)) { result = wis::detail:: - make_result(vr); + make_result(vr); return exts; } std::unique_ptr ext_props_raw = make_unique(ext_count); if (!ext_props_raw) { result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return exts; } vr = table.vkEnumerateInstanceExtensionProperties(nullptr, &ext_count, ext_props_raw.get()); @@ -33,8 +33,8 @@ GetInstanceExtensions(WisResult& result, const wis::impl::VKMainGlobal& table) n exts.reserve(ext_count); } catch (const std::bad_alloc&) { result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return exts; } for (const auto& i : wis::span{ext_props_raw.get(), ext_count}) { @@ -58,15 +58,15 @@ inline std::unordered_set( - vr - ); + vr + ); return layers; } std::unique_ptr layer_props_raw = make_unique(layer_count); if (!layer_props_raw) { result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return layers; } vr = table.vkEnumerateInstanceLayerProperties(&layer_count, layer_props_raw.get()); @@ -75,8 +75,8 @@ inline std::unordered_set( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return layers; } for (const auto& i : wis::span{layer_props_raw.get(), layer_count}) { @@ -99,14 +99,14 @@ GetDeviceExtensions( VkResult vr = adapter_table.vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &ext_count, nullptr); if (!wis::detail::succeeded(vr)) { result = wis::detail:: - make_result(vr); + make_result(vr); return exts; } std::unique_ptr ext_props_raw = make_unique(ext_count); if (!ext_props_raw) { result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return exts; } vr = adapter_table.vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &ext_count, ext_props_raw.get()); @@ -115,8 +115,8 @@ GetDeviceExtensions( exts.reserve(ext_count); } catch (const std::bad_alloc&) { result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return exts; } for (const auto& i : wis::span{ext_props_raw.get(), ext_count}) { @@ -142,8 +142,8 @@ wis::VKInstanceExtensionCollector::VKInstanceExtensionCollector( enabled_layer_names_set.reserve(wis::detail::size(available_layers_set)); } catch (const std::bad_alloc&) { out_result = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return; } for (const auto& ext : instance_extensions) { @@ -163,8 +163,8 @@ wis::VKInstanceExtensionCollector::ExtReturn wis::VKInstanceExtensionCollector:: auto names_array = make_unique(ext_count + layer_count); if (!names_array) { out_res = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return result; } std::size_t index = 0; @@ -213,8 +213,8 @@ wis::VKDeviceExtensionCollector::VKDeviceExtensionCollector( enabled_extension_names_set.reserve(wis::detail::size(available_extensions_set)); } catch (const std::bad_alloc&) { res = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return; } res = wis::detail::vk_success; @@ -246,8 +246,7 @@ const VkExtensionProperties* wis::VKDeviceExtensionCollector::GetExtensionProper return nullptr; } -wis::VKDeviceExtensionCollector::InitBuffer wis::VKDeviceExtensionCollector::GetInitBuffer( - WisResult& out_res +wis::VKDeviceExtensionCollector::InitBuffer wis::VKDeviceExtensionCollector::GetInitBuffer(WisResult& out_res ) const noexcept { InitBuffer result; @@ -275,8 +274,8 @@ wis::VKDeviceExtensionCollector::InitBuffer wis::VKDeviceExtensionCollector::Get std::unique_ptr buffer(new (std::nothrow) std::uint64_t[total_size / sizeof(std::uint64_t)]); if (!buffer) { out_res = wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); return result; } diff --git a/src/include/wisdom/vulkan/vk_extensions.hpp b/src/include/wisdom/vulkan/vk_extensions.hpp index f2a70839d..563d29c2e 100644 --- a/src/include/wisdom/vulkan/vk_extensions.hpp +++ b/src/include/wisdom/vulkan/vk_extensions.hpp @@ -39,31 +39,21 @@ struct CStringHash { // hash for VkExtensionProperties struct VkExtensionPropertiesHash { using is_transparent = void; - std::size_t operator()(const VkExtensionProperties& ext) const noexcept { - return CStringHash{}(ext.extensionName); - } - std::size_t operator()(const char* name) const noexcept { - return CStringHash{}(name); - } + std::size_t operator()(const VkExtensionProperties& ext) const noexcept { return CStringHash{}(ext.extensionName); } + std::size_t operator()(const char* name) const noexcept { return CStringHash{}(name); } }; //---------------------------------------------------------------------------------------------------------------------- struct VkLayerPropertiesHash { using is_transparent = void; - std::size_t operator()(const VkLayerProperties& layer) const noexcept { - return CStringHash{}(layer.layerName); - } - std::size_t operator()(const char* name) const noexcept { - return CStringHash{}(name); - } + std::size_t operator()(const VkLayerProperties& layer) const noexcept { return CStringHash{}(layer.layerName); } + std::size_t operator()(const char* name) const noexcept { return CStringHash{}(name); } }; // Equality helpers //---------------------------------------------------------------------------------------------------------------------- struct CStringEqual { - bool operator()(const char* a, const char* b) const { - return std::strncmp(a, b, VK_MAX_EXTENSION_NAME_SIZE) == 0; - } + bool operator()(const char* a, const char* b) const { return std::strncmp(a, b, VK_MAX_EXTENSION_NAME_SIZE) == 0; } }; //---------------------------------------------------------------------------------------------------------------------- @@ -102,13 +92,13 @@ struct VkLayerPropertiesEqual { using CStringSet = std::unordered_set; using VkExtensionPropertiesSet = std:: - unordered_set; + unordered_set; using VkLayerPropertiesSet = std::unordered_set; } // namespace detail //---------------------------------------------------------------------------------------------------------------------- struct WISDOM_API VKInstanceExtensionCollector { - constexpr static const char* instance_extensions[] { + constexpr static const char* instance_extensions[]{ VK_KHR_SURFACE_EXTENSION_NAME, VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME, VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, @@ -236,9 +226,7 @@ struct WISDOM_API VKDeviceExtensionCollector { template struct VKInstanceExtensionImpl : public VKInstanceExtensionHeader { VKInstanceExtensionImpl() noexcept - : VKInstanceExtensionHeader { - &VKInstanceExtensionImpl::InitThunk - } + : VKInstanceExtensionHeader{&VKInstanceExtensionImpl::InitThunk} { assert( std::uintptr_t(static_cast(this)) == std::uintptr_t(static_cast(this)) @@ -257,9 +245,9 @@ struct VKInstanceExtensionImpl : public VKInstanceExtensionHeader { return reinterpret_cast(self)->CollectInfo(*collector); } return reinterpret_cast(self)->Init( - const_cast(*instance_impl), - const_cast(*collector) - ); + const_cast(*instance_impl), + const_cast(*collector) + ); } public: @@ -279,9 +267,7 @@ struct VKInstanceExtensionImpl : public VKInstanceExtensionHeader { template struct VKDeviceExtensionImpl : public VKDeviceExtensionHeader { VKDeviceExtensionImpl() noexcept - : VKDeviceExtensionHeader { - &VKDeviceExtensionImpl::InitThunk - } + : VKDeviceExtensionHeader{&VKDeviceExtensionImpl::InitThunk} { assert( std::uintptr_t(static_cast(this)) == std::uintptr_t(static_cast(this)) @@ -300,9 +286,9 @@ struct VKDeviceExtensionImpl : public VKDeviceExtensionHeader { return reinterpret_cast(self)->CollectInfo(*collector); } return reinterpret_cast(self)->Init( - const_cast(*device_impl), - const_cast(*collector) - ); + const_cast(*device_impl), + const_cast(*collector) + ); } public: diff --git a/src/include/wisdom/vulkan/vk_impl.cpp b/src/include/wisdom/vulkan/vk_impl.cpp index 9ed1118d0..84bd85b66 100644 --- a/src/include/wisdom/vulkan/vk_impl.cpp +++ b/src/include/wisdom/vulkan/vk_impl.cpp @@ -76,11 +76,8 @@ WIS_EXTERN_C WISDOM_API void wisVKDestroyTexture(WisVKTexture* self) } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKTextureWriteSubresource( - const WisVKTexture* self, - const void* source_data, - const WisTextureRegion* target_region -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKTextureWriteSubresource(const WisVKTexture* self, const void* source_data, const WisTextureRegion* target_region) { auto& impl = wis::from_handle_ref(self); auto& header = impl.device_header->header; @@ -106,16 +103,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKTextureWriteSubresource( .memoryRowLength = 0, .memoryImageHeight = 0, .imageSubresource = - { .aspectMask = plane_to_aspect_mask(target_region->target_subresource.plane_slice), - .mipLevel = target_region->target_subresource.mip_level, - .baseArrayLayer = target_region->target_subresource.array_layer, - .layerCount = 1 - }, + {.aspectMask = plane_to_aspect_mask(target_region->target_subresource.plane_slice), + .mipLevel = target_region->target_subresource.mip_level, + .baseArrayLayer = target_region->target_subresource.array_layer, + .layerCount = 1}, .imageOffset = - { static_cast(target_region->box.x), - static_cast(target_region->box.y), - static_cast(target_region->box.z) - }, + {static_cast(target_region->box.x), + static_cast(target_region->box.y), + static_cast(target_region->box.z)}, .imageExtent{target_region->box.width, target_region->box.height, target_region->box.depth}, }; diff --git a/src/include/wisdom/vulkan/vk_instance.cpp b/src/include/wisdom/vulkan/vk_instance.cpp index 37bcfb27a..0d5ffc356 100644 --- a/src/include/wisdom/vulkan/vk_instance.cpp +++ b/src/include/wisdom/vulkan/vk_instance.cpp @@ -66,8 +66,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCreateInstance( auto header = wis::make_unique(); if (!header) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } header->header.library = wis::detail::unique_library{wis::detail::InitializeVulkanLibrary()}; @@ -77,8 +77,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCreateInstance( if (!header->header.global_table.Init(header->header.library.get())) { return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } const auto& gt = header->header.global_table; @@ -152,11 +152,11 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCreateInstance( .pNext = nullptr, .flags = 0, .messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, + | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT + | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT + | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, .messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, + | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, .pfnUserCallback = wis::detail::VKDebugCallbackThunk::DebugUtilsMessengerCallbackThunk, .pUserData = debug_layer_thunk.get(), }; @@ -182,26 +182,26 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCreateInstance( if (!instance_table.Init(instance_handle, gt.vkGetInstanceProcAddr)) { instance_table.vkDestroyInstance(instance_handle, nullptr); // cleanup return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } // Initialize adapter table if (!header->header.adapter_table.Init(instance_handle, gt.vkGetInstanceProcAddr)) { instance_table.vkDestroyInstance(instance_handle, nullptr); // cleanup return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } // Setup debug messenger if requested if (debug_layer_thunk && instance_table.vkCreateDebugUtilsMessengerEXT) { auto vr2 = instance_table.vkCreateDebugUtilsMessengerEXT( - instance_handle, - &debug_create_info, - nullptr, - &header->header.debug_messenger - ); + instance_handle, + &debug_create_info, + nullptr, + &header->header.debug_messenger + ); // Non-fatal, allow to silently fail (void)vr2; } @@ -218,7 +218,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKCreateInstance( }; // Initialize instance extensions - for (auto* ext : wis::span {extensions, extension_count}) { + for (auto* ext : wis::span{extensions, extension_count}) { if (auto* table = wis::from_handle(ext); table && table->init_fptr) { if (auto xres = table->init_fptr(table, &impl, &collector); xres.status != WisStatusOk) { res.status = WisStatusPartial; // mark as partial success if any extension fails @@ -244,11 +244,8 @@ WIS_EXTERN_C WISDOM_API void wisVKDestroyInstance(WisVKInstance* self) } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKInstanceQueryAdapters( - const WisVKInstance* self, - WisAdapterPreference preference, - WisVKAdapterQuery* query -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKInstanceQueryAdapters(const WisVKInstance* self, WisAdapterPreference preference, WisVKAdapterQuery* query) { // Query can come as partially constructed from C side auto& instance_impl = wis::from_handle_ref(self); @@ -269,16 +266,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKInstanceQueryAdapters( } if (device_count == 0) { return wis::detail::make_result( - VK_ERROR_INITIALIZATION_FAILED - ); + VK_ERROR_INITIALIZATION_FAILED + ); } // Get physical devices devices_ref = wis::make_unique(device_count); if (!devices_ref) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } vr = table.vkEnumeratePhysicalDevices(instance_impl.instance, &device_count, devices_ref.get()); @@ -300,13 +297,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKInstanceQueryAdapters( // Sort devices based on preference constexpr static std::size_t max_align = std::max(alignof(VkPhysicalDeviceProperties), alignof(std::uintptr_t)); std::size_t total_aux_size = sizeof(VkPhysicalDeviceProperties) * device_count - + device_count * sizeof(std::uintptr_t); + + device_count * sizeof(std::uintptr_t); aux_pool = wis::make_unique(total_aux_size + max_align - 1); if (!aux_pool) { return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } // Aligned pointers @@ -351,14 +348,10 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKInstanceQueryAdapters( // Sort indices based on preference switch (preference) { case WisAdapterPreference::WisAdapterPreferenceMinConsumption: - std::ranges::sort(index_span, [&](std::uintptr_t a, std::uintptr_t b) { - return less_consumption(a, b); - }); + std::ranges::sort(index_span, [&](std::uintptr_t a, std::uintptr_t b) { return less_consumption(a, b); }); break; case WisAdapterPreference::WisAdapterPreferencePerformance: - std::ranges::sort(index_span, [&](std::uintptr_t a, std::uintptr_t b) { - return less_performance(a, b); - }); + std::ranges::sort(index_span, [&](std::uintptr_t a, std::uintptr_t b) { return less_performance(a, b); }); break; default: // No sorting diff --git a/src/include/wisdom/vulkan/vk_pipeline_cache.cpp b/src/include/wisdom/vulkan/vk_pipeline_cache.cpp index 7d2ef84ff..29c09cfb0 100644 --- a/src/include/wisdom/vulkan/vk_pipeline_cache.cpp +++ b/src/include/wisdom/vulkan/vk_pipeline_cache.cpp @@ -23,11 +23,8 @@ WIS_EXTERN_C WISDOM_API void wisVKDestroyPipelineCache(WisVKPipelineCache* self) } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKPipelineCacheSerialize( - const WisVKPipelineCache* self, - uint8_t* data, - size_t data_size -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKPipelineCacheSerialize(const WisVKPipelineCache* self, uint8_t* data, size_t data_size) { auto& impl = wis::from_handle_ref(self); auto& table = impl.device_header->header.device_table; @@ -46,9 +43,9 @@ WIS_EXTERN_C WISDOM_API size_t wisVKPipelineCacheGetSerializedSize(const WisVKPi std::size_t data_size = 0; table.vkGetPipelineCacheData(impl.device_header->header.device, impl.cache, &data_size, nullptr); return wis::aligned_size( - data_size, - 4096u - ); // Align to 4096 bytes for better memory management when this data is used to create a new pipeline cache + data_size, + 4096u + ); // Align to 4096 bytes for better memory management when this data is used to create a new pipeline cache } #endif // WIS_VK_PIPELINE_CACHE_CPP diff --git a/src/include/wisdom/vulkan/vk_resource_allocator.cpp b/src/include/wisdom/vulkan/vk_resource_allocator.cpp index f2ab9f117..75a2bb7b8 100644 --- a/src/include/wisdom/vulkan/vk_resource_allocator.cpp +++ b/src/include/wisdom/vulkan/vk_resource_allocator.cpp @@ -16,8 +16,8 @@ inline VkImageCreateInfo VKFillImageDesc(const WisTextureDesc& desc) noexcept .flags = (usage & (VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_SRC_BIT_KHR | VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR)) - ? VK_IMAGE_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR - : VkImageCreateFlags{0}, + ? VK_IMAGE_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR + : VkImageCreateFlags{0}, .format = wis::detail::VKConvert(desc.format), .samples = VK_SAMPLE_COUNT_1_BIT, .usage = usage, @@ -102,11 +102,8 @@ WIS_EXTERN_C WISDOM_API void wisVKDestroyResourceAllocator(WisVKResourceAllocato } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateBuffer( - const WisVKResourceAllocator* self, - const WisBufferDesc* desc, - WisVKBuffer* buffer -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKResourceAllocatorCreateBuffer(const WisVKResourceAllocator* self, const WisBufferDesc* desc, WisVKBuffer* buffer) { auto& allocator = wis::from_handle_ref(self); @@ -118,8 +115,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateBuffer( buffer_info.flags = (buffer_info.usage & (VK_BUFFER_USAGE_VIDEO_DECODE_DST_BIT_KHR | VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR)) - ? VK_BUFFER_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR - : 0; + ? VK_BUFFER_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR + : 0; VmaAllocationCreateFlags flags = wis::detail::VKConvert(desc->memory_flags); if (desc->memory_flags & WisMemoryFlagsMapped) { @@ -145,13 +142,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateBuffer( VkBuffer buffer_handle = VK_NULL_HANDLE; VmaAllocation allocation_handle = VK_NULL_HANDLE; VkResult vr = vmaCreateBuffer( - allocator.allocator, - &buffer_info, - &alloc_info, - &buffer_handle, - &allocation_handle, - nullptr - ); + allocator.allocator, + &buffer_info, + &alloc_info, + &buffer_handle, + &allocation_handle, + nullptr + ); if (!wis::detail::succeeded(vr)) { return wis::detail::make_result(vr); } @@ -188,8 +185,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateTexture( // Check memory type, you can't create a texture with upload or readback memory types if (desc->memory_type == WisMemoryTypeUpload || desc->memory_type == WisMemoryTypeReadback) { return wis::detail::make_result( - VK_ERROR_UNKNOWN - ); + VK_ERROR_UNKNOWN + ); } VkImageCreateInfo image_info = wis::detail::VKFillImageDesc(*desc); @@ -233,7 +230,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateTexture( VkImage image_handle = VK_NULL_HANDLE; VmaAllocation allocation_handle = VK_NULL_HANDLE; VkResult - vr = vmaCreateImage(allocator.allocator, &image_info, &alloc_info, &image_handle, &allocation_handle, nullptr); + vr = vmaCreateImage(allocator.allocator, &image_info, &alloc_info, &image_handle, &allocation_handle, nullptr); if (!wis::detail::succeeded(vr)) { return wis::detail::make_result(vr); } @@ -252,13 +249,14 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateTexture( .image = image_handle, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED, .newLayout = VK_IMAGE_LAYOUT_GENERAL, - .subresourceRange = { - .aspectMask = wis::detail::VKAspectFlags(image_info.format), - .baseMipLevel = 0, - .levelCount = image_info.mipLevels, - .baseArrayLayer = 0, - .layerCount = image_info.arrayLayers, - }, + .subresourceRange = + { + .aspectMask = wis::detail::VKAspectFlags(image_info.format), + .baseMipLevel = 0, + .levelCount = image_info.mipLevels, + .baseArrayLayer = 0, + .layerCount = image_info.arrayLayers, + }, }; vr = table.vkTransitionImageLayoutEXT(header.device, 1, &transition_info); @@ -275,8 +273,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKResourceAllocatorCreateTexture( .width = static_cast(image_info.extent.width), .height = static_cast(image_info.extent.height), .depth_or_array_size = desc->layout == WisTextureLayoutTexture3D - ? static_cast(image_info.extent.depth) - : static_cast(image_info.arrayLayers), + ? static_cast(image_info.extent.depth) + : static_cast(image_info.arrayLayers), }; impl.device_header->AddRef(); diff --git a/src/include/wisdom/vulkan/vk_swapchain.cpp b/src/include/wisdom/vulkan/vk_swapchain.cpp index 274a304f2..bc8d2b1bb 100644 --- a/src/include/wisdom/vulkan/vk_swapchain.cpp +++ b/src/include/wisdom/vulkan/vk_swapchain.cpp @@ -17,13 +17,13 @@ inline VkResult VKAcquireNextImage(const impl::VKSwapchainImpl& impl) noexcept // Acquire the next image index for the new swapchain to update internal state auto result = impl.swapchain_table->vkAcquireNextImageKHR( - impl.device, - impl.swapchain, - impl.lazy_acquire ? 0 : std::numeric_limits::max(), - semaphores[impl.acquire_index], - nullptr, - &impl.present_index - ); + impl.device, + impl.swapchain, + impl.lazy_acquire ? 0 : std::numeric_limits::max(), + semaphores[impl.acquire_index], + nullptr, + &impl.present_index + ); if (result != VK_SUCCESS) { return result; // Caller can choose to handle timeout differently (e.g. by skipping rendering and trying again @@ -79,12 +79,8 @@ WIS_EXTERN_C WISDOM_API void wisVKDestroySwapchain(WisVKSwapchain* self) } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainPresent( - const WisVKSwapchain* self, - WisPresentFlags flags, - const WisRect* rects, - size_t rect_count -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKSwapchainPresent(const WisVKSwapchain* self, WisPresentFlags flags, const WisRect* rects, size_t rect_count) { auto& impl = wis::from_handle_ref(self); @@ -162,8 +158,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel VkFormat new_format = wis::detail::VKConvert(desc->format); bool size_changed = desc->width != 0 && desc->height != 0 - && (desc->width != create_info.imageExtent.width - || desc->height != create_info.imageExtent.height); + && (desc->width != create_info.imageExtent.width || desc->height != create_info.imageExtent.height + ); bool format_changed = desc->format != WisDataFormatUnknown && new_format != create_info.imageFormat; bool count_changed = desc->image_count != 0 && desc->image_count != create_info.minImageCount; bool vsync_changed = desc->vsync != (create_info.presentMode == VK_PRESENT_MODE_FIFO_KHR); @@ -177,10 +173,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel } else if (std::ranges::find(modes, VK_PRESENT_MODE_FIFO_RELAXED_KHR) != std::end(modes)) { present_mode = VK_PRESENT_MODE_FIFO_RELAXED_KHR; } - } else if ( - std::ranges::find(modes, VK_PRESENT_MODE_MAILBOX_KHR) != std::end(modes) - && (create_info.imageArrayLayers == 1) - ) { + } else if (std::ranges::find(modes, VK_PRESENT_MODE_MAILBOX_KHR) != std::end(modes) + && (create_info.imageArrayLayers == 1)) { present_mode = VK_PRESENT_MODE_MAILBOX_KHR; } } @@ -193,15 +187,13 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel if (format_changed) { auto formats = header.GetSupportedFormats(); if (std::ranges::find_if( - formats, - [new_format](const VkSurfaceFormatKHR& fmt) { - return fmt.format == new_format; - } + formats, + [new_format](const VkSurfaceFormatKHR& fmt) { return fmt.format == new_format; } ) - == std::end(formats)) { + == std::end(formats)) { return wis::detail::make_result( - VK_ERROR_FORMAT_NOT_SUPPORTED - ); + VK_ERROR_FORMAT_NOT_SUPPORTED + ); } } @@ -220,16 +212,16 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel header.vkGetPhysicalDeviceSurfaceCapabilities2KHR(header.physical_device, &surface_info, &capabilities); capabilities.surfaceCapabilities.maxImageCount = capabilities.surfaceCapabilities.maxImageCount == 0 - ? wis::AbsoluteMaxSwapchainImages - : capabilities.surfaceCapabilities.maxImageCount; + ? wis::AbsoluteMaxSwapchainImages + : capabilities.surfaceCapabilities.maxImageCount; } if (count_changed - && (desc->image_count < capabilities.surfaceCapabilities.minImageCount - || desc->image_count > capabilities.surfaceCapabilities.maxImageCount)) { + && (desc->image_count < capabilities.surfaceCapabilities.minImageCount + || desc->image_count > capabilities.surfaceCapabilities.maxImageCount)) { return wis::detail::make_result< - wis::detail::Func(), - "Requested swapchain image count is out of bounds for the given surface">(VK_ERROR_INITIALIZATION_FAILED); + wis::detail::Func(), + "Requested swapchain image count is out of bounds for the given surface">(VK_ERROR_INITIALIZATION_FAILED); } // Store backups @@ -247,17 +239,17 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel }; create_info.imageExtent.width = desc->width != 0 ? std::clamp( - desc->width, - capabilities.surfaceCapabilities.minImageExtent.width, - capabilities.surfaceCapabilities.maxImageExtent.width - ) - : create_info.imageExtent.width; + desc->width, + capabilities.surfaceCapabilities.minImageExtent.width, + capabilities.surfaceCapabilities.maxImageExtent.width + ) + : create_info.imageExtent.width; create_info.imageExtent.height = desc->height != 0 ? std::clamp( - desc->height, - capabilities.surfaceCapabilities.minImageExtent.height, - capabilities.surfaceCapabilities.maxImageExtent.height - ) - : create_info.imageExtent.height; + desc->height, + capabilities.surfaceCapabilities.minImageExtent.height, + capabilities.surfaceCapabilities.maxImageExtent.height + ) + : create_info.imageExtent.height; create_info.imageFormat = desc->format != WisDataFormatUnknown ? new_format : create_info.imageFormat; create_info.minImageCount = desc->image_count != 0 ? desc->image_count : create_info.minImageCount; @@ -280,7 +272,7 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel // Wait for the GPU to finish with the swapchain vr = impl.swapchain_table - ->vkWaitForFences(impl.device, 1, &impl.destroy_fence, VK_TRUE, std::numeric_limits::max()); + ->vkWaitForFences(impl.device, 1, &impl.destroy_fence, VK_TRUE, std::numeric_limits::max()); if (!wis::detail::succeeded(vr)) { restore_on_failure(); return wis::detail::make_result(vr); @@ -296,18 +288,15 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainUpdate(const WisVKSwapchain* sel if (vr != VK_SUCCESS) { // no restore return wis::detail:: - make_result(vr); + make_result(vr); } return wis::detail::vk_success; } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainGetTextures( - const WisVKSwapchain* self, - WisVKTexture* buffers, - size_t buffer_count -) +WIS_EXTERN_C WISDOM_API WisResult +wisVKSwapchainGetTextures(const WisVKSwapchain* self, WisVKTexture* buffers, size_t buffer_count) { auto& impl = wis::from_handle_ref(self); @@ -319,8 +308,8 @@ WIS_EXTERN_C WISDOM_API WisResult wisVKSwapchainGetTextures( if (buffer_count < actual_buffer_count) { return wis::detail::make_result< - wis::detail::Func(), - "Provided buffer count is less than the number of swapchain images">(VK_ERROR_UNKNOWN); + wis::detail::Func(), + "Provided buffer count is less than the number of swapchain images">(VK_ERROR_UNKNOWN); } // Cheat the allocation of the output array to avoid dynamic memory allocation in this function by treating the diff --git a/src/include/wisdom/vulkan/vk_tables.hpp b/src/include/wisdom/vulkan/vk_tables.hpp index 2b1e327ec..0fed82c81 100644 --- a/src/include/wisdom/vulkan/vk_tables.hpp +++ b/src/include/wisdom/vulkan/vk_tables.hpp @@ -16,7 +16,7 @@ typedef struct VkPhysicalDeviceDeviceAddressCommandsFeaturesKHR { } VkPhysicalDeviceDeviceAddressCommandsFeaturesKHR; static constexpr VkStructureType -VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_ADDRESS_COMMANDS_FEATURES_KHR = VkStructureType(1000318006); + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_ADDRESS_COMMANDS_FEATURES_KHR = VkStructureType(1000318006); static constexpr VkStructureType VK_STRUCTURE_TYPE_BIND_VERTEX_BUFFER_3_INFO_KHR = VkStructureType(1000318008); static constexpr VkStructureType VK_STRUCTURE_TYPE_BIND_INDEX_BUFFER_3_INFO_KHR = VkStructureType(1000318007); @@ -44,11 +44,11 @@ typedef struct VkBindIndexBuffer3InfoKHR { } VkBindIndexBuffer3InfoKHR; using PFN_vkCmdBindVertexBuffers3KHR = void (*)( - VkCommandBuffer commandBuffer, - uint32_t firstBinding, - uint32_t bindingCount, - const VkBindVertexBuffer3InfoKHR* pBindingInfos - ); + VkCommandBuffer commandBuffer, + uint32_t firstBinding, + uint32_t bindingCount, + const VkBindVertexBuffer3InfoKHR* pBindingInfos +); using PFN_vkCmdBindIndexBuffer3KHR = void (*)(VkCommandBuffer commandBuffer, const VkBindIndexBuffer3InfoKHR* pInfo); #endif // VK_KHR_device_address_commands diff --git a/src/include/wisdom/wisdom.hpp b/src/include/wisdom/wisdom.hpp index cd4ae1e0c..9f6d7f667 100644 --- a/src/include/wisdom/wisdom.hpp +++ b/src/include/wisdom/wisdom.hpp @@ -91,11 +91,11 @@ WIS_NODISCARD inline wis::Instance CreateInstance( { wis::DX12Instance instance{}; const WisResult wis_result = ::wisDX12CreateInstance( - reinterpret_cast(debug_desc), - reinterpret_cast(extensions.data()), - extensions.size(), - instance.GetStorage() - ); + reinterpret_cast(debug_desc), + reinterpret_cast(extensions.data()), + extensions.size(), + instance.GetStorage() + ); out_result = wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; return instance; } @@ -177,11 +177,11 @@ WIS_NODISCARD inline wis::Instance CreateInstance( { wis::VKInstance instance{}; const WisResult wis_result = ::wisVKCreateInstance( - reinterpret_cast(debug_desc), - reinterpret_cast(extensions.data()), - extensions.size(), - instance.GetStorage() - ); + reinterpret_cast(debug_desc), + reinterpret_cast(extensions.data()), + extensions.size(), + instance.GetStorage() + ); out_result = wis::Result{static_cast(wis_result.status), wis_result.platform_code, wis_result.error}; return instance; } diff --git a/src/platform/wisdom_platform/dx12/dx12_platform_uwp.cpp b/src/platform/wisdom_platform/dx12/dx12_platform_uwp.cpp index e62fadd0c..9ebb4fc74 100644 --- a/src/platform/wisdom_platform/dx12/dx12_platform_uwp.cpp +++ b/src/platform/wisdom_platform/dx12/dx12_platform_uwp.cpp @@ -39,11 +39,8 @@ WIS_EXTERN_C WISDOM_PLATFORM_API void wisDX12DestroyUWPExtension(WisDX12UWPExten } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_PLATFORM_API WisResult wisDX12UWPExtensionCreateSurface( - WisDX12UWPExtension* self, - const WisUWPWindowDesc* info, - WisDX12Surface* surface -) +WIS_EXTERN_C WISDOM_PLATFORM_API WisResult +wisDX12UWPExtensionCreateSurface(WisDX12UWPExtension* self, const WisUWPWindowDesc* info, WisDX12Surface* surface) { new (surface) wis::impl::DX12SurfaceImpl{ .surface = info->core_window, diff --git a/src/platform/wisdom_platform/dx12/dx12_platform_win32.cpp b/src/platform/wisdom_platform/dx12/dx12_platform_win32.cpp index 4491fbd87..81b777107 100644 --- a/src/platform/wisdom_platform/dx12/dx12_platform_win32.cpp +++ b/src/platform/wisdom_platform/dx12/dx12_platform_win32.cpp @@ -39,11 +39,8 @@ WIS_EXTERN_C WISDOM_PLATFORM_API void wisDX12DestroyWin32Extension(WisDX12Win32E } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_PLATFORM_API WisResult wisDX12Win32ExtensionCreateSurface( - WisDX12Win32Extension* self, - const WisWin32WindowDesc* info, - WisDX12Surface* surface -) +WIS_EXTERN_C WISDOM_PLATFORM_API WisResult +wisDX12Win32ExtensionCreateSurface(WisDX12Win32Extension* self, const WisWin32WindowDesc* info, WisDX12Surface* surface) { new (surface) wis::impl::DX12SurfaceImpl{ .surface = info->hwnd, diff --git a/src/platform/wisdom_platform/generated/c_api.h b/src/platform/wisdom_platform/generated/c_api.h index 2c39cb174..e1757104f 100644 --- a/src/platform/wisdom_platform/generated/c_api.h +++ b/src/platform/wisdom_platform/generated/c_api.h @@ -132,11 +132,8 @@ WIS_INLINE WISDOM_PLATFORM_API bool wisDX12Win32ExtensionSupported(WisDX12Win32E * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_PLATFORM_API WisResult wisDX12UWPExtensionCreateSurface( - WisDX12UWPExtension* self, - const WisUWPWindowDesc* info, - WisDX12Surface* surface -); +WIS_INLINE WISDOM_PLATFORM_API WisResult +wisDX12UWPExtensionCreateSurface(WisDX12UWPExtension* self, const WisUWPWindowDesc* info, WisDX12Surface* surface); #endif // WISDOM_DX12 @@ -229,11 +226,8 @@ WIS_INLINE WISDOM_PLATFORM_API void wisVKInitWin32Extension(WisVKWin32Extension* * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_PLATFORM_API WisResult wisVKXlibExtensionCreateSurface( - WisVKXlibExtension* self, - const WisXlibWindowDesc* info, - WisVKSurface* surface -); +WIS_INLINE WISDOM_PLATFORM_API WisResult +wisVKXlibExtensionCreateSurface(WisVKXlibExtension* self, const WisXlibWindowDesc* info, WisVKSurface* surface); /** * @brief Provided by Wisdom 0.7.0. Checks if the Xlib surface extension is supported on the current platform. @@ -251,11 +245,8 @@ WIS_INLINE WISDOM_PLATFORM_API bool wisVKXlibExtensionSupported(WisVKXlibExtensi * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_PLATFORM_API WisResult wisVKXCBExtensionCreateSurface( - WisVKXCBExtension* self, - const WisXCBWindowDesc* info, - WisVKSurface* surface -); +WIS_INLINE WISDOM_PLATFORM_API WisResult +wisVKXCBExtensionCreateSurface(WisVKXCBExtension* self, const WisXCBWindowDesc* info, WisVKSurface* surface); /** * @brief Provided by Wisdom 0.7.0. Checks if the XCB surface extension is supported on the current platform. @@ -295,11 +286,8 @@ WIS_INLINE WISDOM_PLATFORM_API bool wisVKWaylandExtensionSupported(WisVKWaylandE * @return Result denoting the outcome of operation. * * */ -WIS_INLINE WISDOM_PLATFORM_API WisResult wisVKWin32ExtensionCreateSurface( - WisVKWin32Extension* self, - const WisWin32WindowDesc* info, - WisVKSurface* surface -); +WIS_INLINE WISDOM_PLATFORM_API WisResult +wisVKWin32ExtensionCreateSurface(WisVKWin32Extension* self, const WisWin32WindowDesc* info, WisVKSurface* surface); /** * @brief Provided by Wisdom 0.7.0. Checks if the Win32 surface extension is supported on the current platform. Always diff --git a/src/platform/wisdom_platform/generated/cpp_api.hpp b/src/platform/wisdom_platform/generated/cpp_api.hpp index 75f8ce00d..74cc9072f 100644 --- a/src/platform/wisdom_platform/generated/cpp_api.hpp +++ b/src/platform/wisdom_platform/generated/cpp_api.hpp @@ -70,9 +70,7 @@ struct UWPWindowDesc { namespace wis { struct DX12Win32ExtensionDeleter { - void operator()(WisDX12Win32Extension* handle) noexcept { - ::wisDX12DestroyWin32Extension(handle); - } + void operator()(WisDX12Win32Extension* handle) noexcept { ::wisDX12DestroyWin32Extension(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Extension for Win32 surface creation functions. @@ -80,7 +78,7 @@ struct DX12Win32ExtensionDeleter { * */ class DX12Win32Extension : public wis::impl:: - Implements + Implements { public: DX12Win32Extension() noexcept @@ -89,9 +87,7 @@ class DX12Win32Extension ::wisDX12InitWin32Extension(GetStorage()); } // Operator & overload - wis::DX12InstanceExtensionHeader* operator&() noexcept { - return &GetMutableInternal().header; - } + wis::DX12InstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } public: /** @@ -108,10 +104,10 @@ class DX12Win32Extension { wis::DX12Surface surface{}; const WisResult wis_result = ::wisDX12Win32ExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -125,15 +121,11 @@ class DX12Win32Extension * @return bool true if the extension is supported, false otherwise. * * */ - WIS_NODISCARD inline bool Supported() noexcept { - return (::wisDX12Win32ExtensionSupported(&_impl_storage)); - } + WIS_NODISCARD inline bool Supported() noexcept { return (::wisDX12Win32ExtensionSupported(&_impl_storage)); } }; struct DX12UWPExtensionDeleter { - void operator()(WisDX12UWPExtension* handle) noexcept { - ::wisDX12DestroyUWPExtension(handle); - } + void operator()(WisDX12UWPExtension* handle) noexcept { ::wisDX12DestroyUWPExtension(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Extension for UWP surface creation functions. @@ -149,9 +141,7 @@ class DX12UWPExtension ::wisDX12InitUWPExtension(GetStorage()); } // Operator & overload - wis::DX12InstanceExtensionHeader* operator&() noexcept { - return &GetMutableInternal().header; - } + wis::DX12InstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } public: /** @@ -168,10 +158,10 @@ class DX12UWPExtension { wis::DX12Surface surface{}; const WisResult wis_result = ::wisDX12UWPExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -189,9 +179,7 @@ class DX12UWPExtension namespace wis { struct VKXlibExtensionDeleter { - void operator()(WisVKXlibExtension* handle) noexcept { - ::wisVKDestroyXlibExtension(handle); - } + void operator()(WisVKXlibExtension* handle) noexcept { ::wisVKDestroyXlibExtension(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Extension for Xlib surface creation functions. @@ -207,9 +195,7 @@ class VKXlibExtension ::wisVKInitXlibExtension(GetStorage()); } // Operator & overload - wis::VKInstanceExtensionHeader* operator&() noexcept { - return &GetMutableInternal().header; - } + wis::VKInstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } public: /** @@ -223,10 +209,10 @@ class VKXlibExtension { wis::VKSurface surface{}; const WisResult wis_result = ::wisVKXlibExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -239,15 +225,11 @@ class VKXlibExtension * @return bool true if the extension is supported, false otherwise. * * */ - WIS_NODISCARD inline bool Supported() noexcept { - return (::wisVKXlibExtensionSupported(&_impl_storage)); - } + WIS_NODISCARD inline bool Supported() noexcept { return (::wisVKXlibExtensionSupported(&_impl_storage)); } }; struct VKXCBExtensionDeleter { - void operator()(WisVKXCBExtension* handle) noexcept { - ::wisVKDestroyXCBExtension(handle); - } + void operator()(WisVKXCBExtension* handle) noexcept { ::wisVKDestroyXCBExtension(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Extension for Xlib surface creation functions. @@ -263,9 +245,7 @@ class VKXCBExtension ::wisVKInitXCBExtension(GetStorage()); } // Operator & overload - wis::VKInstanceExtensionHeader* operator&() noexcept { - return &GetMutableInternal().header; - } + wis::VKInstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } public: /** @@ -279,10 +259,10 @@ class VKXCBExtension { wis::VKSurface surface{}; const WisResult wis_result = ::wisVKXCBExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -295,15 +275,11 @@ class VKXCBExtension * @return bool true if the extension is supported, false otherwise. * * */ - WIS_NODISCARD inline bool Supported() noexcept { - return (::wisVKXCBExtensionSupported(&_impl_storage)); - } + WIS_NODISCARD inline bool Supported() noexcept { return (::wisVKXCBExtensionSupported(&_impl_storage)); } }; struct VKWaylandExtensionDeleter { - void operator()(WisVKWaylandExtension* handle) noexcept { - ::wisVKDestroyWaylandExtension(handle); - } + void operator()(WisVKWaylandExtension* handle) noexcept { ::wisVKDestroyWaylandExtension(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Extension for Xlib surface creation functions. @@ -311,7 +287,7 @@ struct VKWaylandExtensionDeleter { * */ class VKWaylandExtension : public wis::impl:: - Implements + Implements { public: VKWaylandExtension() noexcept @@ -320,9 +296,7 @@ class VKWaylandExtension ::wisVKInitWaylandExtension(GetStorage()); } // Operator & overload - wis::VKInstanceExtensionHeader* operator&() noexcept { - return &GetMutableInternal().header; - } + wis::VKInstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } public: /** @@ -339,10 +313,10 @@ class VKWaylandExtension { wis::VKSurface surface{}; const WisResult wis_result = ::wisVKWaylandExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -355,15 +329,11 @@ class VKWaylandExtension * @return bool true if the extension is supported, false otherwise. * * */ - WIS_NODISCARD inline bool Supported() noexcept { - return (::wisVKWaylandExtensionSupported(&_impl_storage)); - } + WIS_NODISCARD inline bool Supported() noexcept { return (::wisVKWaylandExtensionSupported(&_impl_storage)); } }; struct VKWin32ExtensionDeleter { - void operator()(WisVKWin32Extension* handle) noexcept { - ::wisVKDestroyWin32Extension(handle); - } + void operator()(WisVKWin32Extension* handle) noexcept { ::wisVKDestroyWin32Extension(handle); } }; /** * @brief Provided by Wisdom 0.7.0. Extension for Win32 surface creation functions. @@ -379,9 +349,7 @@ class VKWin32Extension ::wisVKInitWin32Extension(GetStorage()); } // Operator & overload - wis::VKInstanceExtensionHeader* operator&() noexcept { - return &GetMutableInternal().header; - } + wis::VKInstanceExtensionHeader* operator&() noexcept { return &GetMutableInternal().header; } public: /** @@ -398,10 +366,10 @@ class VKWin32Extension { wis::VKSurface surface{}; const WisResult wis_result = ::wisVKWin32ExtensionCreateSurface( - &_impl_storage, - reinterpret_cast(&info), - surface.GetStorage() - ); + &_impl_storage, + reinterpret_cast(&info), + surface.GetStorage() + ); out_result = wis::Result{ static_cast(wis_result.status), wis_result.platform_code, @@ -415,9 +383,7 @@ class VKWin32Extension * @return bool true if the extension is supported, false otherwise. * * */ - WIS_NODISCARD inline bool Supported() noexcept { - return (::wisVKWin32ExtensionSupported(&_impl_storage)); - } + WIS_NODISCARD inline bool Supported() noexcept { return (::wisVKWin32ExtensionSupported(&_impl_storage)); } }; } // namespace wis diff --git a/src/platform/wisdom_platform/vulkan/vk_platform_wayland.cpp b/src/platform/wisdom_platform/vulkan/vk_platform_wayland.cpp index fe42f851b..7c88e6388 100644 --- a/src/platform/wisdom_platform/vulkan/vk_platform_wayland.cpp +++ b/src/platform/wisdom_platform/vulkan/vk_platform_wayland.cpp @@ -54,11 +54,8 @@ WIS_EXTERN_C WISDOM_PLATFORM_API void wisVKDestroyWaylandExtension(WisVKWaylandE } //---------------------------------------------------------------------------------------------------------------------- -WIS_EXTERN_C WISDOM_PLATFORM_API WisResult wisVKWaylandExtensionCreateSurface( - WisVKWaylandExtension* self, - const WisWaylandWindowDesc* info, - WisVKSurface* surface -) +WIS_EXTERN_C WISDOM_PLATFORM_API WisResult +wisVKWaylandExtensionCreateSurface(WisVKWaylandExtension* self, const WisWaylandWindowDesc* info, WisVKSurface* surface) { auto& impl = wis::from_handle_ref(self); auto vkCreateWaylandSurfaceKHR = reinterpret_cast(impl.vkCreateWaylandSurfaceKHR); @@ -82,8 +79,8 @@ WIS_EXTERN_C WISDOM_PLATFORM_API WisResult wisVKWaylandExtensionCreateSurface( auto& itable = impl.instance_control_block->header.instance_table; itable.vkDestroySurfaceKHR(impl.instance_control_block->header.instance, vk_surface, nullptr); return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } header->header.instance_header = impl.instance_control_block, header->header.surface = vk_surface, diff --git a/src/platform/wisdom_platform/vulkan/vk_platform_win32.cpp b/src/platform/wisdom_platform/vulkan/vk_platform_win32.cpp index 93bc34cf5..d56332ed1 100644 --- a/src/platform/wisdom_platform/vulkan/vk_platform_win32.cpp +++ b/src/platform/wisdom_platform/vulkan/vk_platform_win32.cpp @@ -80,11 +80,8 @@ WIS_EXTERN_C WISDOM_PLATFORM_API void wisVKDestroyWin32Extension(WisVKWin32Exten } //---------------------------------------------------------------------------------------------------------------------- -WISDOM_PLATFORM_API WisResult wisVKWin32ExtensionCreateSurface( - WisVKWin32Extension* self, - const WisWin32WindowDesc* info, - WisVKSurface* surface -) +WISDOM_PLATFORM_API WisResult +wisVKWin32ExtensionCreateSurface(WisVKWin32Extension* self, const WisWin32WindowDesc* info, WisVKSurface* surface) { auto& impl = wis::from_handle_ref(self); auto vkCreateWin32SurfaceKHR = reinterpret_cast(impl.vkCreateWin32SurfaceKHR); @@ -109,8 +106,8 @@ WISDOM_PLATFORM_API WisResult wisVKWin32ExtensionCreateSurface( auto& itable = impl.instance_control_block->header.instance_table; itable.vkDestroySurfaceKHR(impl.instance_control_block->header.instance, vk_surface, nullptr); return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } header->header.instance_header = impl.instance_control_block, header->header.surface = vk_surface, diff --git a/src/platform/wisdom_platform/vulkan/vk_platform_xcb.cpp b/src/platform/wisdom_platform/vulkan/vk_platform_xcb.cpp index eab56c055..18e5a05af 100644 --- a/src/platform/wisdom_platform/vulkan/vk_platform_xcb.cpp +++ b/src/platform/wisdom_platform/vulkan/vk_platform_xcb.cpp @@ -58,11 +58,8 @@ WIS_EXTERN_C WISDOM_PLATFORM_API void wisVKDestroyXCBExtension(WisVKXCBExtension } //---------------------------------------------------------------------------------------------------------------------- -WISDOM_PLATFORM_API WisResult wisVKXCBExtensionCreateSurface( - WisVKXCBExtension* self, - const WisXCBWindowDesc* info, - WisVKSurface* surface -) +WISDOM_PLATFORM_API WisResult +wisVKXCBExtensionCreateSurface(WisVKXCBExtension* self, const WisXCBWindowDesc* info, WisVKSurface* surface) { auto& impl = wis::from_handle_ref(self); auto vkCreateXcbSurfaceKHR = reinterpret_cast(impl.vkCreateXcbSurfaceKHR); @@ -86,8 +83,8 @@ WISDOM_PLATFORM_API WisResult wisVKXCBExtensionCreateSurface( auto& itable = impl.instance_control_block->header.instance_table; itable.vkDestroySurfaceKHR(impl.instance_control_block->header.instance, vk_surface, nullptr); return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } header->header.instance_header = impl.instance_control_block, header->header.surface = vk_surface, diff --git a/src/platform/wisdom_platform/vulkan/vk_platform_xlib.cpp b/src/platform/wisdom_platform/vulkan/vk_platform_xlib.cpp index 630b036aa..9b8ebc73d 100644 --- a/src/platform/wisdom_platform/vulkan/vk_platform_xlib.cpp +++ b/src/platform/wisdom_platform/vulkan/vk_platform_xlib.cpp @@ -59,11 +59,8 @@ WIS_EXTERN_C WISDOM_PLATFORM_API void wisVKDestroyXlibExtension(WisVKXlibExtensi } //---------------------------------------------------------------------------------------------------------------------- -WISDOM_PLATFORM_API WisResult wisVKXlibExtensionCreateSurface( - WisVKXlibExtension* self, - const WisXlibWindowDesc* info, - WisVKSurface* surface -) +WISDOM_PLATFORM_API WisResult +wisVKXlibExtensionCreateSurface(WisVKXlibExtension* self, const WisXlibWindowDesc* info, WisVKSurface* surface) { auto& impl = wis::from_handle_ref(self); auto vkCreateXlibSurfaceKHR = reinterpret_cast(impl.vkCreateXlibSurfaceKHR); @@ -87,8 +84,8 @@ WISDOM_PLATFORM_API WisResult wisVKXlibExtensionCreateSurface( auto& itable = impl.instance_control_block->header.instance_table; itable.vkDestroySurfaceKHR(impl.instance_control_block->header.instance, vk_surface, nullptr); return wis::detail::make_result( - VK_ERROR_OUT_OF_HOST_MEMORY - ); + VK_ERROR_OUT_OF_HOST_MEMORY + ); } header->header.instance_header = impl.instance_control_block, header->header.surface = vk_surface, diff --git a/test_package/main.cpp b/test_package/main.cpp index 84bd8e385..eb58a56a3 100644 --- a/test_package/main.cpp +++ b/test_package/main.cpp @@ -6,4 +6,4 @@ int main() wis::DebugDesc debug_desc{true}; wis::Instance instance = wis::CreateInstance(&debug_desc, {}, result); return 0; -} \ No newline at end of file +} diff --git a/tests/basic/platform_check.cpp b/tests/basic/platform_check.cpp index b7c3417e4..8e0905dc4 100644 --- a/tests/basic/platform_check.cpp +++ b/tests/basic/platform_check.cpp @@ -21,11 +21,11 @@ TEST_CASE("check_platform_support") &win32_extension.header, }; WisResult result = wisCreateInstance( - NULL, - extensions, - sizeof(extensions) / sizeof(WisInstanceExtensionHeader*), - &instance - ); + NULL, + extensions, + sizeof(extensions) / sizeof(WisInstanceExtensionHeader*), + &instance + ); // Expect partial success REQUIRE(result.status >= 0); @@ -43,7 +43,6 @@ TEST_CASE("check_platform_support") bool wayland_supported = wisWaylandExtensionSupported(&wayland_extension); bool win32_supported = wisWin32ExtensionSupported(&win32_extension); - printf("XCB supported: %s\n", xcb_supported ? "Yes" : "No"); printf("Xlib supported: %s\n", xlib_supported ? "Yes" : "No"); printf("Wayland supported: %s\n", wayland_supported ? "Yes" : "No"); From 9f57aed0d41b37af5d2e0ddee240afae323118e1 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 13 Sep 2026 17:07:34 +0000 Subject: [PATCH 05/11] Restyled by cmake-format --- CMakeLists.txt | 16 ++++++++++------ examples/CMakeLists.txt | 4 ++-- examples/hello_triangle/CMakeLists.txt | 4 +++- generator/CMakeLists.txt | 3 ++- src/CMakeLists.txt | 2 +- src/extensions/CMakeLists.txt | 7 ++----- src/include/CMakeLists.txt | 8 +------- src/platform/CMakeLists.txt | 9 ++++----- test_package/CMakeLists.txt | 4 ++-- tests/CMakeLists.txt | 8 ++++++-- tests/basic/CMakeLists.txt | 2 +- tests/integration/cmake/CMakeLists.txt | 2 +- 12 files changed, 35 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 92ea662b4..6b9fd782c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,8 @@ option(WISDOM_BUILD_SHARED "Build the dynamic lib." ON) option(WISDOM_BUILD_PLATFORM "Build unified platform extension library." ON) option(WISDOM_BUILD_DOCS "Build the documentation." OFF) option(WISDOM_USE_AGILITY_SDK "Download and use DirectX 12 Agility SDK." ON) -option(WISDOM_USE_CONAN "Use Conan to manage dependencies. Only for library builds." OFF) +option(WISDOM_USE_CONAN + "Use Conan to manage dependencies. Only for library builds." OFF) # DXC deployment options set(WISDOM_VULKAN_HEADER_PATH @@ -34,8 +35,8 @@ set(WISDOM_VULKAN_HEADER_PATH CACHE PATH "Path to custom Vulkan Headers (optional)") # Conan includes Vulkan Headers. -if (WISDOM_USE_CONAN) - set(WISDOM_VULKAN ON) +if(WISDOM_USE_CONAN) + set(WISDOM_VULKAN ON) endif() # Load all dependencies @@ -100,13 +101,16 @@ set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") set(CPACK_PACKAGE_VENDOR "Agrael") set(CPACK_NUGET_PACKAGE_AUTHORS "Agrael") -set(CPACK_PACKAGE_DESCRIPTION "A Low-level thin multiplatform and extensible Graphics API layer over Vulkan and DX12") +set(CPACK_PACKAGE_DESCRIPTION + "A Low-level thin multiplatform and extensible Graphics API layer over Vulkan and DX12" +) set(CPACK_PACKAGE_HOMEPAGE_URL "https://agrael1.github.io/Wisdom/") set(CPACK_NUGET_PACKAGE_REPOSITORY_URL "https://github.com/Agrael1/Wisdom.git") set(CPACK_NUGET_PACKAGE_ICON "favicon.png") # pulled from installed files set(CPACK_NUGET_PACKAGE_REPOSITORY_TYPE git) set(CPACK_NUGET_PACKAGE_LICENSE_EXPRESSION "MIT") set(CPACK_NUGET_PACKAGE_README "README.md") # pulled from installed files -set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_LIST_DIR}/cmake/install/cpack-options.cmake") +set(CPACK_PROJECT_CONFIG_FILE + "${CMAKE_CURRENT_LIST_DIR}/cmake/install/cpack-options.cmake") -include(CPack) \ No newline at end of file +include(CPack) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 68d0a9081..1bac29159 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -52,8 +52,8 @@ include(cmake/deps.cmake) add_custom_target( copy_assets COMMAND ${CMAKE_COMMAND} -E echo "Copying assets to example binaries..." - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/assets ${EXAMPLE_BIN_OUTPUT}/assets) + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets + ${EXAMPLE_BIN_OUTPUT}/assets) add_example_suite(backend) add_example_suite(compute_particles_c) diff --git a/examples/hello_triangle/CMakeLists.txt b/examples/hello_triangle/CMakeLists.txt index 83b1dc304..c7aec17c1 100644 --- a/examples/hello_triangle/CMakeLists.txt +++ b/examples/hello_triangle/CMakeLists.txt @@ -64,7 +64,9 @@ target_compile_definitions(${PROJECT_NAME}-cpp-headers PUBLIC ${ADD_DEFINITIONS}) add_dependencies(${PROJECT_NAME}-cpp-headers copy_sdl wis_test_compile_shaders) -if(POSTFIX STREQUAL "dx12" AND WISDOM_BUILD_STATIC AND WISDOM_USE_AGILITY_SDK) +if(POSTFIX STREQUAL "dx12" + AND WISDOM_BUILD_STATIC + AND WISDOM_USE_AGILITY_SDK) wis_install_agility_win32(TARGET ${PROJECT_NAME}-cpp) wis_install_agility_win32(TARGET ${PROJECT_NAME}-c) endif() diff --git a/generator/CMakeLists.txt b/generator/CMakeLists.txt index 77761ef70..432cf2c4b 100644 --- a/generator/CMakeLists.txt +++ b/generator/CMakeLists.txt @@ -51,7 +51,8 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20) target_precompile_headers(${PROJECT_NAME} PRIVATE "pch.hpp") # Also generate video extension API by running generator with "video" argument -add_custom_target(generate-video-api +add_custom_target( + generate-video-api COMMAND ${PROJECT_NAME} video WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.. COMMENT "Generating Video extension API" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b522b11b6..0db81f93f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,4 +5,4 @@ if(WISDOM_BUILD_PLATFORM) add_subdirectory(platform) endif() -add_subdirectory(extensions) \ No newline at end of file +add_subdirectory(extensions) diff --git a/src/extensions/CMakeLists.txt b/src/extensions/CMakeLists.txt index 9c991e368..a99b6e2ae 100644 --- a/src/extensions/CMakeLists.txt +++ b/src/extensions/CMakeLists.txt @@ -1,7 +1,4 @@ # Each extension will provide an option to build it -# Extensions -# option(WISDOM_BUILD_EXTENSION "Build the X extension." ON) -# if (WISDOM_BUILD_EXTENSION) -# add_subdirectory(extension) -# endif() \ No newline at end of file +# Extensions option(WISDOM_BUILD_EXTENSION "Build the X extension." ON) if +# (WISDOM_BUILD_EXTENSION) add_subdirectory(extension) endif() diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index dd653b214..7840f7a63 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -8,13 +8,7 @@ set(WISDOM_CORE_DEFINITIONS $:WISDOM_VULKAN=1>>) if(WISDOM_DX12) - list( - APPEND - WISDOM_CORE_LIBS - DXGI - DXGUID - d3d12 - GPUOpen::D3D12MemoryAllocator) + list(APPEND WISDOM_CORE_LIBS DXGI DXGUID d3d12 GPUOpen::D3D12MemoryAllocator) list( APPEND diff --git a/src/platform/CMakeLists.txt b/src/platform/CMakeLists.txt index c42171aaa..51ed2d106 100644 --- a/src/platform/CMakeLists.txt +++ b/src/platform/CMakeLists.txt @@ -26,8 +26,8 @@ target_include_directories( $) target_link_libraries(wisdom-platform-headers INTERFACE wis::wisdom-headers) -target_compile_definitions( - wisdom-platform-headers INTERFACE WISDOM_PLATFORM_STATIC=1) +target_compile_definitions(wisdom-platform-headers + INTERFACE WISDOM_PLATFORM_STATIC=1) install( TARGETS wisdom-platform-headers @@ -49,9 +49,8 @@ if(WISDOM_BUILD_STATIC) wisdom-platform PUBLIC $ $) - set_target_properties( - wisdom-platform PROPERTIES CXX_STANDARD 20 - DEBUG_POSTFIX d) + set_target_properties(wisdom-platform PROPERTIES CXX_STANDARD 20 DEBUG_POSTFIX + d) install( TARGETS wisdom-platform diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 96bbfd8d0..19ca31214 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -5,7 +5,7 @@ find_package(Wisdom REQUIRED) add_executable(test_app main.cpp) if(WISDOM_IS_SHARED) - target_link_libraries(test_app PRIVATE wis::wisdom-shared) + target_link_libraries(test_app PRIVATE wis::wisdom-shared) else() - target_link_libraries(test_app PRIVATE wis::wisdom) + target_link_libraries(test_app PRIVATE wis::wisdom) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ca11c3bdb..f9de6d2e8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,9 +6,13 @@ function(wis_add_test TARGET SOURCES IMPL) add_executable(${TEST_TARGET} ${SOURCES}) if(WISDOM_BUILD_STATIC) # Link against static library if built - target_link_libraries(${TEST_TARGET} PUBLIC wis::wisdom wis::wisdom-platform Catch2::Catch2WithMain) + target_link_libraries( + ${TEST_TARGET} PUBLIC wis::wisdom wis::wisdom-platform + Catch2::Catch2WithMain) else() - target_link_libraries(${TEST_TARGET} PUBLIC wis::wisdom-headers wis::wisdom-platform-headers Catch2::Catch2WithMain) + target_link_libraries( + ${TEST_TARGET} PUBLIC wis::wisdom-headers wis::wisdom-platform-headers + Catch2::Catch2WithMain) endif() set_target_properties( diff --git a/tests/basic/CMakeLists.txt b/tests/basic/CMakeLists.txt index 44554a0ab..28ed3dd08 100644 --- a/tests/basic/CMakeLists.txt +++ b/tests/basic/CMakeLists.txt @@ -8,4 +8,4 @@ if(WISDOM_VULKAN) wis_add_test(test-basic "${TEST_SOURCES}" "vk") endif() -target_sources(test-basic-vk PRIVATE "platform_check.cpp") \ No newline at end of file +target_sources(test-basic-vk PRIVATE "platform_check.cpp") diff --git a/tests/integration/cmake/CMakeLists.txt b/tests/integration/cmake/CMakeLists.txt index d91a906f9..efc6b77bb 100644 --- a/tests/integration/cmake/CMakeLists.txt +++ b/tests/integration/cmake/CMakeLists.txt @@ -13,4 +13,4 @@ target_link_libraries(TestAppShared PRIVATE wis::wisdom-shared) target_link_libraries(TestApp PRIVATE wis::wisdom) target_link_libraries(TestAppHeaders PRIVATE wis::wisdom-headers) -set_target_properties(TestAppHeaders PROPERTIES CXX_STANDARD 20) \ No newline at end of file +set_target_properties(TestAppHeaders PROPERTIES CXX_STANDARD 20) From dbe410b63a019db1f99e75ed1b5a5127ad1111e2 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 13 Sep 2026 17:07:36 +0000 Subject: [PATCH 06/11] Restyled by isort --- conanfile.py | 3 ++- test_package/conanfile.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index 176e51737..4a4622645 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,6 +1,7 @@ import os + from conan import ConanFile -from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain, CMakeDeps +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.files import copy, load diff --git a/test_package/conanfile.py b/test_package/conanfile.py index e6b7e763e..02d0d0387 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -1,7 +1,8 @@ import os + from conan import ConanFile -from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout class WisdomTestConan(ConanFile): From c94ff7369cc388a7f9e6bbb6e6d8ccb77086385e Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 13 Sep 2026 17:07:42 +0000 Subject: [PATCH 07/11] Restyled by prettier-json --- test_package/CMakeUserPresets.json | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test_package/CMakeUserPresets.json b/test_package/CMakeUserPresets.json index eafe17862..159166670 100644 --- a/test_package/CMakeUserPresets.json +++ b/test_package/CMakeUserPresets.json @@ -1,9 +1,7 @@ { - "version": 4, - "vendor": { - "conan": {} - }, - "include": [ - "build/msvc-195-x86_64-20-release/generators/CMakePresets.json" - ] -} \ No newline at end of file + "version": 4, + "vendor": { + "conan": {} + }, + "include": ["build/msvc-195-x86_64-20-release/generators/CMakePresets.json"] +} From 3cc4e36efc006e8c2f60c04de88b176653a94616 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 13 Sep 2026 17:07:45 +0000 Subject: [PATCH 08/11] Restyled by pyment --- conanfile.py | 11 +++++++++++ test_package/conanfile.py | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/conanfile.py b/conanfile.py index 4a4622645..f5a89c15c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -6,6 +6,7 @@ class WisdomConan(ConanFile): + """ """ name = "wisdom" package_type = "library" @@ -28,6 +29,7 @@ class WisdomConan(ConanFile): # keep it for now, but remove when we are at CCI def set_version(self): + """ """ version_file_path = os.path.join(self.recipe_folder, "version/VERSION") try: @@ -37,6 +39,7 @@ def set_version(self): self.version = "0.0.0" def requirements(self): + """ """ # If windows platform support is enabled, we need to require the D3D12 Memory Allocator if self.settings.os == "Windows": self.requires( @@ -45,6 +48,7 @@ def requirements(self): self.requires("vulkan-memory-allocator/3.3.0", transitive_headers=True) def export_sources(self): + """ """ copy( self, "*", @@ -66,17 +70,21 @@ def export_sources(self): ) def config_options(self): + """ """ if self.settings.os == "Windows": self.options.rm_safe("fPIC") def configure(self): + """ """ if self.options.shared: self.options.rm_safe("fPIC") def layout(self): + """ """ cmake_layout(self) def generate(self): + """ """ deps = CMakeDeps(self) deps.generate() @@ -103,15 +111,18 @@ def generate(self): tc.generate() def build(self): + """ """ cmake = CMake(self) cmake.configure() cmake.build() def package(self): + """ """ cmake = CMake(self) cmake.install() def package_info(self): + """ """ # The overarching file namespace (find_package(wisdom)) self.cpp_info.set_property("cmake_file_name", "Wisdom") diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 02d0d0387..2e9c8552c 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -6,16 +6,20 @@ class WisdomTestConan(ConanFile): + """ """ settings = "os", "compiler", "build_type", "arch" generators = "CMakeDeps" def requirements(self): + """ """ self.requires(self.tested_reference_str) def layout(self): + """ """ cmake_layout(self) def generate(self): + """ """ tc = CMakeToolchain(self) # Check if the wisdom package we are testing was built as shared is_shared = self.dependencies["wisdom"].options.shared @@ -24,11 +28,13 @@ def generate(self): tc.generate() def build(self): + """ """ cmake = CMake(self) cmake.configure() cmake.build() def test(self): + """ """ if can_run(self): cmd = os.path.join(self.cpp.build.bindir, "test_app") self.run(cmd, env="conanrun") From 5f894f297c2a95abb648071fc0e1f904550339cd Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 13 Sep 2026 17:07:49 +0000 Subject: [PATCH 09/11] Restyled by reorder-python-imports --- conanfile.py | 8 ++++++-- test_package/conanfile.py | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/conanfile.py b/conanfile.py index f5a89c15c..a3f839537 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,8 +1,12 @@ import os from conan import ConanFile -from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.files import copy, load +from conan.tools.cmake import CMake +from conan.tools.cmake import cmake_layout +from conan.tools.cmake import CMakeDeps +from conan.tools.cmake import CMakeToolchain +from conan.tools.files import copy +from conan.tools.files import load class WisdomConan(ConanFile): diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 2e9c8552c..e54327943 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -2,7 +2,9 @@ from conan import ConanFile from conan.tools.build import can_run -from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.cmake import CMake +from conan.tools.cmake import cmake_layout +from conan.tools.cmake import CMakeToolchain class WisdomTestConan(ConanFile): From f940ba7663e873de30ee2801b35b4b338086959f Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 13 Sep 2026 17:07:57 +0000 Subject: [PATCH 10/11] Restyled by whitespace --- .gitignore | 2 +- cmake/deps.cmake | 2 +- cmake/deps/deps_win.cmake | 4 +-- cmake/functions.cmake | 45 ++++++++++++++-------------- cmake/install/cpack-options.cmake | 2 +- cmake/install/nuget-prepare.cmake | 2 +- scripts/test-cmake.ps1 | 6 ++-- scripts/test-conan.ps1 | 2 +- scripts/test-nuget.ps1 | 2 +- tests/integration/nuget/nuget.config | 2 +- tests/integration/nuget/test.vcxproj | 4 +-- xml/enums.xml | 4 +-- xml/spec_template.xml | 12 ++++---- 13 files changed, 44 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index ad66106db..abc2d212d 100644 --- a/.gitignore +++ b/.gitignore @@ -376,4 +376,4 @@ FodyWeavers.xsd # Package artifacts /artifacts/ -/tests/integration/cmake/extracted/ \ No newline at end of file +/tests/integration/cmake/extracted/ diff --git a/cmake/deps.cmake b/cmake/deps.cmake index ddad3b00e..bb22e82b4 100644 --- a/cmake/deps.cmake +++ b/cmake/deps.cmake @@ -5,7 +5,7 @@ if(NOT WISDOM_USE_CONAN) set(CPM_DONT_UPDATE_MODULE_PATH ON) set(GET_CPM_FILE "${CMAKE_CURRENT_LIST_DIR}/deps/get_cpm.cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) - + # Set CPM source cache if (NOT CPM_SOURCE_CACHE) set(CPM_SOURCE_CACHE "${CMAKE_CURRENT_BINARY_DIR}/_deps_cache") diff --git a/cmake/deps/deps_win.cmake b/cmake/deps/deps_win.cmake index f051a0e5d..2f761521c 100644 --- a/cmake/deps/deps_win.cmake +++ b/cmake/deps/deps_win.cmake @@ -25,8 +25,8 @@ else() D3D12MA_USING_DIRECTX_HEADERS=1 ) - # Guaranteed backwards compatibility. - # Using origin/main to ensure we get the latest headers, + # Guaranteed backwards compatibility. + # Using origin/main to ensure we get the latest headers, # which are compatible with the latest SDKs. CPMAddPackage( NAME dxheaders diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 5ab99722a..6b775ea14 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -14,7 +14,7 @@ if (WIN32) TLS_VERIFY ON TLS_VERSION 1.2 ) - + # Check download status list(GET download_status 0 status_code) if (NOT status_code EQUAL 0) @@ -24,13 +24,13 @@ if (WIN32) message(STATUS "File downloaded successfully to ${FILE_PATH}") endif () endfunction(_ww_load_nuget) - + # Find NuGet executable function(_ww_find_nuget) if (NOT WISDOM_WINDOWS) return() endif () - + # Check provided with WISDOM_NUGET_PATH if (WISDOM_NUGET_PATH) find_program( @@ -56,20 +56,20 @@ if (WIN32) NUGET_EXE NAMES nuget PATHS ${CMAKE_CURRENT_BINARY_DIR}/NuGet) - + if (NOT NUGET_EXE) _ww_load_nuget() set(NUGET_EXE "${CMAKE_CURRENT_BINARY_DIR}/NuGet/NuGet.exe" CACHE INTERNAL "Path to NuGet.exe") endif () endfunction(_ww_find_nuget) - + # Load a NuGet dependency function(_ww_load_nuget_dependency NUGET PLUGIN_NAME ALIAS OUT_DIR) if (${ALIAS}_DIR) message("${ALIAS}_DIR already set, skipping download.") return() endif () - + execute_process(COMMAND ${NUGET} install "${PLUGIN_NAME}" -OutputDirectory ${OUT_DIR}) file(GLOB PLUGIN_DIRS ${OUT_DIR}/${PLUGIN_NAME}.*) list(LENGTH PLUGIN_DIRS PLUGIN_DIRS_L) @@ -77,7 +77,7 @@ if (WIN32) #Sort directories by version in descending order, so the first dir is top version list(SORT PLUGIN_DIRS COMPARE NATURAL ORDER DESCENDING) list(GET PLUGIN_DIRS 0 PLUGIN_DIRX) - + #Remove older version MATH(EXPR PLUGIN_DIRS_L "${PLUGIN_DIRS_L}-1") foreach (I RANGE 1 ${PLUGIN_DIRS_L}) @@ -87,7 +87,7 @@ if (WIN32) else () list(GET PLUGIN_DIRS 0 PLUGIN_DIRX) endif () - + set(${ALIAS}_DIR ${PLUGIN_DIRX} CACHE STRING "${PLUGIN_NAME} PATH" FORCE) endfunction(_ww_load_nuget_dependency) endif() @@ -100,8 +100,8 @@ function(_ww_load_latest_dxc) endif () set(DXC_API_FILE "${CMAKE_CURRENT_BINARY_DIR}/dxc_latest_api.json") - file(DOWNLOAD - "https://api.github.com/repos/microsoft/DirectXShaderCompiler/releases/latest" + file(DOWNLOAD + "https://api.github.com/repos/microsoft/DirectXShaderCompiler/releases/latest" "${DXC_API_FILE}" STATUS api_status ) @@ -135,7 +135,7 @@ function(_ww_load_latest_dxc) set(DXC_LINK ${DXC_LINUX_LINK}) endif () - + # Download DXC using CPM include(FetchContent) FetchContent_Declare( @@ -440,9 +440,9 @@ function(wis_load_agility_sdk) message("Setting up DirectX 12 Agility...") _ww_load_nuget_dependency(${NUGET_EXE} "Microsoft.Direct3D.D3D12" DXA ${CMAKE_CURRENT_BINARY_DIR}) - + string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)$" VERSION_MATCH ${DXA_DIR}) - + message("Agility version: ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") set(DXA_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3} @@ -450,7 +450,7 @@ function(wis_load_agility_sdk) set(VERSION_MINOR ${CMAKE_MATCH_2} CACHE INTERNAL "") - + set(DXA_HEADERS ${DXA_DIR}/build/native/include) set(DXA_SRC ${DXA_DIR}/build/native/src) set(DXA_BIN ${DXA_DIR}/build/native/bin/x64) @@ -460,19 +460,19 @@ function(wis_load_agility_sdk) set(DXAGILITY_DEBUG_DLL ${DXA_BIN}/d3d12SDKLayers.dll CACHE INTERNAL "") - + add_library(DX12AgilityCore MODULE IMPORTED GLOBAL) set_property(TARGET DX12AgilityCore PROPERTY IMPORTED_LOCATION ${DXAGILITY_DLL}) - + add_library(DX12AgilitySDKLayers MODULE IMPORTED GLOBAL) set_property(TARGET DX12AgilitySDKLayers PROPERTY IMPORTED_LOCATION ${DXAGILITY_DEBUG_DLL}) - + # Header interface library add_library(DX12Agility STATIC) add_library(wis::DX12Agility ALIAS DX12Agility) - + target_include_directories( DX12Agility SYSTEM BEFORE PUBLIC $ $ @@ -489,7 +489,7 @@ function(wis_load_agility_sdk) LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - + install( IMPORTED_RUNTIME_ARTIFACTS DX12AgilityCore @@ -500,9 +500,9 @@ function(wis_load_agility_sdk) LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}) - + install(DIRECTORY ${DXA_HEADERS}/ DESTINATION include/d3dx12) - + set_target_properties(DX12Agility PROPERTIES DX12SDKVER ${VERSION_MINOR} DEBUG_POSTFIX d @@ -585,9 +585,8 @@ function(wis_install_agility_win32) if (wis_install_agility_win32_PATCH_EXE) wis_patch_agility_executable( - ${wis_install_agility_win32_TARGET} + ${wis_install_agility_win32_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/export_agility.c ) endif() endfunction() - diff --git a/cmake/install/cpack-options.cmake b/cmake/install/cpack-options.cmake index 56c78d626..160a7b8d9 100644 --- a/cmake/install/cpack-options.cmake +++ b/cmake/install/cpack-options.cmake @@ -5,4 +5,4 @@ if(CPACK_GENERATOR MATCHES "NuGet") elseif(CPACK_GENERATOR MATCHES "ZIP") message(STATUS "Wisdom CPack: ZIP generator detected. Proceeding with standard layout.") # No pre-build script needed! The CMake folders stay intact. -endif() \ No newline at end of file +endif() diff --git a/cmake/install/nuget-prepare.cmake b/cmake/install/nuget-prepare.cmake index 47de9f26f..43cebf0ce 100644 --- a/cmake/install/nuget-prepare.cmake +++ b/cmake/install/nuget-prepare.cmake @@ -25,4 +25,4 @@ file(GLOB _wisdom_static_libs "${STAGING_DIR}/lib/*.lib") foreach(_lib IN LISTS _wisdom_static_libs) get_filename_component(_lib_name "${_lib}" NAME) file(RENAME "${_lib}" "${NUGET_NATIVE_LIB_DIR}/${_lib_name}") -endforeach() \ No newline at end of file +endforeach() diff --git a/scripts/test-cmake.ps1 b/scripts/test-cmake.ps1 index dccde17fa..f3b74a62b 100644 --- a/scripts/test-cmake.ps1 +++ b/scripts/test-cmake.ps1 @@ -48,10 +48,10 @@ if ($NoRun) { Write-Host "Skipping execution of Test App due to -NoRun flag..." -ForegroundColor Cyan } else { # 6. Run the compiled executable - # NOTE: Because it's a dynamic build, Windows needs to find wisdom-shared.dll. + # NOTE: Because it's a dynamic build, Windows needs to find wisdom-shared.dll. # We temporarily add the extracted /bin folder to the environment PATH just for this run. $env:PATH = "$($ExtractedRoot.FullName)\bin;$env:PATH" - + Write-Host "Running Test App..." & (Join-Path $CmakeBuildDir "Release\TestApp.exe") Write-Host "Running Test App..." @@ -61,4 +61,4 @@ if ($NoRun) { } -Write-Host "ZIP packaging completely validated!" -ForegroundColor Green \ No newline at end of file +Write-Host "ZIP packaging completely validated!" -ForegroundColor Green diff --git a/scripts/test-conan.ps1 b/scripts/test-conan.ps1 index 214be91fe..cea8a91aa 100644 --- a/scripts/test-conan.ps1 +++ b/scripts/test-conan.ps1 @@ -7,4 +7,4 @@ $BaseDir = Join-Path $ScriptDir "\.." conan create $BaseDir --build=missing # 2. Test Shared -conan create $BaseDir -o "wisdom/*:shared=True" \ No newline at end of file +conan create $BaseDir -o "wisdom/*:shared=True" diff --git a/scripts/test-nuget.ps1 b/scripts/test-nuget.ps1 index 8f37591bf..c0dff0e0c 100644 --- a/scripts/test-nuget.ps1 +++ b/scripts/test-nuget.ps1 @@ -60,4 +60,4 @@ foreach ($Linkage in $Linkages) { } } -Write-Host "`nNuGet packaging completely validated for v$WisdomVersion!" -ForegroundColor Green \ No newline at end of file +Write-Host "`nNuGet packaging completely validated for v$WisdomVersion!" -ForegroundColor Green diff --git a/tests/integration/nuget/nuget.config b/tests/integration/nuget/nuget.config index 0b8ca7620..df933c331 100644 --- a/tests/integration/nuget/nuget.config +++ b/tests/integration/nuget/nuget.config @@ -4,4 +4,4 @@ - \ No newline at end of file + diff --git a/tests/integration/nuget/test.vcxproj b/tests/integration/nuget/test.vcxproj index e55040989..fb3958016 100644 --- a/tests/integration/nuget/test.vcxproj +++ b/tests/integration/nuget/test.vcxproj @@ -23,7 +23,7 @@ Unicode - + @@ -45,4 +45,4 @@ - \ No newline at end of file + diff --git a/xml/enums.xml b/xml/enums.xml index c8156fa39..a9814d880 100644 --- a/xml/enums.xml +++ b/xml/enums.xml @@ -533,13 +533,13 @@ A two-plane format with a single 8-bit Y plane followed by an interleaved UV pla - + - + diff --git a/xml/spec_template.xml b/xml/spec_template.xml index 814616c87..6b56aa36a 100644 --- a/xml/spec_template.xml +++ b/xml/spec_template.xml @@ -3,24 +3,24 @@ - + - + - + - + - + - \ No newline at end of file + From fbe4b9727ba2f73de017de343d37f314f774704c Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 13 Sep 2026 17:08:00 +0000 Subject: [PATCH 11/11] Restyled by yapf --- conanfile.py | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/conanfile.py b/conanfile.py index a3f839537..eff317204 100644 --- a/conanfile.py +++ b/conanfile.py @@ -46,9 +46,8 @@ def requirements(self): """ """ # If windows platform support is enabled, we need to require the D3D12 Memory Allocator if self.settings.os == "Windows": - self.requires( - "d3d12-memory-allocator/[>=3.0.1 <4]", transitive_headers=True - ) + self.requires("d3d12-memory-allocator/[>=3.0.1 <4]", + transitive_headers=True) self.requires("vulkan-memory-allocator/3.3.0", transitive_headers=True) def export_sources(self): @@ -101,7 +100,8 @@ def generate(self): tc.variables["WISDOM_BUILD_EXAMPLES"] = False tc.variables["WISDOM_BUILD_TESTS"] = False tc.variables["WISDOM_BUILD_DOCS"] = False - tc.variables["WISDOM_BUILD_STATIC"] = not self.options.get_safe("shared") + tc.variables["WISDOM_BUILD_STATIC"] = not self.options.get_safe( + "shared") tc.variables["WISDOM_BUILD_SHARED"] = self.options.get_safe("shared") tc.variables["WISDOM_BUILD_PLATFORM"] = self.options.build_platform tc.variables["WISDOM_USE_AGILITY_SDK"] = False @@ -138,15 +138,13 @@ def package_info(self): if self.options.get_safe("shared"): # Core Shared self.cpp_info.components["core"].set_property( - "cmake_target_name", "wis::wisdom-shared" - ) + "cmake_target_name", "wis::wisdom-shared") self.cpp_info.components["core"].libs = [f"wisdom-shared{suffix}"] # Platform Shared if self.options.build_platform: self.cpp_info.components["platform"].set_property( - "cmake_target_name", "wis::wisdom-platform-shared" - ) + "cmake_target_name", "wis::wisdom-platform-shared") self.cpp_info.components["platform"].requires = ["core"] self.cpp_info.components["platform"].libs = [ f"wisdom-platform-shared{suffix}" @@ -154,29 +152,29 @@ def package_info(self): else: # Core Static self.cpp_info.components["core"].set_property( - "cmake_target_name", "wis::wisdom" - ) - self.cpp_info.components["core"].libs = [f"wisdom{suffix}", f"vkma{suffix}"] + "cmake_target_name", "wis::wisdom") + self.cpp_info.components["core"].libs = [ + f"wisdom{suffix}", f"vkma{suffix}" + ] # Platform Static if self.options.build_platform: self.cpp_info.components["platform"].set_property( - "cmake_target_name", "wis::wisdom-platform" - ) + "cmake_target_name", "wis::wisdom-platform") self.cpp_info.components["platform"].requires = ["core"] - self.cpp_info.components["platform"].libs = [f"wisdom-platform{suffix}"] + self.cpp_info.components["platform"].libs = [ + f"wisdom-platform{suffix}" + ] self.cpp_info.components["core"].requires = [ "vulkan-memory-allocator::vulkan-memory-allocator" ] if self.settings.os == "Windows": - self.cpp_info.components["core"].defines.extend( - [ - "D3D12MA_USING_DIRECTX_HEADERS=1", - "VK_USE_PLATFORM_WIN32_KHR=1", - ] - ) + self.cpp_info.components["core"].defines.extend([ + "D3D12MA_USING_DIRECTX_HEADERS=1", + "VK_USE_PLATFORM_WIN32_KHR=1", + ]) self.cpp_info.components["core"].requires.extend( - ["d3d12-memory-allocator::d3d12-memory-allocator"] - ) - self.cpp_info.components["core"].system_libs.extend(["dxgi", "DXGUID"]) + ["d3d12-memory-allocator::d3d12-memory-allocator"]) + self.cpp_info.components["core"].system_libs.extend( + ["dxgi", "DXGUID"])