-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathexport_test.go
More file actions
104 lines (83 loc) · 3.75 KB
/
Copy pathexport_test.go
File metadata and controls
104 lines (83 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//go:build !rust && !(js && wasm)
package wgpu
import (
"github.com/gogpu/gputypes"
"github.com/gogpu/wgpu/core"
)
// SetTestRequiredVertexBuffers sets the requiredVertexBuffers field for testing.
// This method is only available in test builds.
func (p *RenderPipeline) SetTestRequiredVertexBuffers(count uint32) {
p.requiredVertexBuffers = count
}
// TestRef returns the ResourceRef for a RenderPipeline (testing only).
func (p *RenderPipeline) TestRef() *core.ResourceRef { return p.ref }
// TestRef returns the ResourceRef for a ComputePipeline (testing only).
func (p *ComputePipeline) TestRef() *core.ResourceRef { return p.ref }
// TestRef returns the ResourceRef for a BindGroup (testing only).
func (g *BindGroup) TestRef() *core.ResourceRef { return g.ref }
// TestTrackedRefs returns the tracked refs of a CommandBuffer (testing only).
func (cb *CommandBuffer) TestTrackedRefs() []*core.ResourceRef { return cb.trackedRefs }
// TestTrackedRefs returns the tracked refs of a CommandEncoder (testing only).
func (e *CommandEncoder) TestTrackedRefs() []*core.ResourceRef { return e.trackedRefs }
// TestHALEncoder returns the HAL encoder reference on a CommandBuffer (testing only).
func (cb *CommandBuffer) TestHALEncoder() interface{} { return cb.halEncoder }
// TestCmdEncoderPoolSize returns the number of free encoders in the device's pool (testing only).
// Returns -1 if no pool is configured.
func (d *Device) TestCmdEncoderPoolSize() int {
if d.cmdEncoderPool == nil {
return -1
}
d.cmdEncoderPool.mu.Lock()
defer d.cmdEncoderPool.mu.Unlock()
return len(d.cmdEncoderPool.free)
}
// TestReleased returns true if the buffer has been released (testing only).
func (b *Buffer) TestReleased() bool {
if b.released == nil {
return false
}
return b.released.Load()
}
// TestDestroyQueue returns the device's DestroyQueue (testing only).
func (d *Device) TestDestroyQueue() *core.DestroyQueue {
return d.destroyQueue()
}
// TestResourceCounts returns resource counts from the global hub (testing only).
func (d *Device) TestResourceCounts() map[string]uint64 {
return core.GetGlobal().Stats()
}
// TestBindGroupReleased returns true if the bind group has been released (testing only).
func (g *BindGroup) TestBindGroupReleased() bool {
if g.released == nil {
return false
}
return g.released.Load()
}
// SetTestBindGroupLayouts sets the bindGroupLayouts field on a RenderPipeline for testing.
func (p *RenderPipeline) SetTestBindGroupLayouts(layouts []*BindGroupLayout) {
p.bindGroupLayouts = layouts
p.bindGroupCount = uint32(len(layouts))
}
// SetTestBindGroupLayouts sets the bindGroupLayouts field on a ComputePipeline for testing.
func (p *ComputePipeline) SetTestBindGroupLayouts(layouts []*BindGroupLayout) {
p.bindGroupLayouts = layouts
p.bindGroupCount = uint32(len(layouts))
}
// SetTestEntries sets the entries field on a BindGroupLayout for testing.
func (l *BindGroupLayout) SetTestEntries(entries []gputypes.BindGroupLayoutEntry) {
l.entries = entries
}
// SetTestLayout sets the layout field on a BindGroup for testing.
func (g *BindGroup) SetTestLayout(layout *BindGroupLayout) {
g.layout = layout
}
// SetTestStripIndexFormat sets the stripIndexFormat field on a RenderPipeline for testing.
// Pass nil for non-strip topologies, or a pointer to the expected IndexFormat for strip topologies.
func (p *RenderPipeline) SetTestStripIndexFormat(format *IndexFormat) {
p.stripIndexFormat = format
}
// TestMaintainAfterIdle exposes the private maintainAfterIdle for targeted coverage tests.
func (d *Device) TestMaintainAfterIdle() { d.maintainAfterIdle() }
// NewBareDeviceForTest returns a Device with no queue or HAL state (testing only).
// Used to exercise nil-queue guard clauses in maintainAfterIdle.
func NewBareDeviceForTest() *Device { return &Device{} }