/* * Copyright (C) 2017 Apple Inc. All rights reserved. * Copyright (C) 2017 Yuichiro Kikura (y.kikura@gmail.com) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ [ Conditional=WEBMETAL, EnabledAtRuntime=WebMetal, JSCustomMarkFunction, DoNotCheckConstants ] interface WebMetalRenderingContext { // back-reference to the canvas readonly attribute HTMLCanvasElement canvas; // Pixel formats const unsigned int PixelFormatBGRA8Unorm = 80; const unsigned int PixelFormatDepth32Float = 252; const unsigned int PixelFormatStencil8 = 253; const unsigned int PixelFormatInvalid = 0; // Load actions const unsigned int LoadActionDontCare = 0; const unsigned int LoadActionLoad = 1; const unsigned int LoadActionClear = 2; // Store actions const unsigned int StoreActionDontCare = 0; const unsigned int StoreActionStore = 1; const unsigned int StoreActionMultisampleResolve = 2; // Primitive types const unsigned int PrimitiveTypePoint = 0; const unsigned int PrimitiveTypeLine = 1; const unsigned int PrimitiveTypeLineStrip = 2; const unsigned int PrimitiveTypeTriangle = 3; const unsigned int PrimitiveTypeTriangleStrip = 4; // Comparison functions const unsigned int CompareFunctionNever = 0; const unsigned int CompareFunctionLess = 1; const unsigned int CompareFunctionEqual = 2; const unsigned int CompareFunctionLessEqual = 3; const unsigned int CompareFunctionGreater = 4; const unsigned int CompareFunctionNotEqual = 5; const unsigned int CompareFunctionGreaterEqual = 6; const unsigned int CompareFunctionAlways = 7; // Texture Types const unsigned int TextureType1D = 0; const unsigned int TextureType1DArray = 1; const unsigned int TextureType2D = 2; const unsigned int TextureType2DArray = 3; const unsigned int TextureType2DMultisample = 4; const unsigned int TextureTypeCube = 5; const unsigned int TextureTypeCubeArray = 6; const unsigned int TextureType3D = 7; // Storage modes const unsigned int StorageModeShared = 0; const unsigned int StorageModeManaged = 1; const unsigned int StorageModePrivate = 2; // Usage const unsigned int TextureUsageUnknown = 0x0000; const unsigned int TextureUsageShaderRead = 0x0001; const unsigned int TextureUsageShaderWrite = 0x0002; const unsigned int TextureUsageRenderTarget = 0x0004; const unsigned int TextureUsagePixelFormatView = 0x0010; // Entry points WebMetalLibrary createLibrary(DOMString sourceCode); WebMetalRenderPipelineState createRenderPipelineState(WebMetalRenderPipelineDescriptor descriptor); WebMetalDepthStencilState createDepthStencilState(WebMetalDepthStencilDescriptor descriptor); WebMetalComputePipelineState createComputePipelineState(WebMetalFunction function); WebMetalCommandQueue createCommandQueue(); WebMetalDrawable nextDrawable(); WebMetalBuffer? createBuffer(ArrayBufferView data); WebMetalTexture createTexture(WebMetalTextureDescriptor descriptor); };