Skip to content

Commit

Permalink
Fix BeginRenderPass [depth|stencil|]l\LoadValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kangz authored and kainino0x committed Oct 2, 2019
1 parent 3c8c196 commit bade160
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/library_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,16 +649,20 @@ var LibraryWebGPU = {
{{{ gpu.makeCheck('descriptor !== 0') }}}

function makeColorAttachment(caPtr) {
let loadValue = WebGPU.LoadOp[
{{{ gpu.makeGetU32('caPtr', C_STRUCTS.DawnRenderPassColorAttachmentDescriptor.loadOp) }}}];
if (loadValue === 'clear') {
loadValue = WebGPU.makeColor(caPtr + {{{ C_STRUCTS.DawnRenderPassColorAttachmentDescriptor.clearColor }}});
}

return {
attachment: WebGPU.mgrTextureView.get(
{{{ gpu.makeGetU32('caPtr', C_STRUCTS.DawnRenderPassColorAttachmentDescriptor.attachment) }}}),
resolveTarget: WebGPU.mgrTextureView.get(
{{{ gpu.makeGetU32('caPtr', C_STRUCTS.DawnRenderPassColorAttachmentDescriptor.resolveTarget) }}}),
loadOp: WebGPU.LoadOp[
{{{ gpu.makeGetU32('caPtr', C_STRUCTS.DawnRenderPassColorAttachmentDescriptor.loadOp) }}}],
storeOp: WebGPU.StoreOp[
{{{ gpu.makeGetU32('caPtr', C_STRUCTS.DawnRenderPassColorAttachmentDescriptor.storeOp) }}}],
loadValue: WebGPU.makeColor(caPtr + {{{ C_STRUCTS.DawnRenderPassColorAttachmentDescriptor.clearColor }}}),
loadValue,
};
}

Expand All @@ -672,19 +676,28 @@ var LibraryWebGPU = {

function makeDepthStencilAttachment(dsaPtr) {
if (dsaPtr === 0) return undefined;

let depthLoadValue = WebGPU.LoadOp[
{{{ gpu.makeGetU32('dsaPtr', C_STRUCTS.DawnRenderPassDepthStencilAttachmentDescriptor.depthLoadOp) }}}];
if (depthLoadValue === 'clear') {
depthLoadValue = {{{ makeGetValue('dsaPtr', C_STRUCTS.DawnRenderPassDepthStencilAttachmentDescriptor.clearDepth, 'float') }}};
}

let stencilLoadValue = WebGPU.LoadOp[
{{{ gpu.makeGetU32('dsaPtr', C_STRUCTS.DawnRenderPassDepthStencilAttachmentDescriptor.stencilLoadOp) }}}];
if (stencilLoadValue === 'clear') {
stencilLoadValue = {{{ gpu.makeGetU32('dsaPtr', C_STRUCTS.DawnRenderPassDepthStencilAttachmentDescriptor.clearStencil) }}};
}

return {
attachment: WebGPU.mgrTextureView.get(
{{{ gpu.makeGetU32('dsaPtr', C_STRUCTS.DawnRenderPassDepthStencilAttachmentDescriptor.attachment) }}}),
depthLoadOp: WebGPU.LoadOp[
{{{ gpu.makeGetU32('dsaPtr', C_STRUCTS.DawnRenderPassDepthStencilAttachmentDescriptor.depthLoadOp) }}}],
depthStoreOp: WebGPU.StoreOp[
{{{ gpu.makeGetU32('dsaPtr', C_STRUCTS.DawnRenderPassDepthStencilAttachmentDescriptor.depthStoreOp) }}}],
depthLoadValue: {{{ makeGetValue('dsaPtr', C_STRUCTS.DawnRenderPassDepthStencilAttachmentDescriptor.clearDepth, 'float') }}},
stencilLoadOp: WebGPU.LoadOp[
{{{ gpu.makeGetU32('dsaPtr', C_STRUCTS.DawnRenderPassDepthStencilAttachmentDescriptor.stencilLoadOp) }}}],
depthLoadValue,
stencilStoreOp: WebGPU.StoreOp[
{{{ gpu.makeGetU32('dsaPtr', C_STRUCTS.DawnRenderPassDepthStencilAttachmentDescriptor.stencilStoreOp) }}}],
stencilLoadValue: {{{ gpu.makeGetU32('dsaPtr', C_STRUCTS.DawnRenderPassDepthStencilAttachmentDescriptor.clearStencil) }}},
stencilLoadValue,
};
}

Expand Down

0 comments on commit bade160

Please sign in to comment.