Skip to content

Enhancement to GPU APIs#3282

Open
daljit46 wants to merge 8 commits intodevfrom
gpu_enhancement
Open

Enhancement to GPU APIs#3282
daljit46 wants to merge 8 commits intodevfrom
gpu_enhancement

Conversation

@daljit46
Copy link
Member

This PR contains some small additions to the GPU API:

  • some extra logging for GPU selection.
  • Add way to select a GPU via an env variable.
  • Add support for copying textures.
  • Add support for downloading textures as MR::Image instances.

@daljit46 daljit46 self-assigned this Mar 20, 2026
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

SelectedAdapter request_adapter_by_index(const wgpu::InstanceDescriptor &instance_descriptor,
const wgpu::RequestAdapterOptions &adapter_options,
const uint32_t adapter_index) {
dawn::native::Instance dawn_instance(&instance_descriptor);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'dawn_instance' of type 'dawn::native::Instance' can be declared 'const' [misc-const-correctness]

Suggested change
dawn::native::Instance dawn_instance(&instance_descriptor);
dawn::native::Instance const dawn_instance(&instance_descriptor);

// Force the strides to match the memory layout written by download_texture:
// Channel (if present) is fastest, then X, then Y, then Z.
for (size_t i = 0; i < texture_dims; ++i) {
source_header.stride(i) = has_channel_axis ? i + 2 : i + 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'ssize_t' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]

    source_header.stride(i) = has_channel_axis ? i + 2 : i + 1;
                                                           ^

// Force the strides to match the memory layout written by download_texture:
// Channel (if present) is fastest, then X, then Y, then Z.
for (size_t i = 0; i < texture_dims; ++i) {
source_header.stride(i) = has_channel_axis ? i + 2 : i + 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'ssize_t' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]

    source_header.stride(i) = has_channel_axis ? i + 2 : i + 1;
                                                   ^

};
context.copy_texture_to_texture(src_texture, dst_texture, copy_info);

std::vector<float> downloaded_data(dst_initial.size(), 0.0F);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'downloaded_data' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<float> downloaded_data(dst_initial.size(), 0.0F);
std::vector<float> downloaded_data = 0(dst_initial.size(), 0.0F);

}
}

TEST_F(GPUTest, CopyTextureToTextureWithOffsetsOutOfRangeThrows) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: all parameters should be named in a function [readability-named-parameter]

Suggested change
TEST_F(GPUTest, CopyTextureToTextureWithOffsetsOutOfRangeThrows) {
TEST_F(GPUTest /*unused*/, CopyTextureToTextureWithOffsetsOutOfRangeThrows /*unused*/) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant