From fffd2c70e62c86e1df07d9a83a1634578622236d Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sat, 18 May 2024 21:40:54 +0300 Subject: [PATCH] Update to wgpu-native v0.19.4.1 --- libs/wgpu/include/psemek/wgpu/external/wgpu.h | 19 +++++++++++++------ libs/wgpu/include/psemek/wgpu/surface.hpp | 6 ++++++ libs/wgpu/source/pipeline_layout.cpp | 2 +- libs/wgpu/source/render_pass_encoder.cpp | 2 +- libs/wgpu/source/surface.cpp | 9 +++++++++ 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/libs/wgpu/include/psemek/wgpu/external/wgpu.h b/libs/wgpu/include/psemek/wgpu/external/wgpu.h index d90e51b3..ce9c7589 100644 --- a/libs/wgpu/include/psemek/wgpu/external/wgpu.h +++ b/libs/wgpu/include/psemek/wgpu/external/wgpu.h @@ -14,6 +14,7 @@ typedef enum WGPUNativeSType { WGPUSType_BindGroupEntryExtras = 0x00030007, WGPUSType_BindGroupLayoutEntryExtras = 0x00030008, WGPUSType_QuerySetDescriptorExtras = 0x00030009, + WGPUSType_SurfaceConfigurationExtras = 0x0003000A, WGPUNativeSType_Force32 = 0x7FFFFFFF } WGPUNativeSType; @@ -26,6 +27,8 @@ typedef enum WGPUNativeFeature { WGPUNativeFeature_TextureBindingArray = 0x00030006, WGPUNativeFeature_SampledTextureAndStorageBufferArrayNonUniformIndexing = 0x00030007, WGPUNativeFeature_PipelineStatisticsQuery = 0x00030008, + WGPUNativeFeature_StorageResourceBindingArray = 0x00030009, + WGPUNativeFeature_PartiallyBoundBindingArray = 0x0003000A, WGPUNativeFeature_Force32 = 0x7FFFFFFF } WGPUNativeFeature; @@ -131,8 +134,8 @@ typedef struct WGPUPushConstantRange { typedef struct WGPUPipelineLayoutExtras { WGPUChainedStruct chain; - uint32_t pushConstantRangeCount; - WGPUPushConstantRange* pushConstantRanges; + size_t pushConstantRangeCount; + WGPUPushConstantRange const * pushConstantRanges; } WGPUPipelineLayoutExtras; typedef uint64_t WGPUSubmissionIndex; @@ -159,7 +162,6 @@ typedef struct WGPURegistryReport { size_t numAllocated; size_t numKeptFromUser; size_t numReleasedFromUser; - size_t numDestroyedFromUser; size_t numError; size_t elementSize; } WGPURegistryReport; @@ -218,6 +220,11 @@ typedef struct WGPUQuerySetDescriptorExtras { size_t pipelineStatisticCount; } WGPUQuerySetDescriptorExtras WGPU_STRUCTURE_ATTRIBUTE; +typedef struct WGPUSurfaceConfigurationExtras { + WGPUChainedStruct chain; + WGPUBool desiredMaximumFrameLatency; +} WGPUSurfaceConfigurationExtras WGPU_STRUCTURE_ATTRIBUTE; + typedef void (*WGPULogCallback)(WGPULogLevel level, char const * message, void * userdata); #ifdef __cplusplus @@ -225,12 +232,12 @@ extern "C" { #endif void wgpuGenerateReport(WGPUInstance instance, WGPUGlobalReport * report); -size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPUInstanceEnumerateAdapterOptions const * options, WGPUAdapter * adapters); +size_t wgpuInstanceEnumerateAdapters(WGPUInstance instance, WGPU_NULLABLE WGPUInstanceEnumerateAdapterOptions const * options, WGPUAdapter * adapters); WGPUSubmissionIndex wgpuQueueSubmitForIndex(WGPUQueue queue, size_t commandCount, WGPUCommandBuffer const * commands); // Returns true if the queue is empty, or false if there are more queue submissions still in flight. -WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex); +WGPUBool wgpuDevicePoll(WGPUDevice device, WGPUBool wait, WGPU_NULLABLE WGPUWrappedSubmissionIndex const * wrappedSubmissionIndex); void wgpuSetLogCallback(WGPULogCallback callback, void * userdata); @@ -238,7 +245,7 @@ void wgpuSetLogLevel(WGPULogLevel level); uint32_t wgpuGetVersion(void); -void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStageFlags stages, uint32_t offset, uint32_t sizeBytes, void* const data); +void wgpuRenderPassEncoderSetPushConstants(WGPURenderPassEncoder encoder, WGPUShaderStageFlags stages, uint32_t offset, uint32_t sizeBytes, void const * data); void wgpuRenderPassEncoderMultiDrawIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); void wgpuRenderPassEncoderMultiDrawIndexedIndirect(WGPURenderPassEncoder encoder, WGPUBuffer buffer, uint64_t offset, uint32_t count); diff --git a/libs/wgpu/include/psemek/wgpu/surface.hpp b/libs/wgpu/include/psemek/wgpu/surface.hpp index 3cd44682..70c03729 100644 --- a/libs/wgpu/include/psemek/wgpu/surface.hpp +++ b/libs/wgpu/include/psemek/wgpu/surface.hpp @@ -53,6 +53,11 @@ namespace psemek::wgpu std::uint32_t width; std::uint32_t height; surface::present_mode present_mode; + + struct extras + { + bool desired_maximum_frame_latency; + }; }; struct capabilities @@ -137,6 +142,7 @@ namespace psemek::wgpu friend struct instance; }; + detail::chained_struct_ptr to_chained_struct(surface::configuration::extras const & value); detail::chained_struct_ptr to_chained_struct(surface::from_android_native_window const & value); detail::chained_struct_ptr to_chained_struct(surface::from_canvas_html_selected const & value); detail::chained_struct_ptr to_chained_struct(surface::from_metal_layer const & value); diff --git a/libs/wgpu/source/pipeline_layout.cpp b/libs/wgpu/source/pipeline_layout.cpp index 03b20f0c..0ed0ea5e 100644 --- a/libs/wgpu/source/pipeline_layout.cpp +++ b/libs/wgpu/source/pipeline_layout.cpp @@ -26,7 +26,7 @@ namespace psemek::wgpu chained.chain.sType = (WGPUSType)WGPUSType_PipelineLayoutExtras; static_assert(sizeof(WGPUPushConstantRange) == sizeof(push_constant_range)); chained.pushConstantRangeCount = value.ranges.size(); - chained.pushConstantRanges = (WGPUPushConstantRange *)value.ranges.data(); + chained.pushConstantRanges = (WGPUPushConstantRange const *)value.ranges.data(); return detail::make_chained_struct(chained, std::move(value)); } diff --git a/libs/wgpu/source/render_pass_encoder.cpp b/libs/wgpu/source/render_pass_encoder.cpp index acc779e8..01f47cec 100644 --- a/libs/wgpu/source/render_pass_encoder.cpp +++ b/libs/wgpu/source/render_pass_encoder.cpp @@ -48,7 +48,7 @@ namespace psemek::wgpu void render_pass_encoder::set_push_constants(shader_stage stages, std::uint32_t offset, util::span data) { - wgpuRenderPassEncoderSetPushConstants((WGPURenderPassEncoder)get(), (WGPUShaderStageFlags)stages, offset, data.size(), (void *)data.data()); + wgpuRenderPassEncoderSetPushConstants((WGPURenderPassEncoder)get(), (WGPUShaderStageFlags)stages, offset, data.size(), data.data()); } void render_pass_encoder::draw(std::uint32_t vertex_count, std::uint32_t instance_count, std::uint32_t first_vertex, std::uint32_t first_instance) diff --git a/libs/wgpu/source/surface.cpp b/libs/wgpu/source/surface.cpp index e3a74901..091d7a08 100644 --- a/libs/wgpu/source/surface.cpp +++ b/libs/wgpu/source/surface.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace psemek::wgpu { @@ -72,6 +73,14 @@ namespace psemek::wgpu wgpuSurfaceRelease((WGPUSurface)ptr); } + detail::chained_struct_ptr to_chained_struct(surface::configuration::extras const & value) + { + WGPUSurfaceConfigurationExtras chained = {}; + chained.chain.sType = (WGPUSType)WGPUSType_SurfaceConfigurationExtras; + chained.desiredMaximumFrameLatency = value.desired_maximum_frame_latency; + return detail::make_chained_struct(chained); + } + detail::chained_struct_ptr to_chained_struct(surface::from_android_native_window const & value) { WGPUSurfaceDescriptorFromAndroidNativeWindow chained = {};