From 074cbb18ba5e3fda7add263c57b408ec49c13fb9 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Mon, 11 May 2026 13:47:21 +0300 Subject: [PATCH] Mark appropriate methods of wgpu wrappers as const --- libs/wgpu/include/psemek/wgpu/adapter.hpp | 8 ++++---- libs/wgpu/include/psemek/wgpu/buffer.hpp | 8 ++++---- libs/wgpu/include/psemek/wgpu/compute_pipeline.hpp | 2 +- libs/wgpu/include/psemek/wgpu/device.hpp | 8 ++++---- libs/wgpu/include/psemek/wgpu/query_set.hpp | 4 ++-- libs/wgpu/include/psemek/wgpu/render_pipeline.hpp | 2 +- libs/wgpu/include/psemek/wgpu/shader_module.hpp | 2 +- libs/wgpu/include/psemek/wgpu/surface.hpp | 4 ++-- libs/wgpu/include/psemek/wgpu/texture.hpp | 14 +++++++------- libs/wgpu/source/adapter.cpp | 8 ++++---- libs/wgpu/source/buffer.cpp | 8 ++++---- libs/wgpu/source/compute_pipeline.cpp | 2 +- libs/wgpu/source/device.cpp | 8 ++++---- libs/wgpu/source/query_set.cpp | 4 ++-- libs/wgpu/source/render_pipeline.cpp | 2 +- libs/wgpu/source/shader_module.cpp | 2 +- libs/wgpu/source/surface.cpp | 4 ++-- libs/wgpu/source/texture.cpp | 14 +++++++------- 18 files changed, 52 insertions(+), 52 deletions(-) diff --git a/libs/wgpu/include/psemek/wgpu/adapter.hpp b/libs/wgpu/include/psemek/wgpu/adapter.hpp index fc560ba3..3c42ea0a 100644 --- a/libs/wgpu/include/psemek/wgpu/adapter.hpp +++ b/libs/wgpu/include/psemek/wgpu/adapter.hpp @@ -84,10 +84,10 @@ namespace psemek::wgpu uint32_t device_id; }; - std::vector enumerate_features(); - limits get_limits(); - info get_info(); - bool has_feature(feature feature); + std::vector enumerate_features() const; + limits get_limits() const; + info get_info() const; + bool has_feature(feature feature) const; void request_device(callback_mode mode, device::descriptor const & descriptor, device::request_callback const & callback); static void reference(void * ptr); diff --git a/libs/wgpu/include/psemek/wgpu/buffer.hpp b/libs/wgpu/include/psemek/wgpu/buffer.hpp index ba0ded37..05907648 100644 --- a/libs/wgpu/include/psemek/wgpu/buffer.hpp +++ b/libs/wgpu/include/psemek/wgpu/buffer.hpp @@ -65,10 +65,10 @@ namespace psemek::wgpu using map_callback = std::function; void destroy(); - std::uint64_t get_size(); - usage get_usage(); - map_state get_map_state(); - void const * get_const_mapped_range(std::size_t offset, std::size_t size); + std::uint64_t get_size() const; + usage get_usage() const; + map_state get_map_state() const; + void const * get_const_mapped_range(std::size_t offset, std::size_t size) const; void * get_mapped_range(std::size_t offset, std::size_t size); void map_async(callback_mode mode, map_mode flags, std::size_t offset, std::size_t size, map_callback const & callback); void unmap(); diff --git a/libs/wgpu/include/psemek/wgpu/compute_pipeline.hpp b/libs/wgpu/include/psemek/wgpu/compute_pipeline.hpp index c0b5cc0c..6f7929e2 100644 --- a/libs/wgpu/include/psemek/wgpu/compute_pipeline.hpp +++ b/libs/wgpu/include/psemek/wgpu/compute_pipeline.hpp @@ -34,7 +34,7 @@ namespace psemek::wgpu programmable_stage_descriptor compute; }; - bind_group_layout get_bind_group_layout(std::uint32_t index); + bind_group_layout get_bind_group_layout(std::uint32_t index) const; void set_label(std::string const & label); static void reference(void * ptr); diff --git a/libs/wgpu/include/psemek/wgpu/device.hpp b/libs/wgpu/include/psemek/wgpu/device.hpp index d9f58549..c842812a 100644 --- a/libs/wgpu/include/psemek/wgpu/device.hpp +++ b/libs/wgpu/include/psemek/wgpu/device.hpp @@ -198,7 +198,7 @@ namespace psemek::wgpu using pop_error_callback = std::function; using error_callback = std::function; - queue get_queue(); + queue get_queue() const; bind_group create_bind_group(bind_group::descriptor const & desc); bind_group_layout create_bind_group_layout(bind_group_layout::descriptor const & desc); buffer create_buffer(buffer::descriptor const & desc); @@ -214,9 +214,9 @@ namespace psemek::wgpu shader_module create_shader_module(shader_module::descriptor const & desc); texture create_texture(texture::descriptor const & desc); void destroy(); - std::vector enumerate_features(); - limits get_limits(); - bool has_feature(feature feature); + std::vector enumerate_features() const; + limits get_limits() const; + bool has_feature(feature feature) const; void push_error_scope(error_filter filter); void pop_error_scope(callback_mode mode, pop_error_callback const & callback); void set_label(std::string const & label); diff --git a/libs/wgpu/include/psemek/wgpu/query_set.hpp b/libs/wgpu/include/psemek/wgpu/query_set.hpp index 98fb15fe..e5e9bbd5 100644 --- a/libs/wgpu/include/psemek/wgpu/query_set.hpp +++ b/libs/wgpu/include/psemek/wgpu/query_set.hpp @@ -29,8 +29,8 @@ namespace psemek::wgpu }; void destroy(); - std::uint32_t get_count(); - type get_type(); + std::uint32_t get_count() const; + type get_type() const; void set_label(std::string const & label); static void reference(void * ptr); diff --git a/libs/wgpu/include/psemek/wgpu/render_pipeline.hpp b/libs/wgpu/include/psemek/wgpu/render_pipeline.hpp index 5e0fd167..e335f529 100644 --- a/libs/wgpu/include/psemek/wgpu/render_pipeline.hpp +++ b/libs/wgpu/include/psemek/wgpu/render_pipeline.hpp @@ -280,7 +280,7 @@ namespace psemek::wgpu std::optional fragment = {}; }; - bind_group_layout get_bind_group_layout(std::uint32_t index); + bind_group_layout get_bind_group_layout(std::uint32_t index) const; void set_label(std::string const & label); static void reference(void * ptr); diff --git a/libs/wgpu/include/psemek/wgpu/shader_module.hpp b/libs/wgpu/include/psemek/wgpu/shader_module.hpp index 64b01467..abc158be 100644 --- a/libs/wgpu/include/psemek/wgpu/shader_module.hpp +++ b/libs/wgpu/include/psemek/wgpu/shader_module.hpp @@ -83,7 +83,7 @@ namespace psemek::wgpu using compilation_info_callback = std::function; - void get_compilation_info(callback_mode mode, compilation_info_callback const & callback); + void get_compilation_info(callback_mode mode, compilation_info_callback const & callback) const; void set_label(std::string const & label); static void reference(void * ptr); diff --git a/libs/wgpu/include/psemek/wgpu/surface.hpp b/libs/wgpu/include/psemek/wgpu/surface.hpp index 7c35fba5..44a7cc7d 100644 --- a/libs/wgpu/include/psemek/wgpu/surface.hpp +++ b/libs/wgpu/include/psemek/wgpu/surface.hpp @@ -89,8 +89,8 @@ namespace psemek::wgpu }; void configure(configuration const & conf); - capabilities get_capabilities(adapter const & adapter); - current_texture get_current_texture(); + capabilities get_capabilities(adapter const & adapter) const; + current_texture get_current_texture() const; void present(); void unconfigure(); diff --git a/libs/wgpu/include/psemek/wgpu/texture.hpp b/libs/wgpu/include/psemek/wgpu/texture.hpp index e53588da..ed5a6006 100644 --- a/libs/wgpu/include/psemek/wgpu/texture.hpp +++ b/libs/wgpu/include/psemek/wgpu/texture.hpp @@ -181,13 +181,13 @@ namespace psemek::wgpu texture_view create_view(texture_view::descriptor const & desc); void destroy(); - std::uint32_t get_width(); - std::uint32_t get_height(); - std::uint32_t get_depth(); - dimension get_dimension(); - format get_format(); - std::uint32_t get_mip_level_count(); - usage get_usage(); + std::uint32_t get_width() const; + std::uint32_t get_height() const; + std::uint32_t get_depth() const; + dimension get_dimension() const; + format get_format() const; + std::uint32_t get_mip_level_count() const; + usage get_usage() const; void set_label(std::string const & label); static void reference(void * ptr); diff --git a/libs/wgpu/source/adapter.cpp b/libs/wgpu/source/adapter.cpp index 5476b437..33c687b3 100644 --- a/libs/wgpu/source/adapter.cpp +++ b/libs/wgpu/source/adapter.cpp @@ -8,14 +8,14 @@ namespace psemek::wgpu { - std::vector adapter::enumerate_features() + std::vector adapter::enumerate_features() const { WGPUSupportedFeatures supported_features; wgpuAdapterGetFeatures((WGPUAdapter)get(), &supported_features); return std::vector((feature const *)supported_features.features, (feature const *)(supported_features.features) + supported_features.featureCount); } - limits adapter::get_limits() + limits adapter::get_limits() const { WGPULimits limits = {}; detail::check_status("wgpuAdapterGetLimits", wgpuAdapterGetLimits((WGPUAdapter)get(), &limits)); @@ -57,7 +57,7 @@ namespace psemek::wgpu return result; } - adapter::info adapter::get_info() + adapter::info adapter::get_info() const { WGPUAdapterInfo info; detail::check_status("wgpuAdapterGetInfo", wgpuAdapterGetInfo((WGPUAdapter)get(), &info)); @@ -74,7 +74,7 @@ namespace psemek::wgpu }; } - bool adapter::has_feature(feature feature) + bool adapter::has_feature(feature feature) const { return wgpuAdapterHasFeature((WGPUAdapter)get(), (WGPUFeatureName)feature); } diff --git a/libs/wgpu/source/buffer.cpp b/libs/wgpu/source/buffer.cpp index ff6ec097..ffe72bd3 100644 --- a/libs/wgpu/source/buffer.cpp +++ b/libs/wgpu/source/buffer.cpp @@ -12,22 +12,22 @@ namespace psemek::wgpu wgpuBufferDestroy((WGPUBuffer)get()); } - std::uint64_t buffer::get_size() + std::uint64_t buffer::get_size() const { return wgpuBufferGetSize((WGPUBuffer)get()); } - buffer::usage buffer::get_usage() + buffer::usage buffer::get_usage() const { return (usage)wgpuBufferGetUsage((WGPUBuffer)get()); } - buffer::map_state buffer::get_map_state() + buffer::map_state buffer::get_map_state() const { return (map_state)wgpuBufferGetMapState((WGPUBuffer)get()); } - void const * buffer::get_const_mapped_range(std::size_t offset, std::size_t size) + void const * buffer::get_const_mapped_range(std::size_t offset, std::size_t size) const { return wgpuBufferGetConstMappedRange((WGPUBuffer)get(), offset, size); } diff --git a/libs/wgpu/source/compute_pipeline.cpp b/libs/wgpu/source/compute_pipeline.cpp index 178723ad..a6c1bc4e 100644 --- a/libs/wgpu/source/compute_pipeline.cpp +++ b/libs/wgpu/source/compute_pipeline.cpp @@ -5,7 +5,7 @@ namespace psemek::wgpu { - bind_group_layout compute_pipeline::get_bind_group_layout(std::uint32_t index) + bind_group_layout compute_pipeline::get_bind_group_layout(std::uint32_t index) const { return bind_group_layout(wgpuComputePipelineGetBindGroupLayout((WGPUComputePipeline)get(), index)); } diff --git a/libs/wgpu/source/device.cpp b/libs/wgpu/source/device.cpp index cf581e1f..808bbb53 100644 --- a/libs/wgpu/source/device.cpp +++ b/libs/wgpu/source/device.cpp @@ -9,7 +9,7 @@ namespace psemek::wgpu { - queue device::get_queue() + queue device::get_queue() const { return queue(wgpuDeviceGetQueue((WGPUDevice)get())); } @@ -381,7 +381,7 @@ namespace psemek::wgpu wgpuDeviceDestroy((WGPUDevice)get()); } - std::vector device::enumerate_features() + std::vector device::enumerate_features() const { WGPUSupportedFeatures supported_features; wgpuDeviceGetFeatures((WGPUDevice)get(), &supported_features); @@ -391,7 +391,7 @@ namespace psemek::wgpu return result; } - limits device::get_limits() + limits device::get_limits() const { WGPULimits limits = {}; detail::check_status("wgpuDeviceGetLimits", wgpuDeviceGetLimits((WGPUDevice)get(), &limits)); @@ -433,7 +433,7 @@ namespace psemek::wgpu return result; } - bool device::has_feature(feature feature) + bool device::has_feature(feature feature) const { return wgpuDeviceHasFeature((WGPUDevice)get(), (WGPUFeatureName)feature); } diff --git a/libs/wgpu/source/query_set.cpp b/libs/wgpu/source/query_set.cpp index f778ddc6..a06843b1 100644 --- a/libs/wgpu/source/query_set.cpp +++ b/libs/wgpu/source/query_set.cpp @@ -10,12 +10,12 @@ namespace psemek::wgpu wgpuQuerySetDestroy((WGPUQuerySet)get()); } - std::uint32_t query_set::get_count() + std::uint32_t query_set::get_count() const { return wgpuQuerySetGetCount((WGPUQuerySet)get()); } - query_set::type query_set::get_type() + query_set::type query_set::get_type() const { return (type)wgpuQuerySetGetType((WGPUQuerySet)get()); } diff --git a/libs/wgpu/source/render_pipeline.cpp b/libs/wgpu/source/render_pipeline.cpp index 0d47c148..875e35a7 100644 --- a/libs/wgpu/source/render_pipeline.cpp +++ b/libs/wgpu/source/render_pipeline.cpp @@ -5,7 +5,7 @@ namespace psemek::wgpu { - bind_group_layout render_pipeline::get_bind_group_layout(std::uint32_t index) + bind_group_layout render_pipeline::get_bind_group_layout(std::uint32_t index) const { return bind_group_layout(wgpuRenderPipelineGetBindGroupLayout((WGPURenderPipeline)get(), index)); } diff --git a/libs/wgpu/source/shader_module.cpp b/libs/wgpu/source/shader_module.cpp index 8dcceee1..14637f9e 100644 --- a/libs/wgpu/source/shader_module.cpp +++ b/libs/wgpu/source/shader_module.cpp @@ -8,7 +8,7 @@ namespace psemek::wgpu { - void shader_module::get_compilation_info(callback_mode mode, compilation_info_callback const & callback) + void shader_module::get_compilation_info(callback_mode mode, compilation_info_callback const & callback) const { WGPUCompilationInfoCallbackInfo callback_info = {}; callback_info.mode = (WGPUCallbackMode)mode; diff --git a/libs/wgpu/source/surface.cpp b/libs/wgpu/source/surface.cpp index da24425c..19e272b3 100644 --- a/libs/wgpu/source/surface.cpp +++ b/libs/wgpu/source/surface.cpp @@ -25,7 +25,7 @@ namespace psemek::wgpu wgpuSurfaceConfigure((WGPUSurface)get(), &config); } - surface::capabilities surface::get_capabilities(adapter const & adapter) + surface::capabilities surface::get_capabilities(adapter const & adapter) const { WGPUSurfaceCapabilities caps = {}; detail::check_status("wgpuSurfaceGetCapabilities", wgpuSurfaceGetCapabilities((WGPUSurface)get(), (WGPUAdapter)adapter.get(), &caps)); @@ -42,7 +42,7 @@ namespace psemek::wgpu return result; } - surface::current_texture surface::get_current_texture() + surface::current_texture surface::get_current_texture() const { WGPUSurfaceTexture tex; wgpuSurfaceGetCurrentTexture((WGPUSurface)get(), &tex); diff --git a/libs/wgpu/source/texture.cpp b/libs/wgpu/source/texture.cpp index 6186fa56..9d7315ae 100644 --- a/libs/wgpu/source/texture.cpp +++ b/libs/wgpu/source/texture.cpp @@ -26,37 +26,37 @@ namespace psemek::wgpu wgpuTextureDestroy((WGPUTexture)get()); } - std::uint32_t texture::get_width() + std::uint32_t texture::get_width() const { return wgpuTextureGetWidth((WGPUTexture)get()); } - std::uint32_t texture::get_height() + std::uint32_t texture::get_height() const { return wgpuTextureGetHeight((WGPUTexture)get()); } - std::uint32_t texture::get_depth() + std::uint32_t texture::get_depth() const { return wgpuTextureGetDepthOrArrayLayers((WGPUTexture)get()); } - texture::dimension texture::get_dimension() + texture::dimension texture::get_dimension() const { return (dimension)wgpuTextureGetDimension((WGPUTexture)get()); } - texture::format texture::get_format() + texture::format texture::get_format() const { return (format)wgpuTextureGetFormat((WGPUTexture)get()); } - std::uint32_t texture::get_mip_level_count() + std::uint32_t texture::get_mip_level_count() const { return wgpuTextureGetMipLevelCount((WGPUTexture)get()); } - texture::usage texture::get_usage() + texture::usage texture::get_usage() const { return (usage)wgpuTextureGetUsage((WGPUTexture)get()); }