Skip to content

Commit 4da964f

Browse files
Option: Force default limits
Add an option to force the adapter to use the default limits.
1 parent bd033ef commit 4da964f

4 files changed

Lines changed: 71 additions & 1 deletion

File tree

capture/options.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ <h2>Capture</h2>
2020
</p>
2121
</div>
2222

23+
<div>
24+
<h2>Adapter</h2>
25+
26+
<p>
27+
<span>Force default limits</span>
28+
<input type="checkbox" id="adapterDefaultLimits" value="true" />
29+
</p>
30+
</div>
31+
2332
<div>
2433
<h2>External textures</h2>
2534

capture/scripts/isolatedContent.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ chrome.storage.local.get(
22
{
33
captureFilename: "capture.wgpur",
44
captureMaxFrames: "0",
5+
adapterDefaultLimits: "false",
56
externalTextureScale: "100"
67
},
78
(items) => {

capture/scripts/mainContent.js

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,9 @@ function __WebGPUReconstruct_GPUAdapter_requestDevice(originalMethod, descriptor
405405

406406
if (descriptor != undefined) {
407407
overrideDescriptor.label = descriptor.label;
408-
overrideDescriptor.requiredLimits = descriptor.requiredLimits;
408+
if (!__webGPUReconstruct.configuration.adapterDefaultLimits) {
409+
overrideDescriptor.requiredLimits = descriptor.requiredLimits;
410+
}
409411
overrideDescriptor.defaultQueue = descriptor.defaultQueue;
410412

411413
if (descriptor.requiredFeatures != undefined) {
@@ -442,6 +444,48 @@ $STRUCT_SAVE_FUNCTIONS
442444
// Generated code will be inserted here.
443445
$CAPTURE_COMMANDS
444446

447+
function __WebGPUReconstruct_getDefaultLimits(compatibility) {
448+
let limits = {
449+
maxTextureDimension1D: compatibility ? 4096 : 8192,
450+
maxTextureDimension2D: compatibility ? 4096 : 8192,
451+
maxTextureDimension3D: 2048,
452+
maxTextureArrayLayers: 256,
453+
maxBindGroups: 4,
454+
maxBindGroupsPlusVertexBuffers: 24,
455+
maxBindingsPerBindGroup: 1000,
456+
maxDynamicUniformBuffersPerPipelineLayout: 8,
457+
maxDynamicStorageBuffersPerPipelineLayout: 4,
458+
maxSampledTexturesPerShaderStage: 16,
459+
maxSamplersPerShaderStage: 16,
460+
maxStorageBuffersPerShaderStage: 8,
461+
maxStorageBuffersInVertexStage: compatibility ? 0 : 8,
462+
maxStorageBuffersInFragmentStage: compatibility ? 4: 8,
463+
maxStorageTexturesPerShaderStage: 4,
464+
maxStorageTexturesInVertexStage: compatibility ? 0 : 8,
465+
maxStorageTexturesInFragmentStage: compatibility ? 4 : 8,
466+
maxUniformBuffersPerShaderStage: 12,
467+
maxUniformBufferBindingSize: compatibility ? 16384 : 65536,
468+
maxStorageBufferBindingSize: 134217728,
469+
minUniformBufferOffsetAlignment: 256,
470+
minStorageBufferOffsetAlignment: 256,
471+
maxVertexBuffers: 8,
472+
maxBufferSize: 268435456,
473+
maxVertexAttributes: 16,
474+
maxVertexBufferArrayStride: 2048,
475+
maxInterStageShaderVariables: compatibility ? 15 : 16,
476+
maxColorAttachments: compatibility ? 4 : 8,
477+
maxColorAttachmentBytesPerSample: 32,
478+
maxComputeWorkgroupStorageSize: 16384,
479+
maxComputeInvocationsPerWorkgroup: compatibility ? 128 : 256,
480+
maxComputeWorkgroupSizeX: compatibility ? 128 : 256,
481+
maxComputeWorkgroupSizeY: compatibility ? 128 : 256,
482+
maxComputeWorkgroupSizeZ: 64,
483+
maxComputeWorkgroupsPerDimension: 65535
484+
};
485+
limits[Symbol.toStringTag] = "GPUSupportedLimits";
486+
return limits;
487+
}
488+
445489
function __WebGPUReconstruct_GPU_requestAdapter(originalMethod, options) {
446490
__WebGPUReconstruct_DebugOutput("requestAdapter");
447491

@@ -454,6 +498,12 @@ function __WebGPUReconstruct_GPU_requestAdapter(originalMethod, options) {
454498
}
455499
}
456500
adapter.__defineGetter__("features", function() { return features;});
501+
502+
if (__webGPUReconstruct.configuration.adapterDefaultLimits) {
503+
let limits = __WebGPUReconstruct_getDefaultLimits(options.featureLevel === "compatibility");
504+
adapter.__defineGetter__("limits", function() { return limits;});
505+
}
506+
457507
return adapter;
458508
});
459509
});
@@ -666,6 +716,12 @@ $WRAP_COMMANDS
666716
this.configuration.captureMaxFrames = Number(this.configuration.captureMaxFrames);
667717
}
668718

719+
if (this.configuration.adapterDefaultLimits === undefined) {
720+
this.configuration.adapterDefaultLimits = false;
721+
} else {
722+
this.configuration.adapterDefaultLimits = (this.configuration.adapterDefaultLimits === true) || (this.configuration.adapterDefaultLimits === "true");
723+
}
724+
669725
if (this.configuration.externalTextureScale === undefined) {
670726
this.configuration.externalTextureScale = 100;
671727
} else {

capture/scripts/options.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
const saveOptions = () => {
22
const captureFilename = document.getElementById('captureFilename').value;
33
const captureMaxFrames = document.getElementById('captureMaxFrames').value;
4+
const adapterDefaultLimits = document.getElementById('adapterDefaultLimits').checked;
45
const externalTextureScale = document.getElementById('externalTextureScale').value;
56

67
chrome.storage.local.set(
78
{
89
captureFilename: captureFilename,
910
captureMaxFrames: captureMaxFrames,
11+
adapterDefaultLimits: String(adapterDefaultLimits),
1012
externalTextureScale: externalTextureScale
1113
},
1214
() => {
@@ -25,11 +27,13 @@ const restoreOptions = () => {
2527
{
2628
captureFilename: "capture.wgpur",
2729
captureMaxFrames: "0",
30+
adapterDefaultLimits: "false",
2831
externalTextureScale: "100"
2932
},
3033
(items) => {
3134
document.getElementById('captureFilename').value = items.captureFilename;
3235
document.getElementById('captureMaxFrames').value = items.captureMaxFrames;
36+
document.getElementById('adapterDefaultLimits').checked = (items.adapterDefaultLimits === "true");
3337
document.getElementById('externalTextureScale').value = items.externalTextureScale;
3438
}
3539
);

0 commit comments

Comments
 (0)