Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions impeller/fixtures/dart_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void instantiateDefaultContext() {

@pragma('vm:entry-point')
void canEmplaceHostBuffer() {
final gpu.HostBuffer hostBuffer = gpu.HostBuffer(gpu.gpuContext);
final gpu.HostBuffer hostBuffer = gpu.gpuContext.createHostBuffer();

final gpu.BufferView view0 = hostBuffer
.emplace(Int8List.fromList(<int>[0, 1, 2, 3]).buffer.asByteData());
Expand Down Expand Up @@ -216,7 +216,7 @@ void uniformBindFailsForInvalidHostBufferOffset() {
final gpu.RenderPipeline pipeline = createUnlitRenderPipeline();
encoder.bindPipeline(pipeline);

final gpu.HostBuffer transients = gpu.HostBuffer(gpu.gpuContext);
final gpu.HostBuffer transients = gpu.gpuContext.createHostBuffer();
final gpu.BufferView vertInfoData = transients.emplace(float32(<double>[
1, 0, 0, 0, // mvp
0, 1, 0, 0, // mvp
Expand Down Expand Up @@ -262,7 +262,7 @@ void canCreateRenderPassAndSubmit() {
encoder.setColorBlendEnable(true);
encoder.setColorBlendEquation(gpu.ColorBlendEquation());

final gpu.HostBuffer transients = gpu.HostBuffer(gpu.gpuContext);
final gpu.HostBuffer transients = gpu.gpuContext.createHostBuffer();
final gpu.BufferView vertices = transients.emplace(float32(<double>[
-0.5, -0.5, //
0.5, 0.5, //
Expand Down
2 changes: 1 addition & 1 deletion lib/gpu/lib/src/buffer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ base class DeviceBuffer extends NativeFieldWrapperClass1 with Buffer {
/// and automatically inserts padding between emplaced data if necessary.
base class HostBuffer extends NativeFieldWrapperClass1 with Buffer {
/// Creates a new HostBuffer.
HostBuffer(GpuContext gpuContext) {
HostBuffer._initialize(GpuContext gpuContext) {
_initialize(gpuContext);
}

Expand Down
4 changes: 4 additions & 0 deletions lib/gpu/lib/src/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ base class GpuContext extends NativeFieldWrapperClass1 {
return result.isValid ? result : null;
}

HostBuffer createHostBuffer() {
return HostBuffer._initialize(this);
}

/// Allocates a new texture in GPU-resident memory.
///
/// Returns [null] if the [Texture] creation failed.
Expand Down