Skip to content
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
2 changes: 0 additions & 2 deletions wgpu/adapter_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
)

func (g *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error) {
fmt.Println(pointerToJS(descriptor))
descriptor.toJS()
promise := g.jsValue.Call("requestDevice", pointerToJS(descriptor))

device, ok := jsx.Await(promise)
Expand Down
8 changes: 6 additions & 2 deletions wgpu/pipeline_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (g StencilFaceState) toJS() any {
// https://gpuweb.github.io/gpuweb/#dictdef-gpudepthstencilstate
type DepthStencilState struct {
Format TextureFormat
DepthWriteEnabled bool
DepthWriteEnabled OptionalBool
DepthCompare CompareFunction
StencilFront StencilFaceState
StencilBack StencilFaceState
Expand All @@ -123,7 +123,11 @@ type DepthStencilState struct {
func (g DepthStencilState) toJS() any {
result := make(map[string]any)
result["format"] = enumToJS(g.Format)
result["depthWriteEnabled"] = g.DepthWriteEnabled
if g.DepthWriteEnabled == OptionalBoolTrue {
result["depthWriteEnabled"] = true
} else if g.DepthWriteEnabled == OptionalBoolFalse {
result["depthWriteEnabled"] = false
}
result["depthCompare"] = enumToJS(g.DepthCompare)
result["stencilFront"] = g.StencilFront.toJS()
result["stencilBack"] = g.StencilBack.toJS()
Expand Down
18 changes: 12 additions & 6 deletions wgpu/to_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,23 @@ func (g *RenderPassColorAttachment) toJS() any {
}

func (g *RenderPassDepthStencilAttachment) toJS() any {
return map[string]any{
result := map[string]any{
"view": pointerToJS(g.View),
"depthLoadOp": enumToJS(g.DepthLoadOp),
"depthStoreOp": enumToJS(g.DepthStoreOp),
"depthClearValue": g.DepthClearValue,
"depthReadOnly": g.DepthReadOnly,
"stencilLoadOp": enumToJS(g.StencilLoadOp),
"stencilStoreOp": enumToJS(g.StencilStoreOp),
"stencilClearValue": g.StencilClearValue,
"depthReadOnly": g.DepthReadOnly,
"stencilReadOnly": g.StencilReadOnly,
}
// https://www.w3.org/TR/webgpu/#abstract-opdef-gpurenderpassdepthstencilattachment-gpurenderpassdepthstencilattachment-valid-usage
if !g.DepthReadOnly {
result["depthLoadOp"] = enumToJS(g.DepthLoadOp)
result["depthStoreOp"] = enumToJS(g.DepthStoreOp)
}
if !g.StencilReadOnly {
result["stencilLoadOp"] = enumToJS(g.StencilLoadOp)
result["stencilStoreOp"] = enumToJS(g.StencilStoreOp)
}
return result
}

func (g *RenderPipelineDescriptor) toJS() any {
Expand Down
Loading