Skip to content

Commit

Permalink
Use inheritance for debug labels and add them to descriptors (gpuweb#227
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Kangz authored May 10, 2019
1 parent c9dd5af commit a5a5ea6
Showing 1 changed file with 53 additions and 81 deletions.
134 changes: 53 additions & 81 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ dictionary GPUExtent3D {
required u32 height;
required u32 depth;
};

interface GPUObjectBase {
DOMString? label;
};

dictionary GPUObjectDescriptorBase {
DOMString? label;
};
</script>

Buffers {#buffers}
Expand All @@ -61,12 +69,12 @@ interface GPUBufferUsage {
const u32 STORAGE = 128;
};

dictionary GPUBufferDescriptor {
dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
required u64 size;
required GPUBufferUsageFlags usage;
};

interface GPUBuffer {
interface GPUBuffer : GPUObjectBase {
Promise<ArrayBuffer> mapReadAsync();
Promise<ArrayBuffer> mapWriteAsync();
void unmap();
Expand Down Expand Up @@ -167,7 +175,7 @@ interface GPUTextureUsage {
const u32 OUTPUT_ATTACHMENT = 16;
};

dictionary GPUTextureDescriptor {
dictionary GPUTextureDescriptor : GPUObjectDescriptorBase {
required GPUExtent3D size;
u32 arrayLayerCount = 1;
u32 mipLevelCount = 1;
Expand All @@ -193,7 +201,7 @@ enum GPUTextureAspect {
"depth-only"
};

dictionary GPUTextureViewDescriptor {
dictionary GPUTextureViewDescriptor : GPUObjectDescriptorBase {
required GPUTextureFormat format;
required GPUTextureViewDimension dimension;
required GPUTextureAspect aspect;
Expand All @@ -203,10 +211,10 @@ dictionary GPUTextureViewDescriptor {
u32 arrayLayerCount = 1;
};

interface GPUTextureView {
interface GPUTextureView : GPUObjectBase {
};

interface GPUTexture {
interface GPUTexture : GPUObjectBase {
GPUTextureView createView(GPUTextureViewDescriptor desc);
GPUTextureView createDefaultView();

Expand Down Expand Up @@ -240,7 +248,7 @@ enum GPUCompareFunction {
"always"
};

dictionary GPUSamplerDescriptor {
dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase {
GPUAddressMode addressModeU = "clamp-to-edge";
GPUAddressMode addressModeV = "clamp-to-edge";
GPUAddressMode addressModeW = "clamp-to-edge";
Expand All @@ -252,7 +260,7 @@ dictionary GPUSamplerDescriptor {
GPUCompareFunction compareFunction = "never";
};

interface GPUSampler {
interface GPUSampler : GPUObjectBase {
};
</script>

Expand Down Expand Up @@ -285,18 +293,18 @@ dictionary GPUBindGroupLayoutBinding {
required GPUBindingType type;
};

dictionary GPUBindGroupLayoutDescriptor {
dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
required sequence<GPUBindGroupLayoutBinding> bindings;
};

interface GPUBindGroupLayout {
interface GPUBindGroupLayout : GPUObjectBase {
};

dictionary GPUPipelineLayoutDescriptor {
dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase {
required sequence<GPUBindGroupLayout> bindGroupLayouts;
};

interface GPUPipelineLayout {
interface GPUPipelineLayout : GPUObjectBase {
};

dictionary GPUBufferBinding {
Expand All @@ -312,12 +320,12 @@ dictionary GPUBindGroupBinding {
required GPUBindingResource resource;
};

dictionary GPUBindGroupDescriptor {
dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase {
required GPUBindGroupLayout layout;
required sequence<GPUBindGroupBinding> bindings;
};

interface GPUBindGroup {
interface GPUBindGroup : GPUObjectBase {
};
</script>

Expand All @@ -330,11 +338,11 @@ Shader Module {#shader}
// text and binary input.
typedef (ArrayBuffer or DOMString) ArrayBufferOrDOMString;

dictionary GPUShaderModuleDescriptor {
dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
required ArrayBufferOrDOMString code;
};

interface GPUShaderModule {
interface GPUShaderModule : GPUObjectBase {
};
</script>

Expand Down Expand Up @@ -531,7 +539,7 @@ dictionary GPUPipelineStageDescriptor {
// TODO other stuff like specialization constants?
};

dictionary GPUPipelineDescriptorBase {
dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase {
required GPUPipelineLayout layout;
};
</script>
Expand All @@ -544,7 +552,7 @@ dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
required GPUPipelineStageDescriptor computeStage;
};

interface GPUComputePipeline {
interface GPUComputePipeline : GPUObjectBase {
};
</script>

Expand Down Expand Up @@ -575,19 +583,24 @@ dictionary GPURenderPipelineDescriptor : GPUPipelineDescriptorBase {
// TODO other properties
};

interface GPURenderPipeline {
interface GPURenderPipeline : GPUObjectBase {
};
</script>

Command Recording {#command-recording}
======================================

<script type=idl>
interface GPUProgrammablePassEncoder {
interface GPUProgrammablePassEncoder : GPUObjectBase {
void endPass();

// Allowed in both compute and render passes
void setBindGroup(u32 index, GPUBindGroup bindGroup, optional sequence<u64> dynamicOffsets);

// Debugging assistance
void pushDebugGroup(DOMString groupLabel);
void popDebugGroup();
void insertDebugMarker(DOMString markerLabel);
};

interface GPURenderPassEncoder : GPUProgrammablePassEncoder {
Expand Down Expand Up @@ -649,11 +662,17 @@ dictionary GPURenderPassDepthStencilAttachmentDescriptor {
u32 clearStencil = 0;
};

dictionary GPURenderPassDescriptor {
dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase {
required sequence<GPURenderPassColorAttachmentDescriptor> colorAttachments;
GPURenderPassDepthStencilAttachmentDescriptor? depthStencilAttachment = null;
};

dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase {
};

dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
};

dictionary GPUBufferCopyView {
required GPUBuffer buffer;
u64 offset = 0;
Expand All @@ -668,12 +687,12 @@ dictionary GPUTextureCopyView {
GPUOrigin3D origin = {x: 0, y: 0, z: 0};
};

interface GPUCommandBuffer {
interface GPUCommandBuffer : GPUObjectBase {
};

interface GPUCommandEncoder {
interface GPUCommandEncoder : GPUObjectBase {
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
GPUComputePassEncoder beginComputePass();
GPUComputePassEncoder beginComputePass(GPUComputePassEncoder? descriptor);

// Commands allowed outside of "passes"
void copyBufferToBuffer(
Expand All @@ -698,10 +717,10 @@ interface GPUCommandEncoder {
GPUTextureCopyView destination,
GPUExtent3D copySize);

GPUCommandBuffer finish();
GPUCommandBuffer finish(GPUCommandBufferDescriptor? descriptor);
};

dictionary GPUCommandEncoderDescriptor {
dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
//TODO: reusability flag?
};
</script>
Expand All @@ -710,11 +729,11 @@ Fences {#fences}
================

<script type=idl>
dictionary GPUFenceDescriptor {
dictionary GPUFenceDescriptor : GPUObjectDescriptorBase {
u64 initialValue = 0;
};

interface GPUFence {
interface GPUFence : GPUObjectBase {
u64 getCompletedValue();
Promise<void> onCompletion(u64 completionValue);
};
Expand All @@ -724,7 +743,7 @@ Queues {#queues}
================

<script type=idl>
interface GPUQueue {
interface GPUQueue : GPUObjectBase {
void submit(sequence<GPUCommandBuffer> buffers);

GPUFence createFence(GPUFenceDescriptor descriptor);
Expand All @@ -744,13 +763,13 @@ interface GPUCanvasContext {
Promise<GPUTextureFormat> getSwapChainPreferredFormat(GPUDevice device);
}

dictionary GPUSwapChainDescriptor {
dictionary GPUSwapChainDescriptor : GPUObjectDescriptorBase {
required GPUDevice device;
required GPUTextureFormat format;
GPUTextureUsageFlags usage = GPUTextureUsage.OUTPUT_ATTACHMENT;
};

interface GPUSwapChain {
interface GPUSwapChain : GPUObjectBase {
GPUTexture getCurrentTexture();
};
</script>
Expand All @@ -768,7 +787,7 @@ dictionary GPULimits {
};

// Device
interface GPUDevice {
interface GPUDevice : GPUObjectBase {
readonly attribute GPUExtensions extensions;
readonly attribute GPULimits limits;
readonly attribute GPUAdapter adapter;
Expand All @@ -792,14 +811,14 @@ interface GPUDevice {
GPUQueue getQueue();
};

dictionary GPUDeviceDescriptor {
dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
GPUExtensions extensions;
GPULimits limits;

// TODO are other things configurable like queues?
};

interface GPUAdapter {
interface GPUAdapter : GPUObjectBase {
readonly attribute DOMString name;
readonly attribute GPUExtensions extensions;
//readonly attribute GPULimits limits; Don't expose higher limits for now.
Expand Down Expand Up @@ -899,50 +918,3 @@ partial interface GPUDevice : EventTarget {
attribute EventHandler onuncapturederror;
};
</script>

Debugging Assistance {#debugging}
=================================

<script type=idl>
partial interface GPUProgrammablePassEncoder {
void pushDebugGroup(DOMString groupLabel);
void popDebugGroup();
void insertDebugMarker(DOMString markerLabel);
};

interface mixin GPUDebugLabel {
attribute DOMString label;
};

GPUBindGroup includes GPUDebugLabel;
GPUBindGroupLayout includes GPUDebugLabel;
GPUBuffer includes GPUDebugLabel;
GPUCommandBuffer includes GPUDebugLabel;
GPUCommandEncoder includes GPUDebugLabel;
GPUComputePipeline includes GPUDebugLabel;
GPUFence includes GPUDebugLabel;
GPUPipelineLayout includes GPUDebugLabel;
GPUProgrammablePassEncoder includes GPUDebugLabel;
GPUQueue includes GPUDebugLabel;
GPURenderPipeline includes GPUDebugLabel;
GPUSampler includes GPUDebugLabel;
GPUShaderModule includes GPUDebugLabel;
GPUTexture includes GPUDebugLabel;
GPUTextureView includes GPUDebugLabel;

partial dictionary GPUCommandEncoderDescriptor {
DOMString label;
};

partial dictionary GPUFenceDescriptor {
DOMString label;
};

partial dictionary GPUPipelineDescriptorBase {
DOMString label;
};

partial dictionary GPUShaderModuleDescriptor {
DOMString label;
};
</script>

0 comments on commit a5a5ea6

Please sign in to comment.