18#ifndef vtkWebGPUConfiguration_h
19#define vtkWebGPUConfiguration_h
25#include "vtkRenderingWebGPUModule.h"
31VTK_ABI_NAMESPACE_BEGIN
109 vtkSetMacro(Timeout,
double);
110 vtkGetMacro(Timeout,
double);
214 static std::size_t
Align(std::size_t value, std::size_t alignment);
275 WGPUBuffer
CreateBuffer(std::uint64_t sizeBytes, WGPUBufferUsage usage,
276 bool mappedAtCreation =
false,
const char* label =
nullptr);
284 void WriteBuffer(WGPUBuffer buffer, std::uint64_t offset,
const void* data, std::size_t sizeBytes,
285 const char* description =
nullptr);
291 WGPUTexture
CreateTexture(WGPUExtent3D extents, WGPUTextureDimension dimension,
292 WGPUTextureFormat format, WGPUTextureUsage usage,
int mipLevelCount = 1,
293 const char* label =
nullptr);
300 WGPUTextureView
CreateView(WGPUTexture texture, WGPUTextureViewDimension dimension,
301 WGPUTextureAspect aspect, WGPUTextureFormat format,
int baseMipLevel,
int mipLevelCount,
302 const char* label =
nullptr);
303 WGPUTextureView
CreateView(WGPUTexture texture,
const WGPUTextureViewDescriptor& viewDescriptor);
309 void WriteTexture(WGPUTexture texture, uint32_t bytesPerRow, uint32_t byteSize,
const void* data,
310 uint32_t srcOffset = 0, WGPUOrigin3D dstOffset = { 0, 0, 0 }, uint32_t dstMipLevel = 0,
311 const char* description =
nullptr);
346 std::unique_ptr<vtkWebGPUConfigurationInternals> Internals;
350 int ActiveBufferMapCount = 0;
361 bool InstanceRefHeld =
false;
a simple class to control print indentation
A compute pipeline is the orchestrator of a collection of compute passes.
vtkGetEnumMacro(PowerPreference, PowerPreferenceType)
Set/Get the power preference of the graphics adapter.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool IsMicrosoftGPUInUse()
Checks whether a particular vendor's GPU is in use.
vtkLogger::Verbosity GetGPUMemoryLogVerbosity()
Set/Get the log verbosity of messages that are emitted when data is uploaded to GPU memory.
bool IsBroadcomGPUInUse()
Checks whether a particular vendor's GPU is in use.
PowerPreferenceType
These enums have a one-one correspondence with the webgpu enums.
BackendType GetBackendInUse()
Get the backend in use.
vtkGetEnumMacro(Backend, BackendType)
Set/Get the graphics backend to use from the graphics adapter.
WGPUInstance GetInstance()
Get handles of the WGPU adapter/device/instance.
std::uint32_t GetAdapterDeviceID()
static std::size_t Align(std::size_t value, std::size_t alignment)
Adjusts a given value to the nearest multiple of the specified alignment.
~vtkWebGPUConfiguration() override
WGPUTexture CreateTexture(WGPUExtent3D extents, WGPUTextureDimension dimension, WGPUTextureFormat format, WGPUTextureUsage usage, int mipLevelCount=1, const char *label=nullptr)
Creates a WebGPU texture with the given device and returns it.
void IncrementActiveBufferMapCount()
Tracks the number of in-flight asynchronous buffer map (readback) operations.
friend class vtkWebGPUConfigurationInternals
static vtkWebGPUConfiguration * New()
void SetGPUMemoryLogVerbosity(vtkLogger::Verbosity verbosity)
Set/Get the log verbosity of messages that are emitted when data is uploaded to GPU memory.
static void SetDefaultTimeout(double)
Use this method to customize the default value for Timeout.
bool IsAppleGPUInUse()
Checks whether a particular vendor's GPU is in use.
int GetActiveBufferMapCount() const
Tracks the number of in-flight asynchronous buffer map (readback) operations.
WGPUBuffer CreateBuffer(const WGPUBufferDescriptor &bufferDescriptor)
Convenient methods used to create webgpu buffers.
vtkSetEnumMacro(Backend, BackendType)
Set/Get the graphics backend to use from the graphics adapter.
void WriteTexture(WGPUTexture texture, uint32_t bytesPerRow, uint32_t byteSize, const void *data, uint32_t srcOffset=0, WGPUOrigin3D dstOffset={ 0, 0, 0 }, uint32_t dstMipLevel=0, const char *description=nullptr)
Upload byteSize of data from the data pointer to the given texture, assuming bytesPerRow bytes of dat...
VTK_MAYSUSPEND bool Initialize()
Initializes the class.
std::string ReportCapabilities()
Print information of webgpu adapter and device to the output string.
void DeferBufferRelease(WGPUBuffer buffer)
Take over buffer's reference and release it once control has returned from the WebGPU implementation,...
WGPUTexture CreateTexture(const WGPUTextureDescriptor &textureDescriptor)
Creates a WebGPU texture with the given device and returns it.
bool IsAMDGPUInUse()
Checks whether a particular vendor's GPU is in use.
void DumpMemoryStatistics()
This method prints the information corresponding to all active WGPUBuffer and WGPUTexture objects to ...
void WriteBuffer(WGPUBuffer buffer, std::uint64_t offset, const void *data, std::size_t sizeBytes, const char *description=nullptr)
Convenient method used to write data into an existing buffer.
WGPUTextureView CreateView(WGPUTexture texture, const WGPUTextureViewDescriptor &viewDescriptor)
void Finalize()
Finalizes the class.
bool IsNVIDIAGPUInUse()
Checks whether a particular vendor's GPU is in use.
void DecrementActiveBufferMapCount()
Tracks the number of in-flight asynchronous buffer map (readback) operations.
void FinalizeDevice()
Destroys the WebGPU device and adapter without releasing the shared instance.
VTK_MAYSUSPEND void ProcessEvents()
Process events on the WGPUInstance.
vtkSetEnumMacro(PowerPreference, PowerPreferenceType)
Set/Get the power preference of the graphics adapter.
WGPUDevice GetDevice()
Get handles of the WGPU adapter/device/instance.
bool IsIntelGPUInUse()
Checks whether a particular vendor's GPU is in use.
bool IsARMGPUInUse()
Checks whether a particular vendor's GPU is in use.
WGPUBuffer CreateBuffer(std::uint64_t sizeBytes, WGPUBufferUsage usage, bool mappedAtCreation=false, const char *label=nullptr)
Convenient methods used to create webgpu buffers.
std::uint32_t GetAdapterVendorID()
Get the PCI vendor ID of the adapter and the system PCI ID of the device.
bool IsMesaGPUInUse()
Checks whether a particular vendor's GPU is in use.
WGPUTextureView CreateView(WGPUTexture texture, WGPUTextureViewDimension dimension, WGPUTextureAspect aspect, WGPUTextureFormat format, int baseMipLevel, int mipLevelCount, const char *label=nullptr)
Creates a texture view of a texture.
WGPUAdapter GetAdapter()
Get handles of the WGPU adapter/device/instance.
@ DeviceRequestCompletedEvent
@ AdapterRequestCompletedEvent
bool IsSamsungGPUInUse()
Checks whether a particular vendor's GPU is in use.
static std::string DeviceNotReadyMessage()
std::string GetBackendInUseAsString()
Convenient function returns a string representation of the currently used backend.