-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto gen update #166
base: main
Are you sure you want to change the base?
Auto gen update #166
Conversation
Just using regexes to keep it simple. Hopefully it's not too brittle.
interface GPUTexelCopyBufferInfo | ||
extends GPUTexelCopyBufferLayout { | ||
/** | ||
* A buffer which either contains texel data to be copied or will store the texel data being | ||
* copied, depending on the method it is being passed to. | ||
*/ | ||
buffer: GPUBuffer; | ||
} | ||
|
||
interface GPUTexelCopyBufferLayout { | ||
/** | ||
* The offset, in bytes, from the beginning of the texel data source (such as a | ||
* {@link GPUTexelCopyBufferInfo#buffer|GPUTexelCopyBufferInfo.buffer}) to the start of the texel data | ||
* within that source. | ||
*/ | ||
offset?: GPUSize64; | ||
/** | ||
* The stride, in bytes, between the beginning of each texel block row and the subsequent | ||
* texel block row. | ||
* Required if there are multiple texel block rows (i.e. the copy height or depth is more | ||
* than one block). | ||
*/ | ||
bytesPerRow?: GPUSize32; | ||
/** | ||
* Number of texel block rows per single texel image of the texture. | ||
* {@link GPUTexelCopyBufferLayout#rowsPerImage} × | ||
* {@link GPUTexelCopyBufferLayout#bytesPerRow} is the stride, in bytes, between the beginning of each | ||
* texel image of data and the subsequent texel image. | ||
* Required if there are multiple texel images (i.e. the copy depth is more than one). | ||
*/ | ||
rowsPerImage?: GPUSize32; | ||
} | ||
|
||
interface GPUTexelCopyTextureInfo { | ||
/** | ||
* Texture to copy to/from. | ||
*/ | ||
texture: GPUTexture; | ||
/** | ||
* Mip-map level of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from. | ||
*/ | ||
mipLevel?: GPUIntegerCoordinate; | ||
/** | ||
* Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. | ||
* Together with `copySize`, defines the full copy sub-region. | ||
*/ | ||
origin?: GPUOrigin3D; | ||
/** | ||
* Defines which aspects of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from. | ||
*/ | ||
aspect?: GPUTextureAspect; | ||
} | ||
|
||
interface GPUCopyExternalImageDestInfo | ||
extends GPUTexelCopyTextureInfo { | ||
/** | ||
* Describes the color space and encoding used to encode data into the destination texture. | ||
* This [[#color-space-conversions|may result]] in values outside of the range [0, 1] | ||
* being written to the target texture, if its format can represent them. | ||
* Otherwise, the results are clamped to the target texture format's range. | ||
* Note: | ||
* If {@link GPUCopyExternalImageDestInfo#colorSpace} matches the source image, | ||
* conversion may not be necessary. See [[#color-space-conversion-elision]]. | ||
*/ | ||
colorSpace?: PredefinedColorSpace; | ||
/** | ||
* Describes whether the data written into the texture should have its RGB channels | ||
* premultiplied by the alpha channel, or not. | ||
* If this option is set to `true` and the {@link GPUCopyExternalImageSourceInfo#source} is also | ||
* premultiplied, the source RGB values must be preserved even if they exceed their | ||
* corresponding alpha values. | ||
* Note: | ||
* If {@link GPUCopyExternalImageDestInfo#premultipliedAlpha} matches the source image, | ||
* conversion may not be necessary. See [[#color-space-conversion-elision]]. | ||
*/ | ||
premultipliedAlpha?: boolean; | ||
} | ||
|
||
interface GPUCopyExternalImageSourceInfo { | ||
/** | ||
* The source of the texel copy. The copy source data is captured at the moment that | ||
* {@link GPUQueue#copyExternalImageToTexture} is issued. Source size is determined as described | ||
* by the external source dimensions table. | ||
*/ | ||
source: GPUCopyExternalImageSource; | ||
/** | ||
* Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from. | ||
* Together with `copySize`, defines the full copy sub-region. | ||
*/ | ||
origin?: GPUOrigin2D; | ||
/** | ||
* Describes whether the source image is vertically flipped, or not. | ||
* If this option is set to `true`, the copy is flipped vertically: the bottom row of the source | ||
* region is copied into the first row of the destination region, and so on. | ||
* The {@link GPUCopyExternalImageSourceInfo#origin} option is still relative to the top-left corner | ||
* of the source image, increasing downward. | ||
*/ | ||
flipY?: boolean; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do all of the copy-related interfaces need to be here? They're in the IDL so I thought they'd be autogenerated.
@@ -0,0 +1,253 @@ | |||
// ********************************************************************************************* | |||
// This file is manually-edited by diffing against an autogenerated file. See README.md. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is here to be pasted into the combined file, but it's confusing because extra.d.ts is meant to be all manually written right? Maybe move this comment into a string in the script?
* Transform generated to something closer to what we want | ||
* so we have less manual work to do. | ||
*/ | ||
function fixupGenerated(filename) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most (but not all) of these things would ideally be changed in the upstream generator. That repo is external but it was created for webgpu so we can change it freely.
Since some of these do make sense to keep here, it's not a big deal, since we need this script anyway. I'm fine with accepting it as is.
Here's a version that tries to massage the generated/index.d.ts code closer to the dist/index.d.ts. It also separates out the easy parts into extra.d.ts but rather than have 2 files in dist it preprends the contents when making generated/index.d.ts
wdyt?
note: there's 3 commits. I might be easier to look at the commit diffs than the PR diff