mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-13 10:51:35 +00:00
dawn.json: Make textureDescriptor use Extent3D
This matches WebGPU and is a good test of having structures include other structures by value. BUG=dawn:13 Change-Id: Ibd5ea1340338e5aa16069499c498ac5a455fc2cd Reviewed-on: https://dawn-review.googlesource.com/1500 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
1e68479cd6
commit
29353d6ee3
12
dawn.json
12
dawn.json
@ -665,6 +665,14 @@
|
|||||||
"device error callback": {
|
"device error callback": {
|
||||||
"category": "natively defined"
|
"category": "natively defined"
|
||||||
},
|
},
|
||||||
|
"extent 3D": {
|
||||||
|
"category": "structure",
|
||||||
|
"members": [
|
||||||
|
{"name": "width", "type": "uint32_t"},
|
||||||
|
{"name": "height", "type": "uint32_t"},
|
||||||
|
{"name": "depth", "type": "uint32_t"}
|
||||||
|
]
|
||||||
|
},
|
||||||
"face": {
|
"face": {
|
||||||
"category": "bitmask",
|
"category": "bitmask",
|
||||||
"values": [
|
"values": [
|
||||||
@ -996,9 +1004,7 @@
|
|||||||
"members": [
|
"members": [
|
||||||
{"name": "usage", "type": "texture usage bit"},
|
{"name": "usage", "type": "texture usage bit"},
|
||||||
{"name": "dimension", "type": "texture dimension"},
|
{"name": "dimension", "type": "texture dimension"},
|
||||||
{"name": "width", "type": "uint32_t"},
|
{"name": "size", "type": "extent 3D"},
|
||||||
{"name": "height", "type": "uint32_t"},
|
|
||||||
{"name": "depth", "type": "uint32_t"},
|
|
||||||
{"name": "arrayLayer", "type": "uint32_t"},
|
{"name": "arrayLayer", "type": "uint32_t"},
|
||||||
{"name": "format", "type": "texture format"},
|
{"name": "format", "type": "texture format"},
|
||||||
{"name": "mipLevel", "type": "uint32_t"}
|
{"name": "mipLevel", "type": "uint32_t"}
|
||||||
|
@ -50,9 +50,9 @@ void initBuffers() {
|
|||||||
void initTextures() {
|
void initTextures() {
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = 1024;
|
descriptor.size.width = 1024;
|
||||||
descriptor.height = 1024;
|
descriptor.size.height = 1024;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||||
descriptor.mipLevel = 1;
|
descriptor.mipLevel = 1;
|
||||||
|
@ -138,9 +138,9 @@ dawn::SwapChain GetSwapChain(const dawn::Device &device) {
|
|||||||
dawn::TextureView CreateDefaultDepthStencilView(const dawn::Device& device) {
|
dawn::TextureView CreateDefaultDepthStencilView(const dawn::Device& device) {
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = 640;
|
descriptor.size.width = 640;
|
||||||
descriptor.height = 480;
|
descriptor.size.height = 480;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = dawn::TextureFormat::D32FloatS8Uint;
|
descriptor.format = dawn::TextureFormat::D32FloatS8Uint;
|
||||||
descriptor.mipLevel = 1;
|
descriptor.mipLevel = 1;
|
||||||
|
@ -384,9 +384,9 @@ namespace {
|
|||||||
|
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = iImage.width;
|
descriptor.size.width = iImage.width;
|
||||||
descriptor.height = iImage.height;
|
descriptor.size.height = iImage.height;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = format;
|
descriptor.format = format;
|
||||||
descriptor.mipLevel = 1;
|
descriptor.mipLevel = 1;
|
||||||
|
@ -171,6 +171,42 @@ def link_structure(struct, types):
|
|||||||
else:
|
else:
|
||||||
member.length = members_by_name[m['length']]
|
member.length = members_by_name[m['length']]
|
||||||
|
|
||||||
|
# Sort structures so that if struct A has struct B as a member, then B is listed before A
|
||||||
|
# This is a form of topological sort where we try to keep the order reasonably similar to the
|
||||||
|
# original order (though th sort isn't technically stable).
|
||||||
|
# It works by computing for each struct type what is the depth of its DAG of dependents, then
|
||||||
|
# resorting based on that depth using Python's stable sort. This makes a toposort because if
|
||||||
|
# A depends on B then its depth will be bigger than B's. It is also nice because all nodes
|
||||||
|
# with the same depth are kept in the input order.
|
||||||
|
def topo_sort_structure(structs):
|
||||||
|
for struct in structs:
|
||||||
|
struct.visited = False
|
||||||
|
struct.subdag_depth = 0
|
||||||
|
|
||||||
|
def compute_depth(struct):
|
||||||
|
if struct.visited:
|
||||||
|
return struct.subdag_depth
|
||||||
|
|
||||||
|
max_dependent_depth = 0
|
||||||
|
for member in struct.members:
|
||||||
|
if member.type.category == 'structure' and member.annotation == 'value':
|
||||||
|
max_dependent_depth = max(max_dependent_depth, compute_depth(member.type) + 1)
|
||||||
|
|
||||||
|
struct.subdag_depth = max_dependent_depth
|
||||||
|
struct.visited = True
|
||||||
|
return struct.subdag_depth
|
||||||
|
|
||||||
|
for struct in structs:
|
||||||
|
compute_depth(struct)
|
||||||
|
|
||||||
|
result = sorted(structs, key=lambda struct: struct.subdag_depth)
|
||||||
|
|
||||||
|
for struct in structs:
|
||||||
|
del struct.visited
|
||||||
|
del struct.subdag_depth
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
def parse_json(json):
|
def parse_json(json):
|
||||||
category_to_parser = {
|
category_to_parser = {
|
||||||
'bitmask': BitmaskType,
|
'bitmask': BitmaskType,
|
||||||
@ -204,6 +240,8 @@ def parse_json(json):
|
|||||||
for category in by_category.keys():
|
for category in by_category.keys():
|
||||||
by_category[category] = sorted(by_category[category], key=lambda typ: typ.name.canonical_case())
|
by_category[category] = sorted(by_category[category], key=lambda typ: typ.name.canonical_case())
|
||||||
|
|
||||||
|
by_category['structure'] = topo_sort_structure(by_category['structure'])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'types': types,
|
'types': types,
|
||||||
'by_category': by_category
|
'by_category': by_category
|
||||||
|
@ -61,9 +61,9 @@ namespace dawn_native {
|
|||||||
|
|
||||||
TextureDescriptor descriptor;
|
TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = mWidth;
|
descriptor.size.width = mWidth;
|
||||||
descriptor.height = mHeight;
|
descriptor.size.height = mHeight;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = mFormat;
|
descriptor.format = mFormat;
|
||||||
descriptor.mipLevel = 1;
|
descriptor.mipLevel = 1;
|
||||||
|
@ -29,8 +29,9 @@ namespace dawn_native {
|
|||||||
DAWN_TRY(ValidateTextureFormat(descriptor->format));
|
DAWN_TRY(ValidateTextureFormat(descriptor->format));
|
||||||
|
|
||||||
// TODO(jiawei.shao@intel.com): check stuff based on the dimension
|
// TODO(jiawei.shao@intel.com): check stuff based on the dimension
|
||||||
if (descriptor->width == 0 || descriptor->height == 0 || descriptor->depth == 0 ||
|
if (descriptor->size.width == 0 || descriptor->size.height == 0 ||
|
||||||
descriptor->arrayLayer == 0 || descriptor->mipLevel == 0) {
|
descriptor->size.depth == 0 || descriptor->arrayLayer == 0 ||
|
||||||
|
descriptor->mipLevel == 0) {
|
||||||
return DAWN_VALIDATION_ERROR("Cannot create an empty texture");
|
return DAWN_VALIDATION_ERROR("Cannot create an empty texture");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,9 +90,9 @@ namespace dawn_native {
|
|||||||
: mDevice(device),
|
: mDevice(device),
|
||||||
mDimension(descriptor->dimension),
|
mDimension(descriptor->dimension),
|
||||||
mFormat(descriptor->format),
|
mFormat(descriptor->format),
|
||||||
mWidth(descriptor->width),
|
mWidth(descriptor->size.width),
|
||||||
mHeight(descriptor->height),
|
mHeight(descriptor->size.height),
|
||||||
mDepth(descriptor->depth),
|
mDepth(descriptor->size.depth),
|
||||||
mArrayLayers(descriptor->arrayLayer),
|
mArrayLayers(descriptor->arrayLayer),
|
||||||
mNumMipLevels(descriptor->mipLevel),
|
mNumMipLevels(descriptor->mipLevel),
|
||||||
mUsage(descriptor->usage) {
|
mUsage(descriptor->usage) {
|
||||||
|
@ -692,9 +692,9 @@ TEST_P(BlendStateTest, IndependentBlendState) {
|
|||||||
|
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = kRTSize;
|
descriptor.size.width = kRTSize;
|
||||||
descriptor.height = kRTSize;
|
descriptor.size.height = kRTSize;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||||
descriptor.mipLevel = 1;
|
descriptor.mipLevel = 1;
|
||||||
|
@ -75,9 +75,9 @@ class CopyTests_T2B : public CopyTests {
|
|||||||
// Create a texture that is `width` x `height` with (`level` + 1) mip levels.
|
// Create a texture that is `width` x `height` with (`level` + 1) mip levels.
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = textureSpec.width;
|
descriptor.size.width = textureSpec.width;
|
||||||
descriptor.height = textureSpec.height;
|
descriptor.size.height = textureSpec.height;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = textureSpec.arrayLayer;
|
descriptor.arrayLayer = textureSpec.arrayLayer;
|
||||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||||
descriptor.mipLevel = textureSpec.level + 1;
|
descriptor.mipLevel = textureSpec.level + 1;
|
||||||
@ -175,9 +175,9 @@ protected:
|
|||||||
// Create a texture that is `width` x `height` with (`level` + 1) mip levels.
|
// Create a texture that is `width` x `height` with (`level` + 1) mip levels.
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = textureSpec.width;
|
descriptor.size.width = textureSpec.width;
|
||||||
descriptor.height = textureSpec.height;
|
descriptor.size.height = textureSpec.height;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||||
descriptor.mipLevel = textureSpec.level + 1;
|
descriptor.mipLevel = textureSpec.level + 1;
|
||||||
|
@ -26,9 +26,9 @@ class DepthStencilStateTest : public DawnTest {
|
|||||||
|
|
||||||
dawn::TextureDescriptor renderTargetDescriptor;
|
dawn::TextureDescriptor renderTargetDescriptor;
|
||||||
renderTargetDescriptor.dimension = dawn::TextureDimension::e2D;
|
renderTargetDescriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
renderTargetDescriptor.width = kRTSize;
|
renderTargetDescriptor.size.width = kRTSize;
|
||||||
renderTargetDescriptor.height = kRTSize;
|
renderTargetDescriptor.size.height = kRTSize;
|
||||||
renderTargetDescriptor.depth = 1;
|
renderTargetDescriptor.size.depth = 1;
|
||||||
renderTargetDescriptor.arrayLayer = 1;
|
renderTargetDescriptor.arrayLayer = 1;
|
||||||
renderTargetDescriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
renderTargetDescriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||||
renderTargetDescriptor.mipLevel = 1;
|
renderTargetDescriptor.mipLevel = 1;
|
||||||
@ -39,9 +39,9 @@ class DepthStencilStateTest : public DawnTest {
|
|||||||
|
|
||||||
dawn::TextureDescriptor depthDescriptor;
|
dawn::TextureDescriptor depthDescriptor;
|
||||||
depthDescriptor.dimension = dawn::TextureDimension::e2D;
|
depthDescriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
depthDescriptor.width = kRTSize;
|
depthDescriptor.size.width = kRTSize;
|
||||||
depthDescriptor.height = kRTSize;
|
depthDescriptor.size.height = kRTSize;
|
||||||
depthDescriptor.depth = 1;
|
depthDescriptor.size.depth = 1;
|
||||||
depthDescriptor.arrayLayer = 1;
|
depthDescriptor.arrayLayer = 1;
|
||||||
depthDescriptor.format = dawn::TextureFormat::D32FloatS8Uint;
|
depthDescriptor.format = dawn::TextureFormat::D32FloatS8Uint;
|
||||||
depthDescriptor.mipLevel = 1;
|
depthDescriptor.mipLevel = 1;
|
||||||
|
@ -57,9 +57,9 @@ class RenderPassLoadOpTests : public DawnTest {
|
|||||||
|
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = kRTSize;
|
descriptor.size.width = kRTSize;
|
||||||
descriptor.height = kRTSize;
|
descriptor.size.height = kRTSize;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||||
descriptor.mipLevel = 1;
|
descriptor.mipLevel = 1;
|
||||||
|
@ -82,9 +82,9 @@ protected:
|
|||||||
|
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = 2;
|
descriptor.size.width = 2;
|
||||||
descriptor.height = 2;
|
descriptor.size.height = 2;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||||
descriptor.mipLevel = 1;
|
descriptor.mipLevel = 1;
|
||||||
|
@ -30,9 +30,9 @@ class CopyCommandTest : public ValidationTest {
|
|||||||
dawn::TextureFormat format, dawn::TextureUsageBit usage) {
|
dawn::TextureFormat format, dawn::TextureUsageBit usage) {
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = width;
|
descriptor.size.width = width;
|
||||||
descriptor.height = height;
|
descriptor.size.height = height;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = arrayLayer;
|
descriptor.arrayLayer = arrayLayer;
|
||||||
descriptor.format = format;
|
descriptor.format = format;
|
||||||
descriptor.mipLevel = levels;
|
descriptor.mipLevel = levels;
|
||||||
|
@ -24,9 +24,9 @@ class RenderPassDescriptorValidationTest : public ValidationTest {
|
|||||||
dawn::TextureView Create2DAttachment(dawn::Device& device, uint32_t width, uint32_t height, dawn::TextureFormat format) {
|
dawn::TextureView Create2DAttachment(dawn::Device& device, uint32_t width, uint32_t height, dawn::TextureFormat format) {
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = width;
|
descriptor.size.width = width;
|
||||||
descriptor.height = height;
|
descriptor.size.height = height;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = format;
|
descriptor.format = format;
|
||||||
descriptor.mipLevel = 1;
|
descriptor.mipLevel = 1;
|
||||||
|
@ -76,9 +76,9 @@ std::string ValidationTest::GetLastDeviceErrorMessage() const {
|
|||||||
dawn::RenderPassDescriptor ValidationTest::CreateSimpleRenderPass() {
|
dawn::RenderPassDescriptor ValidationTest::CreateSimpleRenderPass() {
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = 640;
|
descriptor.size.width = 640;
|
||||||
descriptor.height = 480;
|
descriptor.size.height = 480;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||||
descriptor.mipLevel = 1;
|
descriptor.mipLevel = 1;
|
||||||
@ -129,9 +129,9 @@ ValidationTest::DummyRenderPass ValidationTest::CreateDummyRenderPass() {
|
|||||||
|
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = dummy.width;
|
descriptor.size.width = dummy.width;
|
||||||
descriptor.height = dummy.height;
|
descriptor.size.height = dummy.height;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = dummy.attachmentFormat;
|
descriptor.format = dummy.attachmentFormat;
|
||||||
descriptor.mipLevel = 1;
|
descriptor.mipLevel = 1;
|
||||||
|
@ -135,9 +135,9 @@ namespace utils {
|
|||||||
result.colorFormat = dawn::TextureFormat::R8G8B8A8Unorm;
|
result.colorFormat = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.width = width;
|
descriptor.size.width = width;
|
||||||
descriptor.height = height;
|
descriptor.size.height = height;
|
||||||
descriptor.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayer = 1;
|
descriptor.arrayLayer = 1;
|
||||||
descriptor.format = result.colorFormat;
|
descriptor.format = result.colorFormat;
|
||||||
descriptor.mipLevel = 1;
|
descriptor.mipLevel = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user