mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-05 03:35:56 +00:00
Use the new semantic constant value information to significantly reduce the complex indexing logic emitted for UBO accesses. This will dramatically reduce the number of `for` loops that are decayed to `while` loops. Change-Id: I1b0adb5edde2b4ed39c6beafc2e28106b86e0edd Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57701 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com>
30 lines
970 B
HLSL
30 lines
970 B
HLSL
ByteAddressBuffer firstMatrix : register(t0, space0);
|
|
ByteAddressBuffer secondMatrix : register(t1, space0);
|
|
RWByteAddressBuffer resultMatrix : register(u2, space0);
|
|
cbuffer cbuffer_uniforms : register(b3, space0) {
|
|
uint4 uniforms[2];
|
|
};
|
|
|
|
struct tint_symbol_1 {
|
|
uint3 global_id : SV_DispatchThreadID;
|
|
};
|
|
|
|
[numthreads(2, 2, 1)]
|
|
void main(tint_symbol_1 tint_symbol) {
|
|
const uint3 global_id = tint_symbol.global_id;
|
|
const uint2 resultCell = uint2(global_id.y, global_id.x);
|
|
const uint dimInner = uniforms[0].y;
|
|
const uint dimOutter = uniforms[1].y;
|
|
uint result = 0u;
|
|
{
|
|
for(uint i = 0u; (i < dimInner); i = (i + 1u)) {
|
|
const uint a = (i + (resultCell.x * dimInner));
|
|
const uint b = (resultCell.y + (i * dimOutter));
|
|
result = (result + (firstMatrix.Load((4u * a)) * secondMatrix.Load((4u * b))));
|
|
}
|
|
}
|
|
const uint index = (resultCell.y + (resultCell.x * dimOutter));
|
|
resultMatrix.Store((4u * index), asuint(result));
|
|
return;
|
|
}
|