@forgeax/engine-rhi 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +32 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/command-encoder-spec-alignment.test-d.ts +9 -12
- package/src/index.ts +42 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgeax/engine-rhi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"LICENSE"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@forgeax/engine-types": "0.1.
|
|
29
|
+
"@forgeax/engine-types": "0.1.21",
|
|
30
30
|
"@webgpu/types": "^0.1.71"
|
|
31
31
|
},
|
|
32
32
|
"forgeax": {
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// `@webgpu/types` GPUCommandEncoder (research F-1 / plan-strategy D-S4).
|
|
3
3
|
//
|
|
4
4
|
// Asserts (will be RED until w3 lands the impl):
|
|
5
|
-
// - 12 spec methods (9 direct + 3 GPUDebugCommandsMixin)
|
|
5
|
+
// - 12 spec methods (9 direct + 3 GPUDebugCommandsMixin) plus one ForgeaX
|
|
6
|
+
// compound operation exist on RhiCommandEncoder
|
|
6
7
|
// - `copyBufferToBuffer` exposes both spec overloads (3-arg shorthand + 5-arg full form)
|
|
7
8
|
// - `finish()` returns Result<CommandBuffer, RhiError>
|
|
8
9
|
// - method NAMES align byte-for-byte with `@webgpu/types` GPUCommandEncoder
|
|
@@ -14,13 +15,14 @@ import { describe, expectTypeOf, it } from 'vitest';
|
|
|
14
15
|
import type {
|
|
15
16
|
Buffer,
|
|
16
17
|
CommandBuffer,
|
|
18
|
+
ComputePassDescriptor,
|
|
17
19
|
QuerySet,
|
|
18
20
|
Result,
|
|
19
21
|
RhiCommandEncoder,
|
|
20
22
|
RhiError,
|
|
21
23
|
} from '../index';
|
|
22
24
|
|
|
23
|
-
describe('w2 - RhiCommandEncoder spec method set (12
|
|
25
|
+
describe('w2 - RhiCommandEncoder spec method set (12 spec + 1 compound)', () => {
|
|
24
26
|
it('exposes beginRenderPass(desc): RhiRenderPassEncoder', () => {
|
|
25
27
|
expectTypeOf<RhiCommandEncoder['beginRenderPass']>().toBeFunction();
|
|
26
28
|
});
|
|
@@ -29,6 +31,11 @@ describe('w2 - RhiCommandEncoder spec method set (12 methods)', () => {
|
|
|
29
31
|
expectTypeOf<RhiCommandEncoder['beginComputePass']>().toBeFunction();
|
|
30
32
|
});
|
|
31
33
|
|
|
34
|
+
it('exposes encodeEmptyComputePass(desc): void as a ForgeaX compound operation', () => {
|
|
35
|
+
type Expected = (desc: ComputePassDescriptor) => void;
|
|
36
|
+
expectTypeOf<RhiCommandEncoder['encodeEmptyComputePass']>().toMatchTypeOf<Expected>();
|
|
37
|
+
});
|
|
38
|
+
|
|
32
39
|
it('exposes copyBufferToBuffer (5-arg full form per spec)', () => {
|
|
33
40
|
// 5-arg overload must be callable (research F-1 finding):
|
|
34
41
|
// copyBufferToBuffer(src, srcOffset, dst, dstOffset, size): void
|
|
@@ -104,14 +111,4 @@ describe('w2 - RhiCommandEncoder spec method set (12 methods)', () => {
|
|
|
104
111
|
Result<CommandBuffer, RhiError>
|
|
105
112
|
>();
|
|
106
113
|
});
|
|
107
|
-
|
|
108
|
-
// w38 (M5 / K-3): writeTimestamp on the CommandEncoder entry only.
|
|
109
|
-
// CPE/RPE inside-pass timestamp writes are deferred to
|
|
110
|
-
// feat-future-rhi-perf-timestamp-pass per K-3 decision.
|
|
111
|
-
it('exposes writeTimestamp(querySet, queryIndex): void (K-3 CommandEncoder-only)', () => {
|
|
112
|
-
type Method = RhiCommandEncoder['writeTimestamp'];
|
|
113
|
-
expectTypeOf<Method>().toBeFunction();
|
|
114
|
-
type Expected = (querySet: QuerySet, queryIndex: number) => void;
|
|
115
|
-
expectTypeOf<Expected>().toMatchTypeOf<Method>();
|
|
116
|
-
});
|
|
117
114
|
});
|
package/src/index.ts
CHANGED
|
@@ -211,6 +211,22 @@ export interface Texture {
|
|
|
211
211
|
readonly [RhiTextureBrand]: void;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
/** RHI-safe source for a texture-to-buffer copy. */
|
|
215
|
+
export interface TextureCopySource {
|
|
216
|
+
readonly texture: Texture;
|
|
217
|
+
readonly mipLevel?: number | undefined;
|
|
218
|
+
readonly origin?: GPUOrigin3D | undefined;
|
|
219
|
+
readonly aspect?: GPUTextureAspect | undefined;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** RHI-safe destination for a texture-to-buffer copy. */
|
|
223
|
+
export interface BufferCopyDestination {
|
|
224
|
+
readonly buffer: Buffer;
|
|
225
|
+
readonly offset?: number | undefined;
|
|
226
|
+
readonly bytesPerRow: number;
|
|
227
|
+
readonly rowsPerImage?: number | undefined;
|
|
228
|
+
}
|
|
229
|
+
|
|
214
230
|
/** RHI-owned destination for queue.writeTexture. The resource handle remains opaque. */
|
|
215
231
|
export interface TextureWriteDestination {
|
|
216
232
|
readonly texture: Texture;
|
|
@@ -1078,7 +1094,7 @@ export interface RhiCaps {
|
|
|
1078
1094
|
* spec minimum = 4, defaults to 8 on mainstream backends.
|
|
1079
1095
|
* HDRP deferred pipeline requires >= 4 (3 g-buffer RT + 1 depth);
|
|
1080
1096
|
* installPipeline checks this cap at install time and throws
|
|
1081
|
-
*
|
|
1097
|
+
* a structured Standard transport refusal on violation (charter P3).
|
|
1082
1098
|
* @note add-only minor (feat-20260612-hdrp-deferred-shading-learn-render-5-8
|
|
1083
1099
|
* M1 / w5); no existing field is modified.
|
|
1084
1100
|
*/
|
|
@@ -1755,7 +1771,8 @@ export interface RhiQueue {
|
|
|
1755
1771
|
/** GPU command encoder - records render / compute passes + resource copies.
|
|
1756
1772
|
*
|
|
1757
1773
|
* Method NAMES align byte-for-byte with `@webgpu/types.GPUCommandEncoder` +
|
|
1758
|
-
* `GPUDebugCommandsMixin` (research F-1 / D-S4). 12 methods
|
|
1774
|
+
* `GPUDebugCommandsMixin` (research F-1 / D-S4). 12 spec methods plus one
|
|
1775
|
+
* ForgeaX compound operation:
|
|
1759
1776
|
* - 9 direct: beginRenderPass / beginComputePass / copyBufferToBuffer /
|
|
1760
1777
|
* copyBufferToTexture / copyTextureToBuffer / copyTextureToTexture /
|
|
1761
1778
|
* clearBuffer / resolveQuerySet / finish
|
|
@@ -1786,6 +1803,17 @@ export interface RhiCommandEncoder {
|
|
|
1786
1803
|
* const pass = encoder.beginComputePass();
|
|
1787
1804
|
*/
|
|
1788
1805
|
beginComputePass(desc?: ComputePassDescriptor | undefined): RhiComputePassEncoder;
|
|
1806
|
+
/**
|
|
1807
|
+
* Record an empty timestamp-enabled compute pass and close it immediately.
|
|
1808
|
+
*
|
|
1809
|
+
* This is a ForgeaX compound recording operation equivalent to
|
|
1810
|
+
* `const pass = encoder.beginComputePass(desc); pass.end()`; it is not a
|
|
1811
|
+
* native `GPUCommandEncoder` method and does not write a timestamp directly.
|
|
1812
|
+
*
|
|
1813
|
+
* @throws RhiError code === 'command-encoder-finished' when invoked on a
|
|
1814
|
+
* finished encoder.
|
|
1815
|
+
*/
|
|
1816
|
+
encodeEmptyComputePass(desc: ComputePassDescriptor): void;
|
|
1789
1817
|
/** Copy a sub-region of a Buffer to another Buffer (5-arg full form).
|
|
1790
1818
|
*
|
|
1791
1819
|
* Spec anchor: [@webgpu/types.GPUCommandEncoder.copyBufferToBuffer].
|
|
@@ -1836,6 +1864,18 @@ export interface RhiCommandEncoder {
|
|
|
1836
1864
|
destination: GPUTexelCopyBufferInfo,
|
|
1837
1865
|
copySize: GPUExtent3DStrict,
|
|
1838
1866
|
): void;
|
|
1867
|
+
/** Opaque RHI handle form for renderer-owned readback. */
|
|
1868
|
+
copyTextureToBuffer(
|
|
1869
|
+
source: TextureCopySource,
|
|
1870
|
+
destination: BufferCopyDestination,
|
|
1871
|
+
copySize: GPUExtent3DStrict,
|
|
1872
|
+
): void;
|
|
1873
|
+
/** Union form for decorators that transparently forward either handle form. */
|
|
1874
|
+
copyTextureToBuffer(
|
|
1875
|
+
source: GPUTexelCopyTextureInfo | TextureCopySource,
|
|
1876
|
+
destination: GPUTexelCopyBufferInfo | BufferCopyDestination,
|
|
1877
|
+
copySize: GPUExtent3DStrict,
|
|
1878
|
+
): void;
|
|
1839
1879
|
/** Copy a Texture sub-region to a Texture sub-region.
|
|
1840
1880
|
*
|
|
1841
1881
|
* Spec anchor: [@webgpu/types.GPUCommandEncoder.copyTextureToTexture].
|
|
@@ -1882,32 +1922,6 @@ export interface RhiCommandEncoder {
|
|
|
1882
1922
|
destination: Buffer,
|
|
1883
1923
|
destinationOffset: number,
|
|
1884
1924
|
): Result<void, RhiError>;
|
|
1885
|
-
/**
|
|
1886
|
-
* Write a u64 GPU timestamp into a timestamp QuerySet at queryIndex.
|
|
1887
|
-
*
|
|
1888
|
-
* Spec anchor: W3C WebGPU §queries / [@webgpu/types.GPUCommandEncoder].
|
|
1889
|
-
* dawn `TimestampOnCommandEncoder` reference (research §2.4): the entry is
|
|
1890
|
-
* gated on the `'timestamp-query'` device feature. K-3 decision
|
|
1891
|
-
* (plan-strategy §2): the forgeax form ships ONLY this CommandEncoder
|
|
1892
|
-
* entry; CPE/RPE inside-pass timestamp writes are deferred to
|
|
1893
|
-
* `feat-future-rhi-perf-timestamp-pass` (additive minor evolution).
|
|
1894
|
-
*
|
|
1895
|
-
* Return shape: `void` per spec literal alignment. When
|
|
1896
|
-
* `caps.timestampQuery === false` the shim fans out a structured
|
|
1897
|
-
* `'feature-not-enabled'` RhiError through the engine `onError` channel
|
|
1898
|
-
* (the forgeax form keeps the spec void return; AI users probe the gate
|
|
1899
|
-
* via `device.caps.timestampQuery` BEFORE calling this entry, charter
|
|
1900
|
-
* proposition 4 explicit failure forward-reachable).
|
|
1901
|
-
*
|
|
1902
|
-
* @throws RhiError code === 'command-encoder-finished' when invoked on a finished encoder (dual-channel; see beginRenderPass JSDoc for the recovery pattern).
|
|
1903
|
-
* @example
|
|
1904
|
-
* if (device.caps.timestampQuery) {
|
|
1905
|
-
* encoder.writeTimestamp(qs, 0);
|
|
1906
|
-
* // ... draw / dispatch ...
|
|
1907
|
-
* encoder.writeTimestamp(qs, 1);
|
|
1908
|
-
* }
|
|
1909
|
-
*/
|
|
1910
|
-
writeTimestamp(querySet: QuerySet, queryIndex: number): void;
|
|
1911
1925
|
/** Push a labelled debug group (GPUDebugCommandsMixin).
|
|
1912
1926
|
*
|
|
1913
1927
|
* Spec anchor: [@webgpu/types.GPUDebugCommandsMixin.pushDebugGroup].
|