@carbonenginejs/runtime-resource 0.12.0 → 0.12.1
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/dist/CjsResMan.js +4 -4
- package/dist/CjsResMan.js.map +1 -1
- package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -4
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/dist/format/CjsByteReader.js +310 -0
- package/dist/format/CjsByteReader.js.map +1 -0
- package/dist/format/CjsByteWriter.js +242 -0
- package/dist/format/CjsByteWriter.js.map +1 -0
- package/dist/format/CjsFormatError.js +41 -0
- package/dist/format/CjsFormatError.js.map +1 -0
- package/dist/format/CjsStringTable.js +268 -0
- package/dist/format/CjsStringTable.js.map +1 -0
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js +361 -0
- package/dist/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -0
- package/dist/format/carbonEffect/CjsCarbonEffectWriter.js +373 -0
- package/dist/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -0
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js +372 -0
- package/dist/format/carbonEffect/carbonDescriptionFromPortable.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js +427 -0
- package/dist/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -0
- package/dist/format/carbonEffect/carbonEffectRecords.js +955 -0
- package/dist/format/carbonEffect/carbonEffectRecords.js.map +1 -0
- package/dist/format/compareUtf8.js +36 -0
- package/dist/format/compareUtf8.js.map +1 -0
- package/dist/format/index.js +11 -0
- package/dist/format/index.js.map +1 -0
- package/dist/formats/bnk/CjsBnkFormat.js +10 -4
- package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
- package/dist/formats/bnk/core/eventAction.js +305 -0
- package/dist/formats/bnk/core/eventAction.js.map +1 -0
- package/dist/formats/bnk/core/helpers.js +11 -2
- package/dist/formats/bnk/core/helpers.js.map +1 -1
- package/dist/formats/bnk/core/nodeBase.js +532 -0
- package/dist/formats/bnk/core/nodeBase.js.map +1 -0
- package/dist/formats/bnk/core/sfxNodes.js +252 -152
- package/dist/formats/bnk/core/sfxNodes.js.map +1 -1
- package/dist/formats/hlsl/core/HlslReader.js +7 -257
- package/dist/formats/hlsl/core/HlslReader.js.map +1 -1
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js +781 -0
- package/dist/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -0
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js +21 -1
- package/dist/formats/hlsl/core/tr2/resources/HlslEffectRes.js.map +1 -1
- package/dist/formats/index.js +1 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js +2 -1
- package/dist/formats/webgl/core/cewg/CewgPackage.js.map +1 -1
- package/dist/formats/webgl/core/cewg/binary.js +11 -93
- package/dist/formats/webgl/core/cewg/binary.js.map +1 -1
- package/dist/formats/webgl/core/effectPackage.js +1 -1
- package/dist/formats/webgpu/CjsWebgpuFormat.js +4 -23
- package/dist/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js +197 -0
- package/dist/formats/webgpu/core/buildCarbonEffectContainer.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js +368 -0
- package/dist/formats/webgpu/core/cewgpu/CewgpuContainer.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/containerViews.js +355 -0
- package/dist/formats/webgpu/core/cewgpu/containerViews.js.map +1 -0
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js +90 -0
- package/dist/formats/webgpu/core/cewgpu/validateContainer.js.map +1 -0
- package/dist/formats/webgpu/core/effectBackendBodySet.js +21 -20
- package/dist/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/formats/webgpu/core/helpers.js +87 -92
- package/dist/formats/webgpu/core/helpers.js.map +1 -1
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js +14 -13
- package/dist/formats/webgpu/core/ir/analyzeRegisterValues.js.map +1 -1
- package/dist/formats/webgpu/core/ir/inferValueTypes.js +10 -8
- package/dist/formats/webgpu/core/ir/inferValueTypes.js.map +1 -1
- package/dist/formats/webgpu/core/packageEffect.js +94 -9
- package/dist/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/formats/webgpu/core/packageMetadata.js +10 -1
- package/dist/formats/webgpu/core/packageMetadata.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js +17 -15
- package/dist/formats/webgpu/core/wgsl/buildResourceTransformPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js +13 -12
- package/dist/formats/webgpu/core/wgsl/buildWgslBindingPlan.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js +9 -8
- package/dist/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js +23 -22
- package/dist/formats/webgpu/core/wgsl/lowerComputeProgram.js.map +1 -1
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js +46 -44
- package/dist/formats/webgpu/core/wgsl/selectionPlans.js.map +1 -1
- package/dist/resource/CjsResource.js +700 -684
- package/dist/resource/CjsResource.js.map +1 -1
- package/dist/resource/Tr2LightProfileRes.js +18 -27
- package/dist/resource/Tr2LightProfileRes.js.map +1 -1
- package/dist/resource/audio/CjsAudioBufferRes.js +2 -2
- package/dist/resource/audio/CjsAudioBufferRes.js.map +1 -1
- package/dist/resource/audio/CjsAudioRes.js +2 -2
- package/dist/resource/audio/CjsAudioRes.js.map +1 -1
- package/dist/resource/geometry/TriGeometryRes.js +605 -586
- package/dist/resource/geometry/TriGeometryRes.js.map +1 -1
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js +21 -30
- package/dist/resource/geometry/granny/Tr2GrannyStateRes.js.map +1 -1
- package/dist/resource/geometry/granny/TriGrannyRes.js +21 -30
- package/dist/resource/geometry/granny/TriGrannyRes.js.map +1 -1
- package/dist/resource/shader/Tr2EffectRes.js +9 -7
- package/dist/resource/shader/Tr2EffectRes.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialArea.js +5 -3
- package/dist/resource/shader/Tr2MaterialArea.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialMesh.js +4 -2
- package/dist/resource/shader/Tr2MaterialMesh.js.map +1 -1
- package/dist/resource/shader/Tr2MaterialRes.js +5 -3
- package/dist/resource/shader/Tr2MaterialRes.js.map +1 -1
- package/dist/resource/shader/Tr2Shader.js +26 -21
- package/dist/resource/shader/Tr2Shader.js.map +1 -1
- package/dist/resource/shader/Tr2ShaderPermutation.js +8 -6
- package/dist/resource/shader/Tr2ShaderPermutation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDefine.js +5 -3
- package/dist/resource/shader/reflection/Tr2EffectDefine.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectDescription.js +5 -3
- package/dist/resource/shader/reflection/Tr2EffectDescription.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js +17 -15
- package/dist/resource/shader/reflection/Tr2EffectLibrary.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js +11 -9
- package/dist/resource/shader/reflection/Tr2EffectParameterAnnotation.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectResource.js +8 -6
- package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js +15 -13
- package/dist/resource/shader/reflection/Tr2EffectStageInput.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js +7 -5
- package/dist/resource/shader/reflection/Tr2EffectTechnique.js.map +1 -1
- package/dist/resource/shader/reflection/Tr2Pass.js +11 -9
- package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js +8 -6
- package/dist/resource/shader/sampler/Tr2SamplerSetup.js.map +1 -1
- package/dist/resource/texture/CjsTextureArrayRes.js +400 -411
- package/dist/resource/texture/CjsTextureArrayRes.js.map +1 -1
- package/dist/resource/texture/Tr2ImageRes.js +99 -95
- package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
- package/dist/resource/texture/TriTextureRes.js +312 -273
- package/dist/resource/texture/TriTextureRes.js.map +1 -1
- package/docs/README.md +13 -1
- package/docs/architecture.md +3 -3
- package/docs/concepts/resource-lifecycle.md +9 -2
- package/docs/concepts/shader-resource-model.md +114 -0
- package/docs/concepts/writing-an-engine-adapter.md +115 -0
- package/docs/formats/README.md +24 -1
- package/docs/formats/carbon-effect-container.md +452 -0
- package/docs/formats/dxbc/reference/classes/README.md +5 -72
- package/docs/formats/hlsl/reference/api.md +5 -4
- package/docs/formats/hlsl/reference/classes/README.md +6 -11
- package/docs/formats/provenance.md +23 -13
- package/docs/formats/webgl/reference/classes/README.md +5 -92
- package/docs/formats/webgpu/README.md +19 -16
- package/docs/formats/webgpu/architecture.md +15 -12
- package/docs/formats/webgpu/formats/cewgpu.md +175 -438
- package/docs/formats/webgpu/guides/effect-packaging.md +132 -140
- package/docs/formats/webgpu/reference/api.md +131 -131
- package/docs/formats/webgpu/reference/classes/README.md +5 -62
- package/docs/formats/webgpu/reference/wgsl-compatibility.md +146 -45
- package/docs/formats/wwise.md +34 -8
- package/docs/reference/classes/core.md +80 -0
- package/docs/reference/classes/formats.md +18 -28
- package/docs/reference/events.md +25 -0
- package/docs/reference/motherlode-cache.md +22 -8
- package/docs/reference/workers.md +5 -5
- package/docs/roadmap.md +61 -41
- package/package.json +2 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js +0 -415
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackage.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js +0 -100
- package/dist/formats/webgpu/core/cewgpu/CewgpuPackageBuilder.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/binary.js +0 -93
- package/dist/formats/webgpu/core/cewgpu/binary.js.map +0 -1
- package/dist/formats/webgpu/core/cewgpu/tags.js +0 -17
- package/dist/formats/webgpu/core/cewgpu/tags.js.map +0 -1
- package/dist/formats/webgpu/core/effectPackageValidation.js +0 -1078
- package/dist/formats/webgpu/core/effectPackageValidation.js.map +0 -1
- package/docs/formats/hlsl/reference/classes/carbon-compatibility.md +0 -66
- package/docs/formats/hlsl/reference/classes/public-api.md +0 -26
- package/docs/formats/hlsl/reference/classes/tr2-effect-model.md +0 -150
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { CjsResource as _CjsResource } from '../CjsResource.js';
|
|
1
|
+
import { CjsSchema, carbon, impl, type, io } from '@carbonenginejs/runtime-utils/schema';
|
|
2
|
+
import { CjsResource } from '../CjsResource.js';
|
|
4
3
|
import { validateVideoPayload, validateTexturePayload, validateRgbaPayload, ResourcePayloadType } from '../../format/payloadContract.js';
|
|
5
4
|
import { resourcePayloadError, validateResourcePayload, resourceBoundaryError } from '../resourceBoundary.js';
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
// Source: trinity/trinity/Resources/TriTextureRes.h
|
|
7
|
+
// Source: trinity/trinity/Resources/TriTextureRes.cpp
|
|
8
|
+
// Source: trinity/trinity/Resources/TriTextureRes_Blue.cpp
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Resource record that owns Carbon-style texture identity and validated
|
|
@@ -13,301 +14,286 @@ let _initProto, _initClass, _init_format, _init_extra_format, _init_type, _init_
|
|
|
13
14
|
*
|
|
14
15
|
* The resource never creates or retains a backend texture.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
cpuMip = (_init_extra_hadLodRequests(this), _init_cpuMip(this, 0));
|
|
37
|
-
gpuMip = (_init_extra_cpuMip(this), _init_gpuMip(this, 0));
|
|
38
|
-
wrappedRenderTarget = (_init_extra_gpuMip(this), _init_wrappedRenderTarget(this, null));
|
|
39
|
-
originalResolution = (_init_extra_wrappedRenderTarget(this), _init_originalResolution(this, 0));
|
|
40
|
-
originalMemoryUsage = (_init_extra_originalResolution(this), _init_originalMemoryUsage(this, 0));
|
|
41
|
-
name = (_init_extra_originalMemoryUsage(this), _init_name(this, ""));
|
|
42
|
-
arraySize = (_init_extra_name(this), _init_arraySize(this, 0));
|
|
43
|
-
cutoutWidth = (_init_extra_arraySize(this), _init_cutoutWidth(this, 1));
|
|
44
|
-
width = (_init_extra_cutoutWidth(this), _init_width(this, 0));
|
|
45
|
-
cutoutX = (_init_extra_width(this), _init_cutoutX(this, 0));
|
|
46
|
-
cutoutY = (_init_extra_cutoutX(this), _init_cutoutY(this, 0));
|
|
17
|
+
class TriTextureRes extends CjsResource {
|
|
18
|
+
format = null;
|
|
19
|
+
type = null;
|
|
20
|
+
averageColor = [0, 0, 0, 0];
|
|
21
|
+
depth = 0;
|
|
22
|
+
cutoutHeight = 1;
|
|
23
|
+
height = 0;
|
|
24
|
+
lodEnabled = false;
|
|
25
|
+
hadLodRequests = false;
|
|
26
|
+
cpuMip = 0;
|
|
27
|
+
gpuMip = 0;
|
|
28
|
+
wrappedRenderTarget = null;
|
|
29
|
+
originalResolution = 0;
|
|
30
|
+
originalMemoryUsage = 0;
|
|
31
|
+
name = "";
|
|
32
|
+
arraySize = 0;
|
|
33
|
+
cutoutWidth = 1;
|
|
34
|
+
width = 0;
|
|
35
|
+
cutoutX = 0;
|
|
36
|
+
cutoutY = 0;
|
|
47
37
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
/** Creates a TriTextureRes with caller-provided initial state. */
|
|
39
|
+
constructor(values = null) {
|
|
40
|
+
super();
|
|
41
|
+
this.SetValues(values || {}, {
|
|
42
|
+
markDirty: false,
|
|
43
|
+
skipUpdate: true,
|
|
44
|
+
skipEvents: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
57
47
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
const validator = {
|
|
72
|
-
[ResourcePayloadType.RGBA]: validateRgbaPayload,
|
|
73
|
-
[ResourcePayloadType.TEXTURE]: validateTexturePayload,
|
|
74
|
-
[ResourcePayloadType.VIDEO]: validateVideoPayload
|
|
75
|
-
}[payload?.payloadType];
|
|
76
|
-
if (!validator) {
|
|
77
|
-
throw resourcePayloadError("TriTextureRes", 'Expected payloadType "rgba", "texture", or "video".', "payloadType");
|
|
78
|
-
}
|
|
79
|
-
validateResourcePayload("TriTextureRes", payload, validator);
|
|
80
|
-
const values = {
|
|
81
|
-
...(options || {})
|
|
82
|
-
};
|
|
83
|
-
if (payload.pixelFormat !== undefined || payload.format !== undefined) values.format = payload.pixelFormat || payload.format;
|
|
84
|
-
if (payload.width !== undefined) values.width = payload.width;
|
|
85
|
-
if (payload.height !== undefined) values.height = payload.height;
|
|
86
|
-
if (payload.depth !== undefined) values.depth = payload.depth;
|
|
87
|
-
if (payload.arraySize !== undefined) values.arraySize = payload.arraySize;else if (Array.isArray(payload.faces)) values.arraySize = payload.faces.length;
|
|
88
|
-
if (payload.mipCount !== undefined) values.cpuMip = payload.mipCount;else if (payload.payloadType === ResourcePayloadType.RGBA) values.cpuMip = 1;
|
|
89
|
-
if (payload.hadLodRequests !== undefined) values.hadLodRequests = !!payload.hadLodRequests;
|
|
90
|
-
values.originalMemoryUsage = getPayloadMemoryUsage(payload);
|
|
91
|
-
values.originalResolution = Math.max(payload.width || 0, payload.height || 0, this.originalResolution || 0);
|
|
92
|
-
super.SetPayload(payload);
|
|
93
|
-
this.SetValues(values);
|
|
48
|
+
/**
|
|
49
|
+
* Attach a plain texture, RGBA, or video payload and mirror Carbon-exposed
|
|
50
|
+
* metadata. Invalid payloads are rejected before replacing the current one.
|
|
51
|
+
*
|
|
52
|
+
* @param {object|null} payload
|
|
53
|
+
* @param {object|null} options
|
|
54
|
+
* @returns {TriTextureRes}
|
|
55
|
+
*/
|
|
56
|
+
SetPayload(payload = null, options = null) {
|
|
57
|
+
if (payload === null) {
|
|
58
|
+
super.SetPayload(null);
|
|
94
59
|
return this;
|
|
95
60
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return this.GetPayload()?.mipCount || this.cpuMip || 0;
|
|
61
|
+
const validator = {
|
|
62
|
+
[ResourcePayloadType.RGBA]: validateRgbaPayload,
|
|
63
|
+
[ResourcePayloadType.TEXTURE]: validateTexturePayload,
|
|
64
|
+
[ResourcePayloadType.VIDEO]: validateVideoPayload
|
|
65
|
+
}[payload?.payloadType];
|
|
66
|
+
if (!validator) {
|
|
67
|
+
throw resourcePayloadError("TriTextureRes", 'Expected payloadType "rgba", "texture", or "video".', "payloadType");
|
|
104
68
|
}
|
|
69
|
+
validateResourcePayload("TriTextureRes", payload, validator);
|
|
70
|
+
const values = {
|
|
71
|
+
...(options || {})
|
|
72
|
+
};
|
|
73
|
+
if (payload.pixelFormat !== undefined || payload.format !== undefined) values.format = payload.pixelFormat || payload.format;
|
|
74
|
+
if (payload.width !== undefined) values.width = payload.width;
|
|
75
|
+
if (payload.height !== undefined) values.height = payload.height;
|
|
76
|
+
if (payload.depth !== undefined) values.depth = payload.depth;
|
|
77
|
+
if (payload.arraySize !== undefined) values.arraySize = payload.arraySize;else if (Array.isArray(payload.faces)) values.arraySize = payload.faces.length;
|
|
78
|
+
if (payload.mipCount !== undefined) values.cpuMip = payload.mipCount;else if (payload.payloadType === ResourcePayloadType.RGBA) values.cpuMip = 1;
|
|
79
|
+
if (payload.hadLodRequests !== undefined) values.hadLodRequests = !!payload.hadLodRequests;
|
|
80
|
+
values.originalMemoryUsage = getPayloadMemoryUsage(payload);
|
|
81
|
+
values.originalResolution = Math.max(payload.width || 0, payload.height || 0, this.originalResolution || 0);
|
|
82
|
+
super.SetPayload(payload);
|
|
83
|
+
this.SetValues(values);
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
105
86
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
87
|
+
/**
|
|
88
|
+
* Return the number of mip levels known to this texture resource.
|
|
89
|
+
*
|
|
90
|
+
* @returns {number}
|
|
91
|
+
*/
|
|
92
|
+
GetMipCount() {
|
|
93
|
+
return this.GetPayload()?.mipCount || this.cpuMip || 0;
|
|
94
|
+
}
|
|
115
95
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Return the multisample type for this texture.
|
|
98
|
+
*
|
|
99
|
+
* @returns {number}
|
|
100
|
+
*/
|
|
101
|
+
GetMsaaType() {
|
|
102
|
+
const payload = this.GetPayload();
|
|
103
|
+
return payload?.multiSampleType ?? payload?.msaaType ?? payload?.samples ?? 1;
|
|
104
|
+
}
|
|
125
105
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Return the multisample quality for this texture.
|
|
108
|
+
*
|
|
109
|
+
* @returns {number}
|
|
110
|
+
*/
|
|
111
|
+
GetMsaaQuality() {
|
|
112
|
+
const payload = this.GetPayload();
|
|
113
|
+
return payload?.multiSampleQuality ?? payload?.msaaQuality ?? 0;
|
|
114
|
+
}
|
|
134
115
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Return true if this texture has received LOD requests.
|
|
118
|
+
*
|
|
119
|
+
* @returns {boolean}
|
|
120
|
+
*/
|
|
121
|
+
HadLodRequests() {
|
|
122
|
+
return this.hadLodRequests;
|
|
123
|
+
}
|
|
143
124
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
125
|
+
/**
|
|
126
|
+
* Return the shader-resource-view heap index when a backend owns one.
|
|
127
|
+
*
|
|
128
|
+
* @returns {number}
|
|
129
|
+
*/
|
|
130
|
+
GetSrvIndexInHeap() {
|
|
131
|
+
throw resourceBoundaryError("TriTextureRes", "GetSrvIndexInHeap", "Runtime-resource does not own descriptor heaps.");
|
|
132
|
+
}
|
|
153
133
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Save this texture asynchronously.
|
|
136
|
+
*
|
|
137
|
+
* @param {string} path
|
|
138
|
+
* @returns {boolean}
|
|
139
|
+
*/
|
|
140
|
+
SaveAsync(path = "") {
|
|
141
|
+
throw resourceBoundaryError("TriTextureRes", "SaveAsync", `Use a format writer and caller-owned destination to save texture payloads${path ? ` (${path})` : ""}.`);
|
|
142
|
+
}
|
|
163
143
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
144
|
+
/**
|
|
145
|
+
* Save this texture synchronously.
|
|
146
|
+
*
|
|
147
|
+
* @param {string} path
|
|
148
|
+
* @returns {boolean}
|
|
149
|
+
*/
|
|
150
|
+
Save(path = "") {
|
|
151
|
+
throw resourceBoundaryError("TriTextureRes", "Save", `Use a format writer and caller-owned destination to save texture payloads${path ? ` (${path})` : ""}.`);
|
|
152
|
+
}
|
|
172
153
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Return true if an asynchronous save is active.
|
|
156
|
+
*
|
|
157
|
+
* @returns {boolean}
|
|
158
|
+
*/
|
|
159
|
+
IsSaving() {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
181
162
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Return true if the asynchronous save operation has completed.
|
|
165
|
+
*
|
|
166
|
+
* @returns {boolean}
|
|
167
|
+
*/
|
|
168
|
+
IsSaveCompleted() {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
190
171
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Return true if the asynchronous save operation succeeded.
|
|
174
|
+
*
|
|
175
|
+
* @returns {boolean}
|
|
176
|
+
*/
|
|
177
|
+
IsSaveSucceeded() {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
199
180
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Wait for an asynchronous save operation.
|
|
183
|
+
*
|
|
184
|
+
* @returns {boolean}
|
|
185
|
+
*/
|
|
186
|
+
WaitForSave() {
|
|
187
|
+
return this.IsSaveCompleted();
|
|
188
|
+
}
|
|
208
189
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Device texture allocation belongs to engine-gpu.
|
|
192
|
+
*
|
|
193
|
+
* @throws {Error}
|
|
194
|
+
*/
|
|
195
|
+
CreateEmptyTexture() {
|
|
196
|
+
throw resourceBoundaryError("TriTextureRes", "CreateEmptyTexture", "Use engine-gpu to allocate device textures.");
|
|
197
|
+
}
|
|
217
198
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Render-target wrapping belongs to engine-gpu.
|
|
201
|
+
*
|
|
202
|
+
* @throws {Error}
|
|
203
|
+
*/
|
|
204
|
+
SetFromRenderTarget() {
|
|
205
|
+
throw resourceBoundaryError("TriTextureRes", "SetFromRenderTarget", "Runtime-resource does not own render targets.");
|
|
206
|
+
}
|
|
226
207
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
208
|
+
/**
|
|
209
|
+
* Create a texture copy from a render target.
|
|
210
|
+
*
|
|
211
|
+
* @throws {Error}
|
|
212
|
+
*/
|
|
213
|
+
CreateAndCopyFromRenderTarget() {
|
|
214
|
+
throw resourceBoundaryError("TriTextureRes", "CreateAndCopyFromRenderTarget", "Runtime-resource does not own render targets.");
|
|
215
|
+
}
|
|
235
216
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
217
|
+
/**
|
|
218
|
+
* Create a device texture from a host bitmap.
|
|
219
|
+
*
|
|
220
|
+
* @throws {Error}
|
|
221
|
+
*/
|
|
222
|
+
CreateFromHostBitmap() {
|
|
223
|
+
throw resourceBoundaryError("TriTextureRes", "CreateFromHostBitmap", "Use engine-gpu to allocate and upload texture data.");
|
|
224
|
+
}
|
|
244
225
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
return this.HasAdapterResource(`${type}:${object}`);
|
|
254
|
-
}
|
|
226
|
+
/**
|
|
227
|
+
* Create this texture from another texture resource.
|
|
228
|
+
*
|
|
229
|
+
* @throws {Error}
|
|
230
|
+
*/
|
|
231
|
+
CreateFromTexture() {
|
|
232
|
+
throw resourceBoundaryError("TriTextureRes", "CreateFromTexture", "Use engine-gpu to copy device textures.");
|
|
233
|
+
}
|
|
255
234
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
235
|
+
/**
|
|
236
|
+
* Return true if this texture owns a backend allocation object.
|
|
237
|
+
*
|
|
238
|
+
* @param {string|number} type
|
|
239
|
+
* @param {string|number} object
|
|
240
|
+
* @returns {boolean}
|
|
241
|
+
*/
|
|
242
|
+
HasALObject(type, object) {
|
|
243
|
+
return this.HasAdapterResource(`${type}:${object}`);
|
|
244
|
+
}
|
|
264
245
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Return an engine-owned texture pipeline object when attached.
|
|
248
|
+
*
|
|
249
|
+
* @returns {*}
|
|
250
|
+
*/
|
|
251
|
+
GetPipeline() {
|
|
252
|
+
return this.GetAdapterResource("pipeline");
|
|
253
|
+
}
|
|
273
254
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
*/
|
|
283
|
-
SetAverageColor(red = 0, green = 0, blue = 0, alpha = 0) {
|
|
284
|
-
this.averageColor = [red, green, blue, alpha];
|
|
285
|
-
return this;
|
|
286
|
-
}
|
|
255
|
+
/**
|
|
256
|
+
* Return memory size for the original non-LODed texture.
|
|
257
|
+
*
|
|
258
|
+
* @returns {number}
|
|
259
|
+
*/
|
|
260
|
+
GetOriginalMemoryUsage() {
|
|
261
|
+
return this.originalMemoryUsage || getPayloadMemoryUsage(this.GetPayload());
|
|
262
|
+
}
|
|
287
263
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Store the average color reported by decoded texture data.
|
|
266
|
+
*
|
|
267
|
+
* @param {number} red
|
|
268
|
+
* @param {number} green
|
|
269
|
+
* @param {number} blue
|
|
270
|
+
* @param {number} alpha
|
|
271
|
+
* @returns {TriTextureRes}
|
|
272
|
+
*/
|
|
273
|
+
SetAverageColor(red = 0, green = 0, blue = 0, alpha = 0) {
|
|
274
|
+
this.averageColor = [red, green, blue, alpha];
|
|
275
|
+
return this;
|
|
276
|
+
}
|
|
296
277
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Update a texture subresource.
|
|
280
|
+
*
|
|
281
|
+
* @throws {Error}
|
|
282
|
+
*/
|
|
283
|
+
UpdateSubresource() {
|
|
284
|
+
throw resourceBoundaryError("TriTextureRes", "UpdateSubresource", "Use engine-gpu to upload texture bytes.");
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Resource preparation does not decide device upload policy.
|
|
289
|
+
*
|
|
290
|
+
* @returns {boolean}
|
|
291
|
+
*/
|
|
292
|
+
PrepareResources() {
|
|
293
|
+
return this.IsPrepared();
|
|
309
294
|
}
|
|
310
|
-
|
|
295
|
+
static payload = "texture";
|
|
296
|
+
}
|
|
311
297
|
function getPayloadMemoryUsage(payload) {
|
|
312
298
|
if (!payload || typeof payload !== "object") return 0;
|
|
313
299
|
if (Number.isSafeInteger(payload.originalMemoryUsage) && payload.originalMemoryUsage >= 0) {
|
|
@@ -316,5 +302,58 @@ function getPayloadMemoryUsage(payload) {
|
|
|
316
302
|
return ArrayBuffer.isView(payload.data) || payload.data instanceof ArrayBuffer ? payload.data.byteLength : 0;
|
|
317
303
|
}
|
|
318
304
|
|
|
319
|
-
|
|
305
|
+
// Declared as data rather than with decorators, so the resource tree loads from
|
|
306
|
+
// source without a transform. Field order is key order, and GetValues() exports
|
|
307
|
+
// in that order.
|
|
308
|
+
CjsSchema.define(TriTextureRes, {
|
|
309
|
+
className: "TriTextureRes",
|
|
310
|
+
family: "resources",
|
|
311
|
+
fields: {
|
|
312
|
+
format: [type.unknown, io.read],
|
|
313
|
+
type: [type.unknown, io.persist],
|
|
314
|
+
averageColor: [type.color, io.read],
|
|
315
|
+
depth: [type.uint32, io.read],
|
|
316
|
+
cutoutHeight: [type.float32, io.readwrite],
|
|
317
|
+
height: [type.uint32, io.read],
|
|
318
|
+
lodEnabled: [type.boolean, io.read],
|
|
319
|
+
hadLodRequests: [type.boolean, io.read],
|
|
320
|
+
cpuMip: [type.uint32, io.read],
|
|
321
|
+
gpuMip: [type.uint32, io.read],
|
|
322
|
+
wrappedRenderTarget: [type.unknown, io.read],
|
|
323
|
+
originalResolution: [type.uint32, io.read],
|
|
324
|
+
originalMemoryUsage: [type.uint64, io.read],
|
|
325
|
+
name: [type.string, io.readwrite],
|
|
326
|
+
arraySize: [type.uint32, io.read],
|
|
327
|
+
cutoutWidth: [type.float32, io.readwrite],
|
|
328
|
+
width: [type.uint32, io.read],
|
|
329
|
+
cutoutX: [type.float32, io.readwrite],
|
|
330
|
+
cutoutY: [type.float32, io.readwrite]
|
|
331
|
+
},
|
|
332
|
+
methods: {
|
|
333
|
+
GetMipCount: [carbon.method, impl.adapted],
|
|
334
|
+
GetMsaaType: [carbon.method, impl.adapted],
|
|
335
|
+
GetMsaaQuality: [carbon.method, impl.adapted],
|
|
336
|
+
HadLodRequests: [carbon.method, impl.adapted],
|
|
337
|
+
GetSrvIndexInHeap: [carbon.method, impl.notSupported],
|
|
338
|
+
SaveAsync: [carbon.method, impl.notSupported],
|
|
339
|
+
Save: [carbon.method, impl.notSupported],
|
|
340
|
+
IsSaving: [carbon.method, impl.noop],
|
|
341
|
+
IsSaveCompleted: [carbon.method, impl.noop],
|
|
342
|
+
IsSaveSucceeded: [carbon.method, impl.noop],
|
|
343
|
+
WaitForSave: [carbon.method, impl.noop],
|
|
344
|
+
CreateEmptyTexture: [carbon.method, impl.notSupported],
|
|
345
|
+
SetFromRenderTarget: [carbon.method, impl.notSupported],
|
|
346
|
+
CreateAndCopyFromRenderTarget: [carbon.method, impl.notSupported],
|
|
347
|
+
CreateFromHostBitmap: [carbon.method, impl.notSupported],
|
|
348
|
+
CreateFromTexture: [carbon.method, impl.notSupported],
|
|
349
|
+
HasALObject: [carbon.method, impl.adapted],
|
|
350
|
+
GetPipeline: [carbon.method, impl.adapted],
|
|
351
|
+
GetOriginalMemoryUsage: [carbon.method, impl.adapted],
|
|
352
|
+
SetAverageColor: [carbon.method, impl.adapted],
|
|
353
|
+
UpdateSubresource: [carbon.method, impl.notSupported],
|
|
354
|
+
PrepareResources: [carbon.method, impl.adapted]
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
export { TriTextureRes };
|
|
320
359
|
//# sourceMappingURL=TriTextureRes.js.map
|