-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validation tests for resource compatibility of render pipelines (#3441)
* Reuses compute pipeline resource infrastructure * small update to generate consistent fragment shader * Filters out writable storge buffer and storage texture resources from the api side for vertex shaders
- Loading branch information
1 parent
69b12ab
commit c0181cf
Showing
3 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
src/webgpu/api/validation/render_pipeline/resource_compatibility.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
export const description = ` | ||
Tests for resource compatibilty between pipeline layout and shader modules | ||
`; | ||
|
||
import { makeTestGroup } from '../../../../common/framework/test_group.js'; | ||
import { keysOf } from '../../../../common/util/data_tables.js'; | ||
import { | ||
kAPIResources, | ||
getWGSLShaderForResource, | ||
getAPIBindGroupLayoutForResource, | ||
doResourcesMatch, | ||
} from '../utils.js'; | ||
|
||
import { CreateRenderPipelineValidationTest } from './common.js'; | ||
|
||
export const g = makeTestGroup(CreateRenderPipelineValidationTest); | ||
|
||
g.test('resource_compatibility') | ||
.desc( | ||
'Tests validation of resource (bind group) compatibility between pipeline layout and WGSL shader' | ||
) | ||
.params(u => | ||
u // | ||
.combine('stage', ['vertex', 'fragment'] as const) | ||
.combine('apiResource', keysOf(kAPIResources)) | ||
.filter(t => { | ||
const res = kAPIResources[t.apiResource]; | ||
if (t.stage === 'vertex') { | ||
if (res.buffer && res.buffer.type === 'storage') { | ||
return false; | ||
} | ||
if (res.storageTexture && res.storageTexture.access !== 'read-only') { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}) | ||
.beginSubcases() | ||
.combine('isAsync', [true, false] as const) | ||
.combine('wgslResource', keysOf(kAPIResources)) | ||
) | ||
.fn(t => { | ||
const apiResource = kAPIResources[t.params.apiResource]; | ||
const wgslResource = kAPIResources[t.params.wgslResource]; | ||
t.skipIf( | ||
wgslResource.storageTexture !== undefined && | ||
wgslResource.storageTexture.access !== 'write-only' && | ||
!t.hasLanguageFeature('readonly_and_readwrite_storage_textures'), | ||
'Storage textures require language feature' | ||
); | ||
const emptyVS = ` | ||
@vertex | ||
fn main() -> @builtin(position) vec4f { | ||
return vec4f(); | ||
} | ||
`; | ||
const emptyFS = ` | ||
@fragment | ||
fn main() -> @location(0) vec4f { | ||
return vec4f(); | ||
} | ||
`; | ||
|
||
const code = getWGSLShaderForResource(t.params.stage, wgslResource); | ||
const vsCode = t.params.stage === 'vertex' ? code : emptyVS; | ||
const fsCode = t.params.stage === 'fragment' ? code : emptyFS; | ||
const gpuStage: GPUShaderStageFlags = | ||
t.params.stage === 'vertex' ? GPUShaderStage.VERTEX : GPUShaderStage.FRAGMENT; | ||
const layout = t.device.createPipelineLayout({ | ||
bindGroupLayouts: [getAPIBindGroupLayoutForResource(t.device, gpuStage, apiResource)], | ||
}); | ||
|
||
const descriptor = { | ||
layout, | ||
vertex: { | ||
module: t.device.createShaderModule({ | ||
code: vsCode, | ||
}), | ||
entryPoint: 'main', | ||
}, | ||
fragment: { | ||
module: t.device.createShaderModule({ | ||
code: fsCode, | ||
}), | ||
entryPoint: 'main', | ||
targets: [{ format: 'rgba8unorm' }] as const, | ||
}, | ||
}; | ||
|
||
t.doCreateRenderPipelineTest( | ||
t.params.isAsync, | ||
doResourcesMatch(apiResource, wgslResource), | ||
descriptor | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters