79 lines
2 KiB
C++
79 lines
2 KiB
C++
#include <psemek/wgpu/texture.hpp>
|
|
#include <psemek/wgpu/detail/string_view.hpp>
|
|
#include <psemek/wgpu/external/webgpu.h>
|
|
|
|
namespace psemek::wgpu
|
|
{
|
|
|
|
texture_view texture::create_view(texture_view::descriptor const & desc)
|
|
{
|
|
WGPUTextureViewDescriptor descriptor = {};
|
|
descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain);
|
|
descriptor.label = detail::to_string_view(desc.label);
|
|
descriptor.format = (WGPUTextureFormat)desc.format;
|
|
descriptor.dimension = (WGPUTextureViewDimension)desc.dimension;
|
|
descriptor.baseMipLevel = desc.base_mip_level;
|
|
descriptor.mipLevelCount = desc.mip_level_count;
|
|
descriptor.baseArrayLayer = desc.base_array_layer;
|
|
descriptor.arrayLayerCount = desc.array_layer_count;
|
|
descriptor.aspect = (WGPUTextureAspect)desc.aspect;
|
|
|
|
return texture_view(wgpuTextureCreateView((WGPUTexture)get(), &descriptor));
|
|
}
|
|
|
|
void texture::destroy()
|
|
{
|
|
wgpuTextureDestroy((WGPUTexture)get());
|
|
}
|
|
|
|
std::uint32_t texture::get_width() const
|
|
{
|
|
return wgpuTextureGetWidth((WGPUTexture)get());
|
|
}
|
|
|
|
std::uint32_t texture::get_height() const
|
|
{
|
|
return wgpuTextureGetHeight((WGPUTexture)get());
|
|
}
|
|
|
|
std::uint32_t texture::get_depth() const
|
|
{
|
|
return wgpuTextureGetDepthOrArrayLayers((WGPUTexture)get());
|
|
}
|
|
|
|
texture::dimension texture::get_dimension() const
|
|
{
|
|
return (dimension)wgpuTextureGetDimension((WGPUTexture)get());
|
|
}
|
|
|
|
texture::format texture::get_format() const
|
|
{
|
|
return (format)wgpuTextureGetFormat((WGPUTexture)get());
|
|
}
|
|
|
|
std::uint32_t texture::get_mip_level_count() const
|
|
{
|
|
return wgpuTextureGetMipLevelCount((WGPUTexture)get());
|
|
}
|
|
|
|
texture::usage texture::get_usage() const
|
|
{
|
|
return (usage)wgpuTextureGetUsage((WGPUTexture)get());
|
|
}
|
|
|
|
void texture::set_label(std::string const & label)
|
|
{
|
|
wgpuTextureSetLabel((WGPUTexture)get(), detail::to_string_view(label));
|
|
}
|
|
|
|
void texture::reference(void * ptr)
|
|
{
|
|
wgpuTextureAddRef((WGPUTexture)ptr);
|
|
}
|
|
|
|
void texture::release(void * ptr)
|
|
{
|
|
wgpuTextureRelease((WGPUTexture)ptr);
|
|
}
|
|
|
|
}
|