Remove Bit from TextureUsageBit and BufferUsageBit
This is to match the naming convention of WebGPU's WebIDL and webgpu.h BUG=dawn:22 Change-Id: Ia91c5a018403e6a72eb0311b5f1a072d102282a2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10461 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
e25a3aede0
commit
9e9e29f7a6
10
dawn.json
10
dawn.json
|
@ -180,7 +180,7 @@
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"extensible": true,
|
"extensible": true,
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "usage", "type": "buffer usage bit"},
|
{"name": "usage", "type": "buffer usage"},
|
||||||
{"name": "size", "type": "uint64_t"}
|
{"name": "size", "type": "uint64_t"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -199,7 +199,7 @@
|
||||||
{"value": 3, "name": "context lost"}
|
{"value": 3, "name": "context lost"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"buffer usage bit": {
|
"buffer usage": {
|
||||||
"category": "bitmask",
|
"category": "bitmask",
|
||||||
"values": [
|
"values": [
|
||||||
{"value": 0, "name": "none"},
|
{"value": 0, "name": "none"},
|
||||||
|
@ -1102,7 +1102,7 @@
|
||||||
"name": "configure",
|
"name": "configure",
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "format", "type": "texture format"},
|
{"name": "format", "type": "texture format"},
|
||||||
{"name": "allowed usage", "type": "texture usage bit"},
|
{"name": "allowed usage", "type": "texture usage"},
|
||||||
{"name": "width", "type": "uint32_t"},
|
{"name": "width", "type": "uint32_t"},
|
||||||
{"name": "height", "type": "uint32_t"}
|
{"name": "height", "type": "uint32_t"}
|
||||||
]
|
]
|
||||||
|
@ -1175,7 +1175,7 @@
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"extensible": true,
|
"extensible": true,
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "usage", "type": "texture usage bit"},
|
{"name": "usage", "type": "texture usage"},
|
||||||
{"name": "dimension", "type": "texture dimension", "default": "2D"},
|
{"name": "dimension", "type": "texture dimension", "default": "2D"},
|
||||||
{"name": "size", "type": "extent 3D"},
|
{"name": "size", "type": "extent 3D"},
|
||||||
{"name": "array layer count", "type": "uint32_t", "default": "1"},
|
{"name": "array layer count", "type": "uint32_t", "default": "1"},
|
||||||
|
@ -1256,7 +1256,7 @@
|
||||||
{"value": 4294967295, "name": "none", "valid": false}
|
{"value": 4294967295, "name": "none", "valid": false}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"texture usage bit": {
|
"texture usage": {
|
||||||
"category": "bitmask",
|
"category": "bitmask",
|
||||||
"values": [
|
"values": [
|
||||||
{"value": 0, "name": "none"},
|
{"value": 0, "name": "none"},
|
||||||
|
|
|
@ -52,8 +52,8 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueue();
|
queue = device.CreateQueue();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(),
|
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
||||||
dawn::TextureUsageBit::OutputAttachment, 640, 480);
|
640, 480);
|
||||||
|
|
||||||
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
|
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
|
||||||
#version 450
|
#version 450
|
||||||
|
@ -134,7 +134,7 @@ void init() {
|
||||||
|
|
||||||
dawn::BufferDescriptor bufferDesc;
|
dawn::BufferDescriptor bufferDesc;
|
||||||
bufferDesc.size = kNumTriangles * sizeof(ShaderData);
|
bufferDesc.size = kNumTriangles * sizeof(ShaderData);
|
||||||
bufferDesc.usage = dawn::BufferUsageBit::CopyDst | dawn::BufferUsageBit::Uniform;
|
bufferDesc.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::Uniform;
|
||||||
ubo = device.CreateBuffer(&bufferDesc);
|
ubo = device.CreateBuffer(&bufferDesc);
|
||||||
|
|
||||||
bindGroup =
|
bindGroup =
|
||||||
|
|
|
@ -35,7 +35,7 @@ void init() {
|
||||||
swapchain = dawnDeviceCreateSwapChain(device, &descriptor);
|
swapchain = dawnDeviceCreateSwapChain(device, &descriptor);
|
||||||
}
|
}
|
||||||
swapChainFormat = static_cast<DawnTextureFormat>(GetPreferredSwapChainTextureFormat());
|
swapChainFormat = static_cast<DawnTextureFormat>(GetPreferredSwapChainTextureFormat());
|
||||||
dawnSwapChainConfigure(swapchain, swapChainFormat, DAWN_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT, 640,
|
dawnSwapChainConfigure(swapchain, swapChainFormat, DAWN_TEXTURE_USAGE_OUTPUT_ATTACHMENT, 640,
|
||||||
480);
|
480);
|
||||||
|
|
||||||
const char* vs =
|
const char* vs =
|
||||||
|
|
|
@ -64,10 +64,12 @@ void initBuffers() {
|
||||||
{0.01, -0.02},
|
{0.01, -0.02},
|
||||||
{0.00, 0.02},
|
{0.00, 0.02},
|
||||||
};
|
};
|
||||||
modelBuffer = utils::CreateBufferFromData(device, model, sizeof(model), dawn::BufferUsageBit::Vertex);
|
modelBuffer =
|
||||||
|
utils::CreateBufferFromData(device, model, sizeof(model), dawn::BufferUsage::Vertex);
|
||||||
|
|
||||||
SimParams params = { 0.04f, 0.1f, 0.025f, 0.025f, 0.02f, 0.05f, 0.005f, kNumParticles };
|
SimParams params = { 0.04f, 0.1f, 0.025f, 0.025f, 0.02f, 0.05f, 0.005f, kNumParticles };
|
||||||
updateParams = utils::CreateBufferFromData(device, ¶ms, sizeof(params), dawn::BufferUsageBit::Uniform);
|
updateParams =
|
||||||
|
utils::CreateBufferFromData(device, ¶ms, sizeof(params), dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
std::vector<Particle> initialParticles(kNumParticles);
|
std::vector<Particle> initialParticles(kNumParticles);
|
||||||
{
|
{
|
||||||
|
@ -83,8 +85,8 @@ void initBuffers() {
|
||||||
for (size_t i = 0; i < 2; i++) {
|
for (size_t i = 0; i < 2; i++) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = sizeof(Particle) * kNumParticles;
|
descriptor.size = sizeof(Particle) * kNumParticles;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopyDst | dawn::BufferUsageBit::Vertex |
|
descriptor.usage =
|
||||||
dawn::BufferUsageBit::Storage;
|
dawn::BufferUsage::CopyDst | dawn::BufferUsage::Vertex | dawn::BufferUsage::Storage;
|
||||||
particleBuffers[i] = device.CreateBuffer(&descriptor);
|
particleBuffers[i] = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
particleBuffers[i].SetSubData(0,
|
particleBuffers[i].SetSubData(0,
|
||||||
|
@ -293,8 +295,8 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueue();
|
queue = device.CreateQueue();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(),
|
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
||||||
dawn::TextureUsageBit::OutputAttachment, 640, 480);
|
640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
initRender();
|
initRender();
|
||||||
|
|
|
@ -38,14 +38,16 @@ void initBuffers() {
|
||||||
static const uint32_t indexData[3] = {
|
static const uint32_t indexData[3] = {
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
};
|
};
|
||||||
indexBuffer = utils::CreateBufferFromData(device, indexData, sizeof(indexData), dawn::BufferUsageBit::Index);
|
indexBuffer =
|
||||||
|
utils::CreateBufferFromData(device, indexData, sizeof(indexData), dawn::BufferUsage::Index);
|
||||||
|
|
||||||
static const float vertexData[12] = {
|
static const float vertexData[12] = {
|
||||||
0.0f, 0.5f, 0.0f, 1.0f,
|
0.0f, 0.5f, 0.0f, 1.0f,
|
||||||
-0.5f, -0.5f, 0.0f, 1.0f,
|
-0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
0.5f, -0.5f, 0.0f, 1.0f,
|
0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
};
|
};
|
||||||
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData), dawn::BufferUsageBit::Vertex);
|
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
|
||||||
|
dawn::BufferUsage::Vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTextures() {
|
void initTextures() {
|
||||||
|
@ -58,7 +60,7 @@ void initTextures() {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::Sampled;
|
descriptor.usage = dawn::TextureUsage::CopyDst | dawn::TextureUsage::Sampled;
|
||||||
texture = device.CreateTexture(&descriptor);
|
texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
|
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
|
||||||
|
@ -71,7 +73,7 @@ void initTextures() {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
||||||
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsageBit::CopySrc);
|
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsage::CopySrc);
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
||||||
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||||
dawn::Extent3D copySize = {1024, 1024, 1};
|
dawn::Extent3D copySize = {1024, 1024, 1};
|
||||||
|
@ -88,8 +90,8 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueue();
|
queue = device.CreateQueue();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(),
|
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
||||||
dawn::TextureUsageBit::OutputAttachment, 640, 480);
|
640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
initTextures();
|
initTextures();
|
||||||
|
|
|
@ -62,7 +62,8 @@ void initBuffers() {
|
||||||
20, 21, 22,
|
20, 21, 22,
|
||||||
20, 22, 23
|
20, 22, 23
|
||||||
};
|
};
|
||||||
indexBuffer = utils::CreateBufferFromData(device, indexData, sizeof(indexData), dawn::BufferUsageBit::Index);
|
indexBuffer =
|
||||||
|
utils::CreateBufferFromData(device, indexData, sizeof(indexData), dawn::BufferUsage::Index);
|
||||||
|
|
||||||
static const float vertexData[6 * 4 * 6] = {
|
static const float vertexData[6 * 4 * 6] = {
|
||||||
-1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
|
-1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
|
||||||
|
@ -95,7 +96,8 @@ void initBuffers() {
|
||||||
-1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
-1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
||||||
-1.0, 1.0, -1.0, 1.0, 1.0, 1.0
|
-1.0, 1.0, -1.0, 1.0, 1.0, 1.0
|
||||||
};
|
};
|
||||||
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData), dawn::BufferUsageBit::Vertex);
|
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
|
||||||
|
dawn::BufferUsage::Vertex);
|
||||||
|
|
||||||
static const float planeData[6 * 4] = {
|
static const float planeData[6 * 4] = {
|
||||||
-2.0, -1.0, -2.0, 0.5, 0.5, 0.5,
|
-2.0, -1.0, -2.0, 0.5, 0.5, 0.5,
|
||||||
|
@ -103,7 +105,8 @@ void initBuffers() {
|
||||||
2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
|
2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
|
||||||
-2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
|
-2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
|
||||||
};
|
};
|
||||||
planeBuffer = utils::CreateBufferFromData(device, planeData, sizeof(planeData), dawn::BufferUsageBit::Vertex);
|
planeBuffer = utils::CreateBufferFromData(device, planeData, sizeof(planeData),
|
||||||
|
dawn::BufferUsage::Vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CameraData {
|
struct CameraData {
|
||||||
|
@ -116,8 +119,8 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueue();
|
queue = device.CreateQueue();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(),
|
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
||||||
dawn::TextureUsageBit::OutputAttachment, 640, 480);
|
640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
|
|
||||||
|
@ -176,14 +179,16 @@ void init() {
|
||||||
|
|
||||||
dawn::BufferDescriptor cameraBufDesc;
|
dawn::BufferDescriptor cameraBufDesc;
|
||||||
cameraBufDesc.size = sizeof(CameraData);
|
cameraBufDesc.size = sizeof(CameraData);
|
||||||
cameraBufDesc.usage = dawn::BufferUsageBit::CopyDst | dawn::BufferUsageBit::Uniform;
|
cameraBufDesc.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::Uniform;
|
||||||
cameraBuffer = device.CreateBuffer(&cameraBufDesc);
|
cameraBuffer = device.CreateBuffer(&cameraBufDesc);
|
||||||
|
|
||||||
glm::mat4 transform(1.0);
|
glm::mat4 transform(1.0);
|
||||||
transformBuffer[0] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4), dawn::BufferUsageBit::Uniform);
|
transformBuffer[0] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4),
|
||||||
|
dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
transform = glm::translate(transform, glm::vec3(0.f, -2.f, 0.f));
|
transform = glm::translate(transform, glm::vec3(0.f, -2.f, 0.f));
|
||||||
transformBuffer[1] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4), dawn::BufferUsageBit::Uniform);
|
transformBuffer[1] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4),
|
||||||
|
dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
bindGroup[0] = utils::MakeBindGroup(device, bgl, {
|
bindGroup[0] = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, cameraBuffer, 0, sizeof(CameraData)},
|
{0, cameraBuffer, 0, sizeof(CameraData)},
|
||||||
|
|
|
@ -173,7 +173,7 @@ dawn::TextureView CreateDefaultDepthStencilView(const dawn::Device& device) {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::Depth24PlusStencil8;
|
descriptor.format = dawn::TextureFormat::Depth24PlusStencil8;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
|
descriptor.usage = dawn::TextureUsage::OutputAttachment;
|
||||||
auto depthStencilTexture = device.CreateTexture(&descriptor);
|
auto depthStencilTexture = device.CreateTexture(&descriptor);
|
||||||
return depthStencilTexture.CreateDefaultView();
|
return depthStencilTexture.CreateDefaultView();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ DawnSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
||||||
reinterpret_cast<T*>(userData)->Init(ctx);
|
reinterpret_cast<T*>(userData)->Init(ctx);
|
||||||
};
|
};
|
||||||
impl.Destroy = [](void* userData) { delete reinterpret_cast<T*>(userData); };
|
impl.Destroy = [](void* userData) { delete reinterpret_cast<T*>(userData); };
|
||||||
impl.Configure = [](void* userData, DawnTextureFormat format, DawnTextureUsageBit allowedUsage,
|
impl.Configure = [](void* userData, DawnTextureFormat format, DawnTextureUsage allowedUsage,
|
||||||
uint32_t width, uint32_t height) {
|
uint32_t width, uint32_t height) {
|
||||||
return static_cast<T*>(userData)->Configure(format, allowedUsage, width, height);
|
return static_cast<T*>(userData)->Configure(format, allowedUsage, width, height);
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
MaybeError ValidateBufferBinding(const DeviceBase* device,
|
MaybeError ValidateBufferBinding(const DeviceBase* device,
|
||||||
const BindGroupBinding& binding,
|
const BindGroupBinding& binding,
|
||||||
dawn::BufferUsageBit requiredUsage) {
|
dawn::BufferUsage requiredUsage) {
|
||||||
if (binding.buffer == nullptr || binding.sampler != nullptr ||
|
if (binding.buffer == nullptr || binding.sampler != nullptr ||
|
||||||
binding.textureView != nullptr) {
|
binding.textureView != nullptr) {
|
||||||
return DAWN_VALIDATION_ERROR("expected buffer binding");
|
return DAWN_VALIDATION_ERROR("expected buffer binding");
|
||||||
|
@ -63,7 +63,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
MaybeError ValidateTextureBinding(const DeviceBase* device,
|
MaybeError ValidateTextureBinding(const DeviceBase* device,
|
||||||
const BindGroupBinding& binding,
|
const BindGroupBinding& binding,
|
||||||
dawn::TextureUsageBit requiredUsage,
|
dawn::TextureUsage requiredUsage,
|
||||||
bool multisampledBinding,
|
bool multisampledBinding,
|
||||||
dawn::TextureComponentType requiredComponentType) {
|
dawn::TextureComponentType requiredComponentType) {
|
||||||
if (binding.textureView == nullptr || binding.sampler != nullptr ||
|
if (binding.textureView == nullptr || binding.sampler != nullptr ||
|
||||||
|
@ -139,14 +139,14 @@ namespace dawn_native {
|
||||||
// Perform binding-type specific validation.
|
// Perform binding-type specific validation.
|
||||||
switch (layoutInfo.types[bindingIndex]) {
|
switch (layoutInfo.types[bindingIndex]) {
|
||||||
case dawn::BindingType::UniformBuffer:
|
case dawn::BindingType::UniformBuffer:
|
||||||
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsageBit::Uniform));
|
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsage::Uniform));
|
||||||
break;
|
break;
|
||||||
case dawn::BindingType::StorageBuffer:
|
case dawn::BindingType::StorageBuffer:
|
||||||
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsageBit::Storage));
|
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsage::Storage));
|
||||||
break;
|
break;
|
||||||
case dawn::BindingType::SampledTexture:
|
case dawn::BindingType::SampledTexture:
|
||||||
DAWN_TRY(
|
DAWN_TRY(
|
||||||
ValidateTextureBinding(device, binding, dawn::TextureUsageBit::Sampled,
|
ValidateTextureBinding(device, binding, dawn::TextureUsage::Sampled,
|
||||||
layoutInfo.multisampled[bindingIndex],
|
layoutInfo.multisampled[bindingIndex],
|
||||||
layoutInfo.textureComponentTypes[bindingIndex]));
|
layoutInfo.textureComponentTypes[bindingIndex]));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -89,19 +89,19 @@ namespace dawn_native {
|
||||||
return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
|
return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
|
||||||
}
|
}
|
||||||
|
|
||||||
DAWN_TRY(ValidateBufferUsageBit(descriptor->usage));
|
DAWN_TRY(ValidateBufferUsage(descriptor->usage));
|
||||||
|
|
||||||
dawn::BufferUsageBit usage = descriptor->usage;
|
dawn::BufferUsage usage = descriptor->usage;
|
||||||
|
|
||||||
const dawn::BufferUsageBit kMapWriteAllowedUsages =
|
const dawn::BufferUsage kMapWriteAllowedUsages =
|
||||||
dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc;
|
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc;
|
||||||
if (usage & dawn::BufferUsageBit::MapWrite && (usage & kMapWriteAllowedUsages) != usage) {
|
if (usage & dawn::BufferUsage::MapWrite && (usage & kMapWriteAllowedUsages) != usage) {
|
||||||
return DAWN_VALIDATION_ERROR("Only CopySrc is allowed with MapWrite");
|
return DAWN_VALIDATION_ERROR("Only CopySrc is allowed with MapWrite");
|
||||||
}
|
}
|
||||||
|
|
||||||
const dawn::BufferUsageBit kMapReadAllowedUsages =
|
const dawn::BufferUsage kMapReadAllowedUsages =
|
||||||
dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::CopyDst;
|
dawn::BufferUsage::MapRead | dawn::BufferUsage::CopyDst;
|
||||||
if (usage & dawn::BufferUsageBit::MapRead && (usage & kMapReadAllowedUsages) != usage) {
|
if (usage & dawn::BufferUsage::MapRead && (usage & kMapReadAllowedUsages) != usage) {
|
||||||
return DAWN_VALIDATION_ERROR("Only CopyDst is allowed with MapRead");
|
return DAWN_VALIDATION_ERROR("Only CopyDst is allowed with MapRead");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ namespace dawn_native {
|
||||||
return mSize;
|
return mSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::BufferUsageBit BufferBase::GetUsage() const {
|
dawn::BufferUsage BufferBase::GetUsage() const {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
return mUsage;
|
return mUsage;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::MapReadAsync(DawnBufferMapReadCallback callback, void* userdata) {
|
void BufferBase::MapReadAsync(DawnBufferMapReadCallback callback, void* userdata) {
|
||||||
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsageBit::MapRead))) {
|
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsage::MapRead))) {
|
||||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::MapWriteAsync(DawnBufferMapWriteCallback callback, void* userdata) {
|
void BufferBase::MapWriteAsync(DawnBufferMapWriteCallback callback, void* userdata) {
|
||||||
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsageBit::MapWrite))) {
|
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsage::MapWrite))) {
|
||||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -381,14 +381,14 @@ namespace dawn_native {
|
||||||
return DAWN_VALIDATION_ERROR("Buffer subdata out of range");
|
return DAWN_VALIDATION_ERROR("Buffer subdata out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(mUsage & dawn::BufferUsageBit::CopyDst)) {
|
if (!(mUsage & dawn::BufferUsage::CopyDst)) {
|
||||||
return DAWN_VALIDATION_ERROR("Buffer needs the CopyDst usage bit");
|
return DAWN_VALIDATION_ERROR("Buffer needs the CopyDst usage bit");
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError BufferBase::ValidateMap(dawn::BufferUsageBit requiredUsage) const {
|
MaybeError BufferBase::ValidateMap(dawn::BufferUsage requiredUsage) const {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||||
|
|
||||||
switch (mState) {
|
switch (mState) {
|
||||||
|
@ -416,8 +416,7 @@ namespace dawn_native {
|
||||||
// even if it did not have a mappable usage.
|
// even if it did not have a mappable usage.
|
||||||
return {};
|
return {};
|
||||||
case BufferState::Unmapped:
|
case BufferState::Unmapped:
|
||||||
if ((mUsage & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) ==
|
if ((mUsage & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) == 0) {
|
||||||
0) {
|
|
||||||
return DAWN_VALIDATION_ERROR("Buffer does not have map usage");
|
return DAWN_VALIDATION_ERROR("Buffer does not have map usage");
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -27,13 +27,12 @@ namespace dawn_native {
|
||||||
|
|
||||||
MaybeError ValidateBufferDescriptor(DeviceBase* device, const BufferDescriptor* descriptor);
|
MaybeError ValidateBufferDescriptor(DeviceBase* device, const BufferDescriptor* descriptor);
|
||||||
|
|
||||||
static constexpr dawn::BufferUsageBit kReadOnlyBufferUsages =
|
static constexpr dawn::BufferUsage kReadOnlyBufferUsages =
|
||||||
dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::CopySrc |
|
dawn::BufferUsage::MapRead | dawn::BufferUsage::CopySrc | dawn::BufferUsage::Index |
|
||||||
dawn::BufferUsageBit::Index | dawn::BufferUsageBit::Vertex | dawn::BufferUsageBit::Uniform;
|
dawn::BufferUsage::Vertex | dawn::BufferUsage::Uniform;
|
||||||
|
|
||||||
static constexpr dawn::BufferUsageBit kWritableBufferUsages = dawn::BufferUsageBit::MapWrite |
|
static constexpr dawn::BufferUsage kWritableBufferUsages =
|
||||||
dawn::BufferUsageBit::CopyDst |
|
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopyDst | dawn::BufferUsage::Storage;
|
||||||
dawn::BufferUsageBit::Storage;
|
|
||||||
|
|
||||||
class BufferBase : public ObjectBase {
|
class BufferBase : public ObjectBase {
|
||||||
enum class BufferState {
|
enum class BufferState {
|
||||||
|
@ -52,7 +51,7 @@ namespace dawn_native {
|
||||||
uint8_t** mappedPointer);
|
uint8_t** mappedPointer);
|
||||||
|
|
||||||
uint64_t GetSize() const;
|
uint64_t GetSize() const;
|
||||||
dawn::BufferUsageBit GetUsage() const;
|
dawn::BufferUsage GetUsage() const;
|
||||||
|
|
||||||
MaybeError MapAtCreation(uint8_t** mappedPointer);
|
MaybeError MapAtCreation(uint8_t** mappedPointer);
|
||||||
|
|
||||||
|
@ -91,12 +90,12 @@ namespace dawn_native {
|
||||||
MaybeError CopyFromStagingBuffer();
|
MaybeError CopyFromStagingBuffer();
|
||||||
|
|
||||||
MaybeError ValidateSetSubData(uint32_t start, uint32_t count) const;
|
MaybeError ValidateSetSubData(uint32_t start, uint32_t count) const;
|
||||||
MaybeError ValidateMap(dawn::BufferUsageBit requiredUsage) const;
|
MaybeError ValidateMap(dawn::BufferUsage requiredUsage) const;
|
||||||
MaybeError ValidateUnmap() const;
|
MaybeError ValidateUnmap() const;
|
||||||
MaybeError ValidateDestroy() const;
|
MaybeError ValidateDestroy() const;
|
||||||
|
|
||||||
uint64_t mSize = 0;
|
uint64_t mSize = 0;
|
||||||
dawn::BufferUsageBit mUsage = dawn::BufferUsageBit::None;
|
dawn::BufferUsage mUsage = dawn::BufferUsage::None;
|
||||||
|
|
||||||
DawnBufferMapReadCallback mMapReadCallback = nullptr;
|
DawnBufferMapReadCallback mMapReadCallback = nullptr;
|
||||||
DawnBufferMapWriteCallback mMapWriteCallback = nullptr;
|
DawnBufferMapWriteCallback mMapWriteCallback = nullptr;
|
||||||
|
|
|
@ -242,7 +242,7 @@ namespace dawn_native {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError ValidateCanUseAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
|
MaybeError ValidateCanUseAs(BufferBase* buffer, dawn::BufferUsage usage) {
|
||||||
ASSERT(HasZeroOrOneBits(usage));
|
ASSERT(HasZeroOrOneBits(usage));
|
||||||
if (!(buffer->GetUsage() & usage)) {
|
if (!(buffer->GetUsage() & usage)) {
|
||||||
return DAWN_VALIDATION_ERROR("buffer doesn't have the required usage.");
|
return DAWN_VALIDATION_ERROR("buffer doesn't have the required usage.");
|
||||||
|
@ -251,7 +251,7 @@ namespace dawn_native {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError ValidateCanUseAs(TextureBase* texture, dawn::TextureUsageBit usage) {
|
MaybeError ValidateCanUseAs(TextureBase* texture, dawn::TextureUsage usage) {
|
||||||
ASSERT(HasZeroOrOneBits(usage));
|
ASSERT(HasZeroOrOneBits(usage));
|
||||||
if (!(texture->GetUsage() & usage)) {
|
if (!(texture->GetUsage() & usage)) {
|
||||||
return DAWN_VALIDATION_ERROR("texture doesn't have the required usage.");
|
return DAWN_VALIDATION_ERROR("texture doesn't have the required usage.");
|
||||||
|
@ -715,9 +715,8 @@ namespace dawn_native {
|
||||||
DAWN_TRY(ValidateB2BCopySizeAlignment(copy->size, copy->sourceOffset,
|
DAWN_TRY(ValidateB2BCopySizeAlignment(copy->size, copy->sourceOffset,
|
||||||
copy->destinationOffset));
|
copy->destinationOffset));
|
||||||
|
|
||||||
DAWN_TRY(ValidateCanUseAs(copy->source.Get(), dawn::BufferUsageBit::CopySrc));
|
DAWN_TRY(ValidateCanUseAs(copy->source.Get(), dawn::BufferUsage::CopySrc));
|
||||||
DAWN_TRY(
|
DAWN_TRY(ValidateCanUseAs(copy->destination.Get(), dawn::BufferUsage::CopyDst));
|
||||||
ValidateCanUseAs(copy->destination.Get(), dawn::BufferUsageBit::CopyDst));
|
|
||||||
|
|
||||||
mResourceUsages.topLevelBuffers.insert(copy->source.Get());
|
mResourceUsages.topLevelBuffers.insert(copy->source.Get());
|
||||||
mResourceUsages.topLevelBuffers.insert(copy->destination.Get());
|
mResourceUsages.topLevelBuffers.insert(copy->destination.Get());
|
||||||
|
@ -750,9 +749,9 @@ namespace dawn_native {
|
||||||
copy->destination.texture->GetFormat()));
|
copy->destination.texture->GetFormat()));
|
||||||
|
|
||||||
DAWN_TRY(
|
DAWN_TRY(
|
||||||
ValidateCanUseAs(copy->source.buffer.Get(), dawn::BufferUsageBit::CopySrc));
|
ValidateCanUseAs(copy->source.buffer.Get(), dawn::BufferUsage::CopySrc));
|
||||||
DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
|
DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
|
||||||
dawn::TextureUsageBit::CopyDst));
|
dawn::TextureUsage::CopyDst));
|
||||||
|
|
||||||
mResourceUsages.topLevelBuffers.insert(copy->source.buffer.Get());
|
mResourceUsages.topLevelBuffers.insert(copy->source.buffer.Get());
|
||||||
mResourceUsages.topLevelTextures.insert(copy->destination.texture.Get());
|
mResourceUsages.topLevelTextures.insert(copy->destination.texture.Get());
|
||||||
|
@ -784,10 +783,10 @@ namespace dawn_native {
|
||||||
DAWN_TRY(ValidateTexelBufferOffset(copy->destination,
|
DAWN_TRY(ValidateTexelBufferOffset(copy->destination,
|
||||||
copy->source.texture->GetFormat()));
|
copy->source.texture->GetFormat()));
|
||||||
|
|
||||||
DAWN_TRY(ValidateCanUseAs(copy->source.texture.Get(),
|
DAWN_TRY(
|
||||||
dawn::TextureUsageBit::CopySrc));
|
ValidateCanUseAs(copy->source.texture.Get(), dawn::TextureUsage::CopySrc));
|
||||||
DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
|
DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
|
||||||
dawn::BufferUsageBit::CopyDst));
|
dawn::BufferUsage::CopyDst));
|
||||||
|
|
||||||
mResourceUsages.topLevelTextures.insert(copy->source.texture.Get());
|
mResourceUsages.topLevelTextures.insert(copy->source.texture.Get());
|
||||||
mResourceUsages.topLevelBuffers.insert(copy->destination.buffer.Get());
|
mResourceUsages.topLevelBuffers.insert(copy->destination.buffer.Get());
|
||||||
|
@ -812,10 +811,10 @@ namespace dawn_native {
|
||||||
DAWN_TRY(ValidateCopySizeFitsInTexture(copy->source, copy->copySize));
|
DAWN_TRY(ValidateCopySizeFitsInTexture(copy->source, copy->copySize));
|
||||||
DAWN_TRY(ValidateCopySizeFitsInTexture(copy->destination, copy->copySize));
|
DAWN_TRY(ValidateCopySizeFitsInTexture(copy->destination, copy->copySize));
|
||||||
|
|
||||||
DAWN_TRY(ValidateCanUseAs(copy->source.texture.Get(),
|
DAWN_TRY(
|
||||||
dawn::TextureUsageBit::CopySrc));
|
ValidateCanUseAs(copy->source.texture.Get(), dawn::TextureUsage::CopySrc));
|
||||||
DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
|
DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
|
||||||
dawn::TextureUsageBit::CopyDst));
|
dawn::TextureUsage::CopyDst));
|
||||||
|
|
||||||
mResourceUsages.topLevelTextures.insert(copy->source.texture.Get());
|
mResourceUsages.topLevelTextures.insert(copy->source.texture.Get());
|
||||||
mResourceUsages.topLevelTextures.insert(copy->destination.texture.Get());
|
mResourceUsages.topLevelTextures.insert(copy->destination.texture.Get());
|
||||||
|
|
|
@ -59,17 +59,17 @@ namespace dawn_native {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case dawn::BindingType::UniformBuffer: {
|
case dawn::BindingType::UniformBuffer: {
|
||||||
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
||||||
usageTracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Uniform);
|
usageTracker->BufferUsedAs(buffer, dawn::BufferUsage::Uniform);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dawn::BindingType::StorageBuffer: {
|
case dawn::BindingType::StorageBuffer: {
|
||||||
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
||||||
usageTracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Storage);
|
usageTracker->BufferUsedAs(buffer, dawn::BufferUsage::Storage);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dawn::BindingType::SampledTexture: {
|
case dawn::BindingType::SampledTexture: {
|
||||||
TextureBase* texture = group->GetBindingAsTextureView(i)->GetTexture();
|
TextureBase* texture = group->GetBindingAsTextureView(i)->GetTexture();
|
||||||
usageTracker->TextureUsedAs(texture, dawn::TextureUsageBit::Sampled);
|
usageTracker->TextureUsedAs(texture, dawn::TextureUsage::Sampled);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dawn::BindingType::Sampler:
|
case dawn::BindingType::Sampler:
|
||||||
|
@ -105,14 +105,14 @@ namespace dawn_native {
|
||||||
DrawIndirectCmd* cmd = commands->NextCommand<DrawIndirectCmd>();
|
DrawIndirectCmd* cmd = commands->NextCommand<DrawIndirectCmd>();
|
||||||
DAWN_TRY(commandBufferState->ValidateCanDraw());
|
DAWN_TRY(commandBufferState->ValidateCanDraw());
|
||||||
usageTracker->BufferUsedAs(cmd->indirectBuffer.Get(),
|
usageTracker->BufferUsedAs(cmd->indirectBuffer.Get(),
|
||||||
dawn::BufferUsageBit::Indirect);
|
dawn::BufferUsage::Indirect);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Command::DrawIndexedIndirect: {
|
case Command::DrawIndexedIndirect: {
|
||||||
DrawIndexedIndirectCmd* cmd = commands->NextCommand<DrawIndexedIndirectCmd>();
|
DrawIndexedIndirectCmd* cmd = commands->NextCommand<DrawIndexedIndirectCmd>();
|
||||||
DAWN_TRY(commandBufferState->ValidateCanDrawIndexed());
|
DAWN_TRY(commandBufferState->ValidateCanDrawIndexed());
|
||||||
usageTracker->BufferUsedAs(cmd->indirectBuffer.Get(),
|
usageTracker->BufferUsedAs(cmd->indirectBuffer.Get(),
|
||||||
dawn::BufferUsageBit::Indirect);
|
dawn::BufferUsage::Indirect);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Command::InsertDebugMarker: {
|
case Command::InsertDebugMarker: {
|
||||||
|
@ -154,7 +154,7 @@ namespace dawn_native {
|
||||||
case Command::SetIndexBuffer: {
|
case Command::SetIndexBuffer: {
|
||||||
SetIndexBufferCmd* cmd = commands->NextCommand<SetIndexBufferCmd>();
|
SetIndexBufferCmd* cmd = commands->NextCommand<SetIndexBufferCmd>();
|
||||||
|
|
||||||
usageTracker->BufferUsedAs(cmd->buffer.Get(), dawn::BufferUsageBit::Index);
|
usageTracker->BufferUsedAs(cmd->buffer.Get(), dawn::BufferUsage::Index);
|
||||||
commandBufferState->SetIndexBuffer();
|
commandBufferState->SetIndexBuffer();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ namespace dawn_native {
|
||||||
commands->NextData<uint64_t>(cmd->count);
|
commands->NextData<uint64_t>(cmd->count);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < cmd->count; ++i) {
|
for (uint32_t i = 0; i < cmd->count; ++i) {
|
||||||
usageTracker->BufferUsedAs(buffers[i].Get(), dawn::BufferUsageBit::Vertex);
|
usageTracker->BufferUsedAs(buffers[i].Get(), dawn::BufferUsage::Vertex);
|
||||||
}
|
}
|
||||||
commandBufferState->SetVertexBuffer(cmd->startSlot, cmd->count);
|
commandBufferState->SetVertexBuffer(cmd->startSlot, cmd->count);
|
||||||
} break;
|
} break;
|
||||||
|
@ -211,18 +211,18 @@ namespace dawn_native {
|
||||||
for (uint32_t i : IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
for (uint32_t i : IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
||||||
RenderPassColorAttachmentInfo* colorAttachment = &renderPass->colorAttachments[i];
|
RenderPassColorAttachmentInfo* colorAttachment = &renderPass->colorAttachments[i];
|
||||||
TextureBase* texture = colorAttachment->view->GetTexture();
|
TextureBase* texture = colorAttachment->view->GetTexture();
|
||||||
usageTracker.TextureUsedAs(texture, dawn::TextureUsageBit::OutputAttachment);
|
usageTracker.TextureUsedAs(texture, dawn::TextureUsage::OutputAttachment);
|
||||||
|
|
||||||
TextureViewBase* resolveTarget = colorAttachment->resolveTarget.Get();
|
TextureViewBase* resolveTarget = colorAttachment->resolveTarget.Get();
|
||||||
if (resolveTarget != nullptr) {
|
if (resolveTarget != nullptr) {
|
||||||
usageTracker.TextureUsedAs(resolveTarget->GetTexture(),
|
usageTracker.TextureUsedAs(resolveTarget->GetTexture(),
|
||||||
dawn::TextureUsageBit::OutputAttachment);
|
dawn::TextureUsage::OutputAttachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderPass->attachmentState->HasDepthStencilAttachment()) {
|
if (renderPass->attachmentState->HasDepthStencilAttachment()) {
|
||||||
TextureBase* texture = renderPass->depthStencilAttachment.view->GetTexture();
|
TextureBase* texture = renderPass->depthStencilAttachment.view->GetTexture();
|
||||||
usageTracker.TextureUsedAs(texture, dawn::TextureUsageBit::OutputAttachment);
|
usageTracker.TextureUsedAs(texture, dawn::TextureUsage::OutputAttachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command type;
|
Command type;
|
||||||
|
@ -324,7 +324,7 @@ namespace dawn_native {
|
||||||
DispatchIndirectCmd* cmd = commands->NextCommand<DispatchIndirectCmd>();
|
DispatchIndirectCmd* cmd = commands->NextCommand<DispatchIndirectCmd>();
|
||||||
DAWN_TRY(commandBufferState.ValidateCanDispatch());
|
DAWN_TRY(commandBufferState.ValidateCanDispatch());
|
||||||
usageTracker.BufferUsedAs(cmd->indirectBuffer.Get(),
|
usageTracker.BufferUsedAs(cmd->indirectBuffer.Get(),
|
||||||
dawn::BufferUsageBit::Indirect);
|
dawn::BufferUsage::Indirect);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Command::InsertDebugMarker: {
|
case Command::InsertDebugMarker: {
|
||||||
|
|
|
@ -30,10 +30,10 @@ namespace dawn_native {
|
||||||
// re-compute it.
|
// re-compute it.
|
||||||
struct PassResourceUsage {
|
struct PassResourceUsage {
|
||||||
std::vector<BufferBase*> buffers;
|
std::vector<BufferBase*> buffers;
|
||||||
std::vector<dawn::BufferUsageBit> bufferUsages;
|
std::vector<dawn::BufferUsage> bufferUsages;
|
||||||
|
|
||||||
std::vector<TextureBase*> textures;
|
std::vector<TextureBase*> textures;
|
||||||
std::vector<dawn::TextureUsageBit> textureUsages;
|
std::vector<dawn::TextureUsage> textureUsages;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CommandBufferResourceUsage {
|
struct CommandBufferResourceUsage {
|
||||||
|
|
|
@ -19,26 +19,24 @@
|
||||||
|
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
|
|
||||||
void PassResourceUsageTracker::BufferUsedAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
|
void PassResourceUsageTracker::BufferUsedAs(BufferBase* buffer, dawn::BufferUsage usage) {
|
||||||
// std::map's operator[] will create the key and return 0 if the key didn't exist
|
// std::map's operator[] will create the key and return 0 if the key didn't exist
|
||||||
// before.
|
// before.
|
||||||
dawn::BufferUsageBit& storedUsage = mBufferUsages[buffer];
|
dawn::BufferUsage& storedUsage = mBufferUsages[buffer];
|
||||||
|
|
||||||
if (usage == dawn::BufferUsageBit::Storage && storedUsage & dawn::BufferUsageBit::Storage) {
|
if (usage == dawn::BufferUsage::Storage && storedUsage & dawn::BufferUsage::Storage) {
|
||||||
mStorageUsedMultipleTimes = true;
|
mStorageUsedMultipleTimes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
storedUsage |= usage;
|
storedUsage |= usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PassResourceUsageTracker::TextureUsedAs(TextureBase* texture,
|
void PassResourceUsageTracker::TextureUsedAs(TextureBase* texture, dawn::TextureUsage usage) {
|
||||||
dawn::TextureUsageBit usage) {
|
|
||||||
// std::map's operator[] will create the key and return 0 if the key didn't exist
|
// std::map's operator[] will create the key and return 0 if the key didn't exist
|
||||||
// before.
|
// before.
|
||||||
dawn::TextureUsageBit& storedUsage = mTextureUsages[texture];
|
dawn::TextureUsage& storedUsage = mTextureUsages[texture];
|
||||||
|
|
||||||
if (usage == dawn::TextureUsageBit::Storage &&
|
if (usage == dawn::TextureUsage::Storage && storedUsage & dawn::TextureUsage::Storage) {
|
||||||
storedUsage & dawn::TextureUsageBit::Storage) {
|
|
||||||
mStorageUsedMultipleTimes = true;
|
mStorageUsedMultipleTimes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +60,7 @@ namespace dawn_native {
|
||||||
// Buffers can only be used as single-write or multiple read.
|
// Buffers can only be used as single-write or multiple read.
|
||||||
for (auto& it : mBufferUsages) {
|
for (auto& it : mBufferUsages) {
|
||||||
BufferBase* buffer = it.first;
|
BufferBase* buffer = it.first;
|
||||||
dawn::BufferUsageBit usage = it.second;
|
dawn::BufferUsage usage = it.second;
|
||||||
|
|
||||||
if (usage & ~buffer->GetUsage()) {
|
if (usage & ~buffer->GetUsage()) {
|
||||||
return DAWN_VALIDATION_ERROR("Buffer missing usage for the pass");
|
return DAWN_VALIDATION_ERROR("Buffer missing usage for the pass");
|
||||||
|
@ -81,7 +79,7 @@ namespace dawn_native {
|
||||||
// TODO(cwallez@chromium.org): implement per-subresource tracking
|
// TODO(cwallez@chromium.org): implement per-subresource tracking
|
||||||
for (auto& it : mTextureUsages) {
|
for (auto& it : mTextureUsages) {
|
||||||
TextureBase* texture = it.first;
|
TextureBase* texture = it.first;
|
||||||
dawn::TextureUsageBit usage = it.second;
|
dawn::TextureUsage usage = it.second;
|
||||||
|
|
||||||
if (usage & ~texture->GetUsage()) {
|
if (usage & ~texture->GetUsage()) {
|
||||||
return DAWN_VALIDATION_ERROR("Texture missing usage for the pass");
|
return DAWN_VALIDATION_ERROR("Texture missing usage for the pass");
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace dawn_native {
|
||||||
// information.
|
// information.
|
||||||
class PassResourceUsageTracker {
|
class PassResourceUsageTracker {
|
||||||
public:
|
public:
|
||||||
void BufferUsedAs(BufferBase* buffer, dawn::BufferUsageBit usage);
|
void BufferUsedAs(BufferBase* buffer, dawn::BufferUsage usage);
|
||||||
void TextureUsedAs(TextureBase* texture, dawn::TextureUsageBit usage);
|
void TextureUsedAs(TextureBase* texture, dawn::TextureUsage usage);
|
||||||
|
|
||||||
MaybeError ValidateComputePassUsages() const;
|
MaybeError ValidateComputePassUsages() const;
|
||||||
MaybeError ValidateRenderPassUsages() const;
|
MaybeError ValidateRenderPassUsages() const;
|
||||||
|
@ -46,8 +46,8 @@ namespace dawn_native {
|
||||||
// Performs the per-pass usage validation checks
|
// Performs the per-pass usage validation checks
|
||||||
MaybeError ValidateUsages() const;
|
MaybeError ValidateUsages() const;
|
||||||
|
|
||||||
std::map<BufferBase*, dawn::BufferUsageBit> mBufferUsages;
|
std::map<BufferBase*, dawn::BufferUsage> mBufferUsages;
|
||||||
std::map<TextureBase*, dawn::TextureUsageBit> mTextureUsages;
|
std::map<TextureBase*, dawn::TextureUsage> mTextureUsages;
|
||||||
bool mStorageUsedMultipleTimes = false;
|
bool mStorageUsedMultipleTimes = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwapChainBase::Configure(dawn::TextureFormat format,
|
void SwapChainBase::Configure(dawn::TextureFormat format,
|
||||||
dawn::TextureUsageBit allowedUsage,
|
dawn::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
if (GetDevice()->ConsumedError(ValidateConfigure(format, allowedUsage, width, height))) {
|
if (GetDevice()->ConsumedError(ValidateConfigure(format, allowedUsage, width, height))) {
|
||||||
|
@ -89,14 +89,14 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
|
|
||||||
allowedUsage |= dawn::TextureUsageBit::Present;
|
allowedUsage |= dawn::TextureUsage::Present;
|
||||||
|
|
||||||
mFormat = format;
|
mFormat = format;
|
||||||
mAllowedUsage = allowedUsage;
|
mAllowedUsage = allowedUsage;
|
||||||
mWidth = width;
|
mWidth = width;
|
||||||
mHeight = height;
|
mHeight = height;
|
||||||
mImplementation.Configure(mImplementation.userData, static_cast<DawnTextureFormat>(format),
|
mImplementation.Configure(mImplementation.userData, static_cast<DawnTextureFormat>(format),
|
||||||
static_cast<DawnTextureUsageBit>(allowedUsage), width, height);
|
static_cast<DawnTextureUsage>(allowedUsage), width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureBase* SwapChainBase::GetNextTexture() {
|
TextureBase* SwapChainBase::GetNextTexture() {
|
||||||
|
@ -138,12 +138,12 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError SwapChainBase::ValidateConfigure(dawn::TextureFormat format,
|
MaybeError SwapChainBase::ValidateConfigure(dawn::TextureFormat format,
|
||||||
dawn::TextureUsageBit allowedUsage,
|
dawn::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) const {
|
uint32_t height) const {
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||||
|
|
||||||
DAWN_TRY(ValidateTextureUsageBit(allowedUsage));
|
DAWN_TRY(ValidateTextureUsage(allowedUsage));
|
||||||
DAWN_TRY(ValidateTextureFormat(format));
|
DAWN_TRY(ValidateTextureFormat(format));
|
||||||
|
|
||||||
if (width == 0 || height == 0) {
|
if (width == 0 || height == 0) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void Configure(dawn::TextureFormat format,
|
void Configure(dawn::TextureFormat format,
|
||||||
dawn::TextureUsageBit allowedUsage,
|
dawn::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
TextureBase* GetNextTexture();
|
TextureBase* GetNextTexture();
|
||||||
|
@ -51,7 +51,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaybeError ValidateConfigure(dawn::TextureFormat format,
|
MaybeError ValidateConfigure(dawn::TextureFormat format,
|
||||||
dawn::TextureUsageBit allowedUsage,
|
dawn::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) const;
|
uint32_t height) const;
|
||||||
MaybeError ValidateGetNextTexture() const;
|
MaybeError ValidateGetNextTexture() const;
|
||||||
|
@ -59,7 +59,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
DawnSwapChainImplementation mImplementation = {};
|
DawnSwapChainImplementation mImplementation = {};
|
||||||
dawn::TextureFormat mFormat = {};
|
dawn::TextureFormat mFormat = {};
|
||||||
dawn::TextureUsageBit mAllowedUsage;
|
dawn::TextureUsage mAllowedUsage;
|
||||||
uint32_t mWidth = 0;
|
uint32_t mWidth = 0;
|
||||||
uint32_t mHeight = 0;
|
uint32_t mHeight = 0;
|
||||||
TextureBase* mLastNextTexture = nullptr;
|
TextureBase* mLastNextTexture = nullptr;
|
||||||
|
|
|
@ -173,23 +173,23 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError ValidateTextureUsage(const TextureDescriptor* descriptor, const Format* format) {
|
MaybeError ValidateTextureUsage(const TextureDescriptor* descriptor, const Format* format) {
|
||||||
DAWN_TRY(ValidateTextureUsageBit(descriptor->usage));
|
DAWN_TRY(dawn_native::ValidateTextureUsage(descriptor->usage));
|
||||||
|
|
||||||
constexpr dawn::TextureUsageBit kValidCompressedUsages =
|
constexpr dawn::TextureUsage kValidCompressedUsages = dawn::TextureUsage::Sampled |
|
||||||
dawn::TextureUsageBit::Sampled | dawn::TextureUsageBit::CopySrc |
|
dawn::TextureUsage::CopySrc |
|
||||||
dawn::TextureUsageBit::CopyDst;
|
dawn::TextureUsage::CopyDst;
|
||||||
if (format->isCompressed && (descriptor->usage & (~kValidCompressedUsages))) {
|
if (format->isCompressed && (descriptor->usage & (~kValidCompressedUsages))) {
|
||||||
return DAWN_VALIDATION_ERROR(
|
return DAWN_VALIDATION_ERROR(
|
||||||
"Compressed texture format is incompatible with the texture usage");
|
"Compressed texture format is incompatible with the texture usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!format->isRenderable &&
|
if (!format->isRenderable &&
|
||||||
(descriptor->usage & dawn::TextureUsageBit::OutputAttachment)) {
|
(descriptor->usage & dawn::TextureUsage::OutputAttachment)) {
|
||||||
return DAWN_VALIDATION_ERROR(
|
return DAWN_VALIDATION_ERROR(
|
||||||
"Non-renderable format used with OutputAttachment usage");
|
"Non-renderable format used with OutputAttachment usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor->usage & dawn::TextureUsageBit::Storage) {
|
if (descriptor->usage & dawn::TextureUsage::Storage) {
|
||||||
return DAWN_VALIDATION_ERROR("storage textures aren't supported (yet)");
|
return DAWN_VALIDATION_ERROR("storage textures aren't supported (yet)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ namespace dawn_native {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
return mSampleCount;
|
return mSampleCount;
|
||||||
}
|
}
|
||||||
dawn::TextureUsageBit TextureBase::GetUsage() const {
|
dawn::TextureUsage TextureBase::GetUsage() const {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
return mUsage;
|
return mUsage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,13 +34,12 @@ namespace dawn_native {
|
||||||
|
|
||||||
bool IsValidSampleCount(uint32_t sampleCount);
|
bool IsValidSampleCount(uint32_t sampleCount);
|
||||||
|
|
||||||
static constexpr dawn::TextureUsageBit kReadOnlyTextureUsages = dawn::TextureUsageBit::CopySrc |
|
static constexpr dawn::TextureUsage kReadOnlyTextureUsages =
|
||||||
dawn::TextureUsageBit::Sampled |
|
dawn::TextureUsage::CopySrc | dawn::TextureUsage::Sampled | dawn::TextureUsage::Present;
|
||||||
dawn::TextureUsageBit::Present;
|
|
||||||
|
|
||||||
static constexpr dawn::TextureUsageBit kWritableTextureUsages =
|
static constexpr dawn::TextureUsage kWritableTextureUsages =
|
||||||
dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::Storage |
|
dawn::TextureUsage::CopyDst | dawn::TextureUsage::Storage |
|
||||||
dawn::TextureUsageBit::OutputAttachment;
|
dawn::TextureUsage::OutputAttachment;
|
||||||
|
|
||||||
class TextureBase : public ObjectBase {
|
class TextureBase : public ObjectBase {
|
||||||
public:
|
public:
|
||||||
|
@ -56,7 +55,7 @@ namespace dawn_native {
|
||||||
uint32_t GetArrayLayers() const;
|
uint32_t GetArrayLayers() const;
|
||||||
uint32_t GetNumMipLevels() const;
|
uint32_t GetNumMipLevels() const;
|
||||||
uint32_t GetSampleCount() const;
|
uint32_t GetSampleCount() const;
|
||||||
dawn::TextureUsageBit GetUsage() const;
|
dawn::TextureUsage GetUsage() const;
|
||||||
TextureState GetTextureState() const;
|
TextureState GetTextureState() const;
|
||||||
uint32_t GetSubresourceIndex(uint32_t mipLevel, uint32_t arraySlice) const;
|
uint32_t GetSubresourceIndex(uint32_t mipLevel, uint32_t arraySlice) const;
|
||||||
bool IsSubresourceContentInitialized(uint32_t baseMipLevel,
|
bool IsSubresourceContentInitialized(uint32_t baseMipLevel,
|
||||||
|
@ -100,7 +99,7 @@ namespace dawn_native {
|
||||||
uint32_t mArrayLayerCount;
|
uint32_t mArrayLayerCount;
|
||||||
uint32_t mMipLevelCount;
|
uint32_t mMipLevelCount;
|
||||||
uint32_t mSampleCount;
|
uint32_t mSampleCount;
|
||||||
dawn::TextureUsageBit mUsage = dawn::TextureUsageBit::None;
|
dawn::TextureUsage mUsage = dawn::TextureUsage::None;
|
||||||
TextureState mState;
|
TextureState mState;
|
||||||
|
|
||||||
// TODO(natlee@microsoft.com): Use a more optimized data structure to save space
|
// TODO(natlee@microsoft.com): Use a more optimized data structure to save space
|
||||||
|
|
|
@ -23,45 +23,45 @@
|
||||||
namespace dawn_native { namespace d3d12 {
|
namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::BufferUsageBit usage) {
|
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::BufferUsage usage) {
|
||||||
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE;
|
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE;
|
||||||
|
|
||||||
if (usage & dawn::BufferUsageBit::Storage) {
|
if (usage & dawn::BufferUsage::Storage) {
|
||||||
flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
|
flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_RESOURCE_STATES D3D12BufferUsage(dawn::BufferUsageBit usage) {
|
D3D12_RESOURCE_STATES D3D12BufferUsage(dawn::BufferUsage usage) {
|
||||||
D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
|
D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
|
||||||
|
|
||||||
if (usage & dawn::BufferUsageBit::CopySrc) {
|
if (usage & dawn::BufferUsage::CopySrc) {
|
||||||
resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
|
resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::CopyDst) {
|
if (usage & dawn::BufferUsage::CopyDst) {
|
||||||
resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
|
resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
|
||||||
}
|
}
|
||||||
if (usage & (dawn::BufferUsageBit::Vertex | dawn::BufferUsageBit::Uniform)) {
|
if (usage & (dawn::BufferUsage::Vertex | dawn::BufferUsage::Uniform)) {
|
||||||
resourceState |= D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER;
|
resourceState |= D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Index) {
|
if (usage & dawn::BufferUsage::Index) {
|
||||||
resourceState |= D3D12_RESOURCE_STATE_INDEX_BUFFER;
|
resourceState |= D3D12_RESOURCE_STATE_INDEX_BUFFER;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Storage) {
|
if (usage & dawn::BufferUsage::Storage) {
|
||||||
resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Indirect) {
|
if (usage & dawn::BufferUsage::Indirect) {
|
||||||
resourceState |= D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT;
|
resourceState |= D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return resourceState;
|
return resourceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_HEAP_TYPE D3D12HeapType(dawn::BufferUsageBit allowedUsage) {
|
D3D12_HEAP_TYPE D3D12HeapType(dawn::BufferUsage allowedUsage) {
|
||||||
if (allowedUsage & dawn::BufferUsageBit::MapRead) {
|
if (allowedUsage & dawn::BufferUsage::MapRead) {
|
||||||
return D3D12_HEAP_TYPE_READBACK;
|
return D3D12_HEAP_TYPE_READBACK;
|
||||||
} else if (allowedUsage & dawn::BufferUsageBit::MapWrite) {
|
} else if (allowedUsage & dawn::BufferUsage::MapWrite) {
|
||||||
return D3D12_HEAP_TYPE_UPLOAD;
|
return D3D12_HEAP_TYPE_UPLOAD;
|
||||||
} else {
|
} else {
|
||||||
return D3D12_HEAP_TYPE_DEFAULT;
|
return D3D12_HEAP_TYPE_DEFAULT;
|
||||||
|
@ -84,7 +84,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||||
// Add CopyDst for non-mappable buffer initialization in CreateBufferMapped
|
// Add CopyDst for non-mappable buffer initialization in CreateBufferMapped
|
||||||
// and robust resource initialization.
|
// and robust resource initialization.
|
||||||
resourceDescriptor.Flags = D3D12ResourceFlags(GetUsage() | dawn::BufferUsageBit::CopyDst);
|
resourceDescriptor.Flags = D3D12ResourceFlags(GetUsage() | dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
auto heapType = D3D12HeapType(GetUsage());
|
auto heapType = D3D12HeapType(GetUsage());
|
||||||
auto bufferUsage = D3D12_RESOURCE_STATE_COMMON;
|
auto bufferUsage = D3D12_RESOURCE_STATE_COMMON;
|
||||||
|
@ -94,7 +94,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
if (heapType == D3D12_HEAP_TYPE_READBACK) {
|
if (heapType == D3D12_HEAP_TYPE_READBACK) {
|
||||||
bufferUsage |= D3D12_RESOURCE_STATE_COPY_DEST;
|
bufferUsage |= D3D12_RESOURCE_STATE_COPY_DEST;
|
||||||
mFixedResourceState = true;
|
mFixedResourceState = true;
|
||||||
mLastUsage = dawn::BufferUsageBit::CopyDst;
|
mLastUsage = dawn::BufferUsage::CopyDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
// D3D12 requires buffers on the UPLOAD heap to have the D3D12_RESOURCE_STATE_GENERIC_READ
|
// D3D12 requires buffers on the UPLOAD heap to have the D3D12_RESOURCE_STATE_GENERIC_READ
|
||||||
|
@ -102,7 +102,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
if (heapType == D3D12_HEAP_TYPE_UPLOAD) {
|
if (heapType == D3D12_HEAP_TYPE_UPLOAD) {
|
||||||
bufferUsage |= D3D12_RESOURCE_STATE_GENERIC_READ;
|
bufferUsage |= D3D12_RESOURCE_STATE_GENERIC_READ;
|
||||||
mFixedResourceState = true;
|
mFixedResourceState = true;
|
||||||
mLastUsage = dawn::BufferUsageBit::CopySrc;
|
mLastUsage = dawn::BufferUsage::CopySrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
mResource =
|
mResource =
|
||||||
|
@ -126,7 +126,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
// ResourceBarrier call. Failing to do so will cause the tracked state to become invalid and can
|
// ResourceBarrier call. Failing to do so will cause the tracked state to become invalid and can
|
||||||
// cause subsequent errors.
|
// cause subsequent errors.
|
||||||
bool Buffer::TransitionUsageAndGetResourceBarrier(D3D12_RESOURCE_BARRIER* barrier,
|
bool Buffer::TransitionUsageAndGetResourceBarrier(D3D12_RESOURCE_BARRIER* barrier,
|
||||||
dawn::BufferUsageBit newUsage) {
|
dawn::BufferUsage newUsage) {
|
||||||
// Resources in upload and readback heaps must be kept in the COPY_SOURCE/DEST state
|
// Resources in upload and readback heaps must be kept in the COPY_SOURCE/DEST state
|
||||||
if (mFixedResourceState) {
|
if (mFixedResourceState) {
|
||||||
ASSERT(mLastUsage == newUsage);
|
ASSERT(mLastUsage == newUsage);
|
||||||
|
@ -183,7 +183,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
|
void Buffer::TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
|
||||||
dawn::BufferUsageBit usage) {
|
dawn::BufferUsage usage) {
|
||||||
D3D12_RESOURCE_BARRIER barrier;
|
D3D12_RESOURCE_BARRIER barrier;
|
||||||
|
|
||||||
if (TransitionUsageAndGetResourceBarrier(&barrier, usage)) {
|
if (TransitionUsageAndGetResourceBarrier(&barrier, usage)) {
|
||||||
|
@ -205,7 +205,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
bool Buffer::IsMapWritable() const {
|
bool Buffer::IsMapWritable() const {
|
||||||
// TODO(enga): Handle CPU-visible memory on UMA
|
// TODO(enga): Handle CPU-visible memory on UMA
|
||||||
return (GetUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) != 0;
|
return (GetUsage() & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) {
|
MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) {
|
||||||
|
|
|
@ -34,9 +34,9 @@ namespace dawn_native { namespace d3d12 {
|
||||||
D3D12_GPU_VIRTUAL_ADDRESS GetVA() const;
|
D3D12_GPU_VIRTUAL_ADDRESS GetVA() const;
|
||||||
void OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite);
|
void OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite);
|
||||||
bool TransitionUsageAndGetResourceBarrier(D3D12_RESOURCE_BARRIER* barrier,
|
bool TransitionUsageAndGetResourceBarrier(D3D12_RESOURCE_BARRIER* barrier,
|
||||||
dawn::BufferUsageBit newUsage);
|
dawn::BufferUsage newUsage);
|
||||||
void TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
|
void TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
|
||||||
dawn::BufferUsageBit usage);
|
dawn::BufferUsage usage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Dawn API
|
// Dawn API
|
||||||
|
@ -50,7 +50,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
ComPtr<ID3D12Resource> mResource;
|
ComPtr<ID3D12Resource> mResource;
|
||||||
bool mFixedResourceState = false;
|
bool mFixedResourceState = false;
|
||||||
dawn::BufferUsageBit mLastUsage = dawn::BufferUsageBit::None;
|
dawn::BufferUsage mLastUsage = dawn::BufferUsage::None;
|
||||||
Serial mLastUsedSerial = UINT64_MAX;
|
Serial mLastUsedSerial = UINT64_MAX;
|
||||||
D3D12_RANGE mWrittenMappedRange;
|
D3D12_RANGE mWrittenMappedRange;
|
||||||
};
|
};
|
||||||
|
|
|
@ -539,7 +539,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
// Clear textures that are not output attachments. Output attachments will be
|
// Clear textures that are not output attachments. Output attachments will be
|
||||||
// cleared during record render pass if the texture subresource has not been
|
// cleared during record render pass if the texture subresource has not been
|
||||||
// initialized before the render pass.
|
// initialized before the render pass.
|
||||||
if (!(usages.textureUsages[i] & dawn::TextureUsageBit::OutputAttachment)) {
|
if (!(usages.textureUsages[i] & dawn::TextureUsage::OutputAttachment)) {
|
||||||
texture->EnsureSubresourceContentInitialized(
|
texture->EnsureSubresourceContentInitialized(
|
||||||
commandList, 0, texture->GetNumMipLevels(), 0, texture->GetArrayLayers());
|
commandList, 0, texture->GetNumMipLevels(), 0, texture->GetArrayLayers());
|
||||||
}
|
}
|
||||||
|
@ -591,8 +591,8 @@ namespace dawn_native { namespace d3d12 {
|
||||||
Buffer* srcBuffer = ToBackend(copy->source.Get());
|
Buffer* srcBuffer = ToBackend(copy->source.Get());
|
||||||
Buffer* dstBuffer = ToBackend(copy->destination.Get());
|
Buffer* dstBuffer = ToBackend(copy->destination.Get());
|
||||||
|
|
||||||
srcBuffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::CopySrc);
|
srcBuffer->TransitionUsageNow(commandList, dawn::BufferUsage::CopySrc);
|
||||||
dstBuffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::CopyDst);
|
dstBuffer->TransitionUsageNow(commandList, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
commandList->CopyBufferRegion(
|
commandList->CopyBufferRegion(
|
||||||
dstBuffer->GetD3D12Resource().Get(), copy->destinationOffset,
|
dstBuffer->GetD3D12Resource().Get(), copy->destinationOffset,
|
||||||
|
@ -614,8 +614,8 @@ namespace dawn_native { namespace d3d12 {
|
||||||
copy->destination.arrayLayer, 1);
|
copy->destination.arrayLayer, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::CopySrc);
|
buffer->TransitionUsageNow(commandList, dawn::BufferUsage::CopySrc);
|
||||||
texture->TransitionUsageNow(commandList, dawn::TextureUsageBit::CopyDst);
|
texture->TransitionUsageNow(commandList, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
auto copySplit = ComputeTextureCopySplit(
|
auto copySplit = ComputeTextureCopySplit(
|
||||||
copy->destination.origin, copy->copySize, texture->GetFormat(),
|
copy->destination.origin, copy->copySize, texture->GetFormat(),
|
||||||
|
@ -660,8 +660,8 @@ namespace dawn_native { namespace d3d12 {
|
||||||
texture->EnsureSubresourceContentInitialized(commandList, copy->source.mipLevel,
|
texture->EnsureSubresourceContentInitialized(commandList, copy->source.mipLevel,
|
||||||
1, copy->source.arrayLayer, 1);
|
1, copy->source.arrayLayer, 1);
|
||||||
|
|
||||||
texture->TransitionUsageNow(commandList, dawn::TextureUsageBit::CopySrc);
|
texture->TransitionUsageNow(commandList, dawn::TextureUsage::CopySrc);
|
||||||
buffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::CopyDst);
|
buffer->TransitionUsageNow(commandList, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
auto copySplit = ComputeTextureCopySplit(
|
auto copySplit = ComputeTextureCopySplit(
|
||||||
copy->source.origin, copy->copySize, texture->GetFormat(),
|
copy->source.origin, copy->copySize, texture->GetFormat(),
|
||||||
|
@ -718,8 +718,8 @@ namespace dawn_native { namespace d3d12 {
|
||||||
commandList, copy->destination.mipLevel, 1,
|
commandList, copy->destination.mipLevel, 1,
|
||||||
copy->destination.arrayLayer, 1);
|
copy->destination.arrayLayer, 1);
|
||||||
}
|
}
|
||||||
source->TransitionUsageNow(commandList, dawn::TextureUsageBit::CopySrc);
|
source->TransitionUsageNow(commandList, dawn::TextureUsage::CopySrc);
|
||||||
destination->TransitionUsageNow(commandList, dawn::TextureUsageBit::CopyDst);
|
destination->TransitionUsageNow(commandList, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
if (CanUseCopyResource(source->GetNumMipLevels(), source->GetSize(),
|
if (CanUseCopyResource(source->GetNumMipLevels(), source->GetSize(),
|
||||||
destination->GetSize(), copy->copySize)) {
|
destination->GetSize(), copy->copySize)) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
DawnSwapChainImplementation impl;
|
DawnSwapChainImplementation impl;
|
||||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, window));
|
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, window));
|
||||||
impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
|
impl.textureUsage = DAWN_TEXTURE_USAGE_PRESENT;
|
||||||
|
|
||||||
return impl;
|
return impl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
uint64_t destinationOffset,
|
uint64_t destinationOffset,
|
||||||
uint64_t size) {
|
uint64_t size) {
|
||||||
ToBackend(destination)
|
ToBackend(destination)
|
||||||
->TransitionUsageNow(GetPendingCommandList(), dawn::BufferUsageBit::CopyDst);
|
->TransitionUsageNow(GetPendingCommandList(), dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
GetPendingCommandList()->CopyBufferRegion(
|
GetPendingCommandList()->CopyBufferRegion(
|
||||||
ToBackend(destination)->GetD3D12Resource().Get(), destinationOffset,
|
ToBackend(destination)->GetD3D12Resource().Get(), destinationOffset,
|
||||||
|
|
|
@ -21,15 +21,15 @@
|
||||||
namespace dawn_native { namespace d3d12 {
|
namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
DXGI_USAGE D3D12SwapChainBufferUsage(DawnTextureUsageBit allowedUsages) {
|
DXGI_USAGE D3D12SwapChainBufferUsage(DawnTextureUsage allowedUsages) {
|
||||||
DXGI_USAGE usage = DXGI_CPU_ACCESS_NONE;
|
DXGI_USAGE usage = DXGI_CPU_ACCESS_NONE;
|
||||||
if (allowedUsages & DAWN_TEXTURE_USAGE_BIT_SAMPLED) {
|
if (allowedUsages & DAWN_TEXTURE_USAGE_SAMPLED) {
|
||||||
usage |= DXGI_USAGE_SHADER_INPUT;
|
usage |= DXGI_USAGE_SHADER_INPUT;
|
||||||
}
|
}
|
||||||
if (allowedUsages & DAWN_TEXTURE_USAGE_BIT_STORAGE) {
|
if (allowedUsages & DAWN_TEXTURE_USAGE_STORAGE) {
|
||||||
usage |= DXGI_USAGE_UNORDERED_ACCESS;
|
usage |= DXGI_USAGE_UNORDERED_ACCESS;
|
||||||
}
|
}
|
||||||
if (allowedUsages & DAWN_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT) {
|
if (allowedUsages & DAWN_TEXTURE_USAGE_OUTPUT_ATTACHMENT) {
|
||||||
usage |= DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
usage |= DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
}
|
}
|
||||||
return usage;
|
return usage;
|
||||||
|
@ -49,7 +49,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
||||||
DawnTextureUsageBit usage,
|
DawnTextureUsage usage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
ASSERT(width > 0);
|
ASSERT(width > 0);
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
void Init(DawnWSIContextD3D12* context);
|
void Init(DawnWSIContextD3D12* context);
|
||||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||||
DawnTextureUsageBit,
|
DawnTextureUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||||
|
|
|
@ -28,8 +28,8 @@ namespace dawn_native { namespace d3d12 {
|
||||||
wsiContext.device = reinterpret_cast<DawnDevice>(GetDevice());
|
wsiContext.device = reinterpret_cast<DawnDevice>(GetDevice());
|
||||||
im.Init(im.userData, &wsiContext);
|
im.Init(im.userData, &wsiContext);
|
||||||
|
|
||||||
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_BIT_NONE);
|
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_NONE);
|
||||||
mTextureUsage = static_cast<dawn::TextureUsageBit>(im.textureUsage);
|
mTextureUsage = static_cast<dawn::TextureUsage>(im.textureUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
SwapChain::~SwapChain() {
|
SwapChain::~SwapChain() {
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
|
TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
|
||||||
void OnBeforePresent(TextureBase* texture) override;
|
void OnBeforePresent(TextureBase* texture) override;
|
||||||
|
|
||||||
dawn::TextureUsageBit mTextureUsage;
|
dawn::TextureUsage mTextureUsage;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::d3d12
|
}} // namespace dawn_native::d3d12
|
||||||
|
|
|
@ -21,28 +21,28 @@
|
||||||
namespace dawn_native { namespace d3d12 {
|
namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
D3D12_RESOURCE_STATES D3D12TextureUsage(dawn::TextureUsageBit usage, const Format& format) {
|
D3D12_RESOURCE_STATES D3D12TextureUsage(dawn::TextureUsage usage, const Format& format) {
|
||||||
D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
|
D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
|
||||||
|
|
||||||
// Present is an exclusive flag.
|
// Present is an exclusive flag.
|
||||||
if (usage & dawn::TextureUsageBit::Present) {
|
if (usage & dawn::TextureUsage::Present) {
|
||||||
return D3D12_RESOURCE_STATE_PRESENT;
|
return D3D12_RESOURCE_STATE_PRESENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usage & dawn::TextureUsageBit::CopySrc) {
|
if (usage & dawn::TextureUsage::CopySrc) {
|
||||||
resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
|
resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::CopyDst) {
|
if (usage & dawn::TextureUsage::CopyDst) {
|
||||||
resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
|
resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::Sampled) {
|
if (usage & dawn::TextureUsage::Sampled) {
|
||||||
resourceState |= (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE |
|
resourceState |= (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE |
|
||||||
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::Storage) {
|
if (usage & dawn::TextureUsage::Storage) {
|
||||||
resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::OutputAttachment) {
|
if (usage & dawn::TextureUsage::OutputAttachment) {
|
||||||
if (format.HasDepthOrStencil()) {
|
if (format.HasDepthOrStencil()) {
|
||||||
resourceState |= D3D12_RESOURCE_STATE_DEPTH_WRITE;
|
resourceState |= D3D12_RESOURCE_STATE_DEPTH_WRITE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,12 +53,12 @@ namespace dawn_native { namespace d3d12 {
|
||||||
return resourceState;
|
return resourceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::TextureUsageBit usage,
|
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::TextureUsage usage,
|
||||||
const Format& format,
|
const Format& format,
|
||||||
bool isMultisampledTexture) {
|
bool isMultisampledTexture) {
|
||||||
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE;
|
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE;
|
||||||
|
|
||||||
if (usage & dawn::TextureUsageBit::Storage) {
|
if (usage & dawn::TextureUsage::Storage) {
|
||||||
flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
|
flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
// flag is invalid.
|
// flag is invalid.
|
||||||
// TODO(natlee@microsoft.com, jiawei.shao@intel.com): do not require render target for
|
// TODO(natlee@microsoft.com, jiawei.shao@intel.com): do not require render target for
|
||||||
// lazy clearing.
|
// lazy clearing.
|
||||||
if ((usage & dawn::TextureUsageBit::OutputAttachment) || isMultisampledTexture ||
|
if ((usage & dawn::TextureUsage::OutputAttachment) || isMultisampledTexture ||
|
||||||
!format.isCompressed) {
|
!format.isCompressed) {
|
||||||
if (format.HasDepthOrStencil()) {
|
if (format.HasDepthOrStencil()) {
|
||||||
flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
|
flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
|
||||||
|
@ -319,7 +319,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
// ResourceBarrier call. Failing to do so will cause the tracked state to become invalid and can
|
// ResourceBarrier call. Failing to do so will cause the tracked state to become invalid and can
|
||||||
// cause subsequent errors.
|
// cause subsequent errors.
|
||||||
bool Texture::TransitionUsageAndGetResourceBarrier(D3D12_RESOURCE_BARRIER* barrier,
|
bool Texture::TransitionUsageAndGetResourceBarrier(D3D12_RESOURCE_BARRIER* barrier,
|
||||||
dawn::TextureUsageBit newUsage) {
|
dawn::TextureUsage newUsage) {
|
||||||
return TransitionUsageAndGetResourceBarrier(barrier,
|
return TransitionUsageAndGetResourceBarrier(barrier,
|
||||||
D3D12TextureUsage(newUsage, GetFormat()));
|
D3D12TextureUsage(newUsage, GetFormat()));
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
|
void Texture::TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
|
||||||
dawn::TextureUsageBit usage) {
|
dawn::TextureUsage usage) {
|
||||||
TransitionUsageNow(commandList, D3D12TextureUsage(usage, GetFormat()));
|
TransitionUsageNow(commandList, D3D12TextureUsage(usage, GetFormat()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,9 @@ namespace dawn_native { namespace d3d12 {
|
||||||
DXGI_FORMAT GetD3D12Format() const;
|
DXGI_FORMAT GetD3D12Format() const;
|
||||||
ID3D12Resource* GetD3D12Resource() const;
|
ID3D12Resource* GetD3D12Resource() const;
|
||||||
bool TransitionUsageAndGetResourceBarrier(D3D12_RESOURCE_BARRIER* barrier,
|
bool TransitionUsageAndGetResourceBarrier(D3D12_RESOURCE_BARRIER* barrier,
|
||||||
dawn::TextureUsageBit newUsage);
|
dawn::TextureUsage newUsage);
|
||||||
void TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
|
void TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
|
||||||
dawn::TextureUsageBit usage);
|
dawn::TextureUsage usage);
|
||||||
void TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
|
void TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
|
||||||
D3D12_RESOURCE_STATES newState);
|
D3D12_RESOURCE_STATES newState);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef DAWNNATIVE_DAWNPLATFORM_H_
|
#ifndef DAWNNATIVE_DAWNPLATFORM_H_
|
||||||
#define DAWNNATIVE_DAWNPLATFORM_H_
|
#define DAWNNATIVE_DAWNPLATFORM_H_
|
||||||
|
|
||||||
// Use cawncpp to have the enum and bitfield definitions
|
// Use dawncpp to have the enum and bitfield definitions
|
||||||
#include <dawn/dawncpp.h>
|
#include <dawn/dawncpp.h>
|
||||||
|
|
||||||
// Use our autogenerated version of the dawn structures that point to dawn_native object types
|
// Use our autogenerated version of the dawn structures that point to dawn_native object types
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace dawn_native { namespace metal {
|
||||||
Buffer::Buffer(Device* device, const BufferDescriptor* descriptor)
|
Buffer::Buffer(Device* device, const BufferDescriptor* descriptor)
|
||||||
: BufferBase(device, descriptor) {
|
: BufferBase(device, descriptor) {
|
||||||
MTLResourceOptions storageMode;
|
MTLResourceOptions storageMode;
|
||||||
if (GetUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) {
|
if (GetUsage() & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) {
|
||||||
storageMode = MTLResourceStorageModeShared;
|
storageMode = MTLResourceStorageModeShared;
|
||||||
} else {
|
} else {
|
||||||
storageMode = MTLResourceStorageModePrivate;
|
storageMode = MTLResourceStorageModePrivate;
|
||||||
|
@ -49,7 +49,7 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
bool Buffer::IsMapWritable() const {
|
bool Buffer::IsMapWritable() const {
|
||||||
// TODO(enga): Handle CPU-visible memory on UMA
|
// TODO(enga): Handle CPU-visible memory on UMA
|
||||||
return (GetUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) != 0;
|
return (GetUsage() & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) {
|
MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) {
|
||||||
|
|
|
@ -21,24 +21,24 @@
|
||||||
namespace dawn_native { namespace metal {
|
namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool UsageNeedsTextureView(dawn::TextureUsageBit usage) {
|
bool UsageNeedsTextureView(dawn::TextureUsage usage) {
|
||||||
constexpr dawn::TextureUsageBit kUsageNeedsTextureView =
|
constexpr dawn::TextureUsage kUsageNeedsTextureView =
|
||||||
dawn::TextureUsageBit::Storage | dawn::TextureUsageBit::Sampled;
|
dawn::TextureUsage::Storage | dawn::TextureUsage::Sampled;
|
||||||
return usage & kUsageNeedsTextureView;
|
return usage & kUsageNeedsTextureView;
|
||||||
}
|
}
|
||||||
|
|
||||||
MTLTextureUsage MetalTextureUsage(dawn::TextureUsageBit usage) {
|
MTLTextureUsage MetalTextureUsage(dawn::TextureUsage usage) {
|
||||||
MTLTextureUsage result = MTLTextureUsageUnknown; // This is 0
|
MTLTextureUsage result = MTLTextureUsageUnknown; // This is 0
|
||||||
|
|
||||||
if (usage & (dawn::TextureUsageBit::Storage)) {
|
if (usage & (dawn::TextureUsage::Storage)) {
|
||||||
result |= MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead;
|
result |= MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usage & (dawn::TextureUsageBit::Sampled)) {
|
if (usage & (dawn::TextureUsage::Sampled)) {
|
||||||
result |= MTLTextureUsageShaderRead;
|
result |= MTLTextureUsageShaderRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usage & (dawn::TextureUsageBit::OutputAttachment)) {
|
if (usage & (dawn::TextureUsage::OutputAttachment)) {
|
||||||
result |= MTLTextureUsageRenderTarget;
|
result |= MTLTextureUsageRenderTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ namespace dawn_native { namespace null {
|
||||||
bool Buffer::IsMapWritable() const {
|
bool Buffer::IsMapWritable() const {
|
||||||
// Only return true for mappable buffers so we can test cases that need / don't need a
|
// Only return true for mappable buffers so we can test cases that need / don't need a
|
||||||
// staging buffer.
|
// staging buffer.
|
||||||
return (GetUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) != 0;
|
return (GetUsage() & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) {
|
MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) {
|
||||||
|
@ -345,7 +345,7 @@ namespace dawn_native { namespace null {
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
||||||
DawnTextureUsageBit,
|
DawnTextureUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
|
|
|
@ -209,7 +209,7 @@ namespace dawn_native { namespace null {
|
||||||
using WSIContext = struct {};
|
using WSIContext = struct {};
|
||||||
void Init(WSIContext* context);
|
void Init(WSIContext* context);
|
||||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||||
DawnTextureUsageBit,
|
DawnTextureUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace dawn_native { namespace null {
|
||||||
DawnSwapChainImplementation CreateNativeSwapChainImpl() {
|
DawnSwapChainImplementation CreateNativeSwapChainImpl() {
|
||||||
DawnSwapChainImplementation impl;
|
DawnSwapChainImplementation impl;
|
||||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl());
|
impl = CreateSwapChainImplementation(new NativeSwapChainImpl());
|
||||||
impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
|
impl.textureUsage = DAWN_TEXTURE_USAGE_PRESENT;
|
||||||
return impl;
|
return impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,7 +394,7 @@ namespace dawn_native { namespace opengl {
|
||||||
// We count the lazy clears for non output attachment textures and depth stencil
|
// We count the lazy clears for non output attachment textures and depth stencil
|
||||||
// textures in order to match the backdoor lazy clear counts in Vulkan and D3D12.
|
// textures in order to match the backdoor lazy clear counts in Vulkan and D3D12.
|
||||||
bool isLazyClear =
|
bool isLazyClear =
|
||||||
((!(usages.textureUsages[i] & dawn::TextureUsageBit::OutputAttachment) &&
|
((!(usages.textureUsages[i] & dawn::TextureUsage::OutputAttachment) &&
|
||||||
texture->GetFormat().IsColor()) ||
|
texture->GetFormat().IsColor()) ||
|
||||||
texture->GetFormat().HasDepthOrStencil());
|
texture->GetFormat().HasDepthOrStencil());
|
||||||
texture->EnsureSubresourceContentInitialized(
|
texture->EnsureSubresourceContentInitialized(
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace dawn_native { namespace opengl {
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
||||||
DawnTextureUsageBit usage,
|
DawnTextureUsage usage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
if (format != DAWN_TEXTURE_FORMAT_RGBA8_UNORM) {
|
if (format != DAWN_TEXTURE_FORMAT_RGBA8_UNORM) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
void Init(DawnWSIContextGL* context);
|
void Init(DawnWSIContextGL* context);
|
||||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||||
DawnTextureUsageBit,
|
DawnTextureUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace dawn_native { namespace opengl {
|
||||||
DawnSwapChainImplementation impl;
|
DawnSwapChainImplementation impl;
|
||||||
impl = CreateSwapChainImplementation(
|
impl = CreateSwapChainImplementation(
|
||||||
new NativeSwapChainImpl(backendDevice, present, presentUserdata));
|
new NativeSwapChainImpl(backendDevice, present, presentUserdata));
|
||||||
impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
|
impl.textureUsage = DAWN_TEXTURE_USAGE_PRESENT;
|
||||||
|
|
||||||
return impl;
|
return impl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,9 @@ namespace dawn_native { namespace opengl {
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UsageNeedsTextureView(dawn::TextureUsageBit usage) {
|
bool UsageNeedsTextureView(dawn::TextureUsage usage) {
|
||||||
constexpr dawn::TextureUsageBit kUsageNeedingTextureView =
|
constexpr dawn::TextureUsage kUsageNeedingTextureView =
|
||||||
dawn::TextureUsageBit::Storage | dawn::TextureUsageBit::Sampled;
|
dawn::TextureUsage::Storage | dawn::TextureUsage::Sampled;
|
||||||
return usage & kUsageNeedingTextureView;
|
return usage & kUsageNeedingTextureView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,86 +23,86 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
VkBufferUsageFlags VulkanBufferUsage(dawn::BufferUsageBit usage) {
|
VkBufferUsageFlags VulkanBufferUsage(dawn::BufferUsage usage) {
|
||||||
VkBufferUsageFlags flags = 0;
|
VkBufferUsageFlags flags = 0;
|
||||||
|
|
||||||
if (usage & dawn::BufferUsageBit::CopySrc) {
|
if (usage & dawn::BufferUsage::CopySrc) {
|
||||||
flags |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
flags |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::CopyDst) {
|
if (usage & dawn::BufferUsage::CopyDst) {
|
||||||
flags |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
flags |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Index) {
|
if (usage & dawn::BufferUsage::Index) {
|
||||||
flags |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
|
flags |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Vertex) {
|
if (usage & dawn::BufferUsage::Vertex) {
|
||||||
flags |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
|
flags |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Uniform) {
|
if (usage & dawn::BufferUsage::Uniform) {
|
||||||
flags |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
|
flags |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Storage) {
|
if (usage & dawn::BufferUsage::Storage) {
|
||||||
flags |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
|
flags |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Indirect) {
|
if (usage & dawn::BufferUsage::Indirect) {
|
||||||
flags |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
|
flags |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPipelineStageFlags VulkanPipelineStage(dawn::BufferUsageBit usage) {
|
VkPipelineStageFlags VulkanPipelineStage(dawn::BufferUsage usage) {
|
||||||
VkPipelineStageFlags flags = 0;
|
VkPipelineStageFlags flags = 0;
|
||||||
|
|
||||||
if (usage & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) {
|
if (usage & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) {
|
||||||
flags |= VK_PIPELINE_STAGE_HOST_BIT;
|
flags |= VK_PIPELINE_STAGE_HOST_BIT;
|
||||||
}
|
}
|
||||||
if (usage & (dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst)) {
|
if (usage & (dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst)) {
|
||||||
flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
|
flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||||
}
|
}
|
||||||
if (usage & (dawn::BufferUsageBit::Index | dawn::BufferUsageBit::Vertex)) {
|
if (usage & (dawn::BufferUsage::Index | dawn::BufferUsage::Vertex)) {
|
||||||
flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
|
flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
|
||||||
}
|
}
|
||||||
if (usage & (dawn::BufferUsageBit::Uniform | dawn::BufferUsageBit::Storage)) {
|
if (usage & (dawn::BufferUsage::Uniform | dawn::BufferUsage::Storage)) {
|
||||||
flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
|
flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
|
||||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
|
||||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
|
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Indirect) {
|
if (usage & dawn::BufferUsage::Indirect) {
|
||||||
flags |= VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT;
|
flags |= VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkAccessFlags VulkanAccessFlags(dawn::BufferUsageBit usage) {
|
VkAccessFlags VulkanAccessFlags(dawn::BufferUsage usage) {
|
||||||
VkAccessFlags flags = 0;
|
VkAccessFlags flags = 0;
|
||||||
|
|
||||||
if (usage & dawn::BufferUsageBit::MapRead) {
|
if (usage & dawn::BufferUsage::MapRead) {
|
||||||
flags |= VK_ACCESS_HOST_READ_BIT;
|
flags |= VK_ACCESS_HOST_READ_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::MapWrite) {
|
if (usage & dawn::BufferUsage::MapWrite) {
|
||||||
flags |= VK_ACCESS_HOST_WRITE_BIT;
|
flags |= VK_ACCESS_HOST_WRITE_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::CopySrc) {
|
if (usage & dawn::BufferUsage::CopySrc) {
|
||||||
flags |= VK_ACCESS_TRANSFER_READ_BIT;
|
flags |= VK_ACCESS_TRANSFER_READ_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::CopyDst) {
|
if (usage & dawn::BufferUsage::CopyDst) {
|
||||||
flags |= VK_ACCESS_TRANSFER_WRITE_BIT;
|
flags |= VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Index) {
|
if (usage & dawn::BufferUsage::Index) {
|
||||||
flags |= VK_ACCESS_INDEX_READ_BIT;
|
flags |= VK_ACCESS_INDEX_READ_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Vertex) {
|
if (usage & dawn::BufferUsage::Vertex) {
|
||||||
flags |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
|
flags |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Uniform) {
|
if (usage & dawn::BufferUsage::Uniform) {
|
||||||
flags |= VK_ACCESS_UNIFORM_READ_BIT;
|
flags |= VK_ACCESS_UNIFORM_READ_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Storage) {
|
if (usage & dawn::BufferUsage::Storage) {
|
||||||
flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
|
flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::BufferUsageBit::Indirect) {
|
if (usage & dawn::BufferUsage::Indirect) {
|
||||||
flags |= VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
|
flags |= VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
createInfo.size = GetSize();
|
createInfo.size = GetSize();
|
||||||
// Add CopyDst for non-mappable buffer initialization in CreateBufferMapped
|
// Add CopyDst for non-mappable buffer initialization in CreateBufferMapped
|
||||||
// and robust resource initialization.
|
// and robust resource initialization.
|
||||||
createInfo.usage = VulkanBufferUsage(GetUsage() | dawn::BufferUsageBit::CopyDst);
|
createInfo.usage = VulkanBufferUsage(GetUsage() | dawn::BufferUsage::CopyDst);
|
||||||
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
createInfo.queueFamilyIndexCount = 0;
|
createInfo.queueFamilyIndexCount = 0;
|
||||||
createInfo.pQueueFamilyIndices = 0;
|
createInfo.pQueueFamilyIndices = 0;
|
||||||
|
@ -134,7 +134,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
device->fn.GetBufferMemoryRequirements(device->GetVkDevice(), mHandle, &requirements);
|
device->fn.GetBufferMemoryRequirements(device->GetVkDevice(), mHandle, &requirements);
|
||||||
|
|
||||||
bool requestMappable =
|
bool requestMappable =
|
||||||
(GetUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) != 0;
|
(GetUsage() & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) != 0;
|
||||||
if (!device->GetMemoryAllocator()->Allocate(requirements, requestMappable,
|
if (!device->GetMemoryAllocator()->Allocate(requirements, requestMappable,
|
||||||
&mMemoryAllocation)) {
|
&mMemoryAllocation)) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
|
@ -164,7 +164,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::TransitionUsageNow(CommandRecordingContext* recordingContext,
|
void Buffer::TransitionUsageNow(CommandRecordingContext* recordingContext,
|
||||||
dawn::BufferUsageBit usage) {
|
dawn::BufferUsage usage) {
|
||||||
bool lastIncludesTarget = (mLastUsage & usage) == usage;
|
bool lastIncludesTarget = (mLastUsage & usage) == usage;
|
||||||
bool lastReadOnly = (mLastUsage & kReadOnlyBufferUsages) == mLastUsage;
|
bool lastReadOnly = (mLastUsage & kReadOnlyBufferUsages) == mLastUsage;
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special-case for the initial transition: Vulkan doesn't allow access flags to be 0.
|
// Special-case for the initial transition: Vulkan doesn't allow access flags to be 0.
|
||||||
if (mLastUsage == dawn::BufferUsageBit::None) {
|
if (mLastUsage == dawn::BufferUsage::None) {
|
||||||
mLastUsage = usage;
|
mLastUsage = usage;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
|
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
|
||||||
TransitionUsageNow(recordingContext, dawn::BufferUsageBit::MapRead);
|
TransitionUsageNow(recordingContext, dawn::BufferUsage::MapRead);
|
||||||
|
|
||||||
uint8_t* memory = mMemoryAllocation.GetMappedPointer();
|
uint8_t* memory = mMemoryAllocation.GetMappedPointer();
|
||||||
ASSERT(memory != nullptr);
|
ASSERT(memory != nullptr);
|
||||||
|
@ -228,7 +228,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
|
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
|
||||||
TransitionUsageNow(recordingContext, dawn::BufferUsageBit::MapWrite);
|
TransitionUsageNow(recordingContext, dawn::BufferUsage::MapWrite);
|
||||||
|
|
||||||
uint8_t* memory = mMemoryAllocation.GetMappedPointer();
|
uint8_t* memory = mMemoryAllocation.GetMappedPointer();
|
||||||
ASSERT(memory != nullptr);
|
ASSERT(memory != nullptr);
|
||||||
|
|
|
@ -39,8 +39,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
// Transitions the buffer to be used as `usage`, recording any necessary barrier in
|
// Transitions the buffer to be used as `usage`, recording any necessary barrier in
|
||||||
// `commands`.
|
// `commands`.
|
||||||
// TODO(cwallez@chromium.org): coalesce barriers and do them early when possible.
|
// TODO(cwallez@chromium.org): coalesce barriers and do them early when possible.
|
||||||
void TransitionUsageNow(CommandRecordingContext* recordingContext,
|
void TransitionUsageNow(CommandRecordingContext* recordingContext, dawn::BufferUsage usage);
|
||||||
dawn::BufferUsageBit usage);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Dawn API
|
// Dawn API
|
||||||
|
@ -55,7 +54,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
VkBuffer mHandle = VK_NULL_HANDLE;
|
VkBuffer mHandle = VK_NULL_HANDLE;
|
||||||
DeviceMemoryAllocation mMemoryAllocation;
|
DeviceMemoryAllocation mMemoryAllocation;
|
||||||
|
|
||||||
dawn::BufferUsageBit mLastUsage = dawn::BufferUsageBit::None;
|
dawn::BufferUsage mLastUsage = dawn::BufferUsage::None;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapRequestTracker {
|
class MapRequestTracker {
|
||||||
|
|
|
@ -327,7 +327,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
format.blockByteSize;
|
format.blockByteSize;
|
||||||
BufferDescriptor tempBufferDescriptor;
|
BufferDescriptor tempBufferDescriptor;
|
||||||
tempBufferDescriptor.size = tempBufferSize;
|
tempBufferDescriptor.size = tempBufferSize;
|
||||||
tempBufferDescriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
tempBufferDescriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
|
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
Ref<Buffer> tempBuffer = ToBackend(device->CreateBuffer(&tempBufferDescriptor));
|
Ref<Buffer> tempBuffer = ToBackend(device->CreateBuffer(&tempBufferDescriptor));
|
||||||
|
@ -347,7 +347,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
VkImage srcImage = ToBackend(srcCopy.texture)->GetHandle();
|
VkImage srcImage = ToBackend(srcCopy.texture)->GetHandle();
|
||||||
VkImage dstImage = ToBackend(dstCopy.texture)->GetHandle();
|
VkImage dstImage = ToBackend(dstCopy.texture)->GetHandle();
|
||||||
|
|
||||||
tempBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsageBit::CopyDst);
|
tempBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopyDst);
|
||||||
VkBufferImageCopy srcToTempBufferRegion =
|
VkBufferImageCopy srcToTempBufferRegion =
|
||||||
ComputeBufferImageCopyRegion(tempBufferCopy, srcCopy, copySize);
|
ComputeBufferImageCopyRegion(tempBufferCopy, srcCopy, copySize);
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
device->fn.CmdCopyImageToBuffer(commands, srcImage, VK_IMAGE_LAYOUT_GENERAL,
|
device->fn.CmdCopyImageToBuffer(commands, srcImage, VK_IMAGE_LAYOUT_GENERAL,
|
||||||
tempBuffer->GetHandle(), 1, &srcToTempBufferRegion);
|
tempBuffer->GetHandle(), 1, &srcToTempBufferRegion);
|
||||||
|
|
||||||
tempBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsageBit::CopySrc);
|
tempBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopySrc);
|
||||||
VkBufferImageCopy tempBufferToDstRegion =
|
VkBufferImageCopy tempBufferToDstRegion =
|
||||||
ComputeBufferImageCopyRegion(tempBufferCopy, dstCopy, copySize);
|
ComputeBufferImageCopyRegion(tempBufferCopy, dstCopy, copySize);
|
||||||
|
|
||||||
|
@ -384,7 +384,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
// Clear textures that are not output attachments. Output attachments will be
|
// Clear textures that are not output attachments. Output attachments will be
|
||||||
// cleared in RecordBeginRenderPass by setting the loadop to clear when the
|
// cleared in RecordBeginRenderPass by setting the loadop to clear when the
|
||||||
// texture subresource has not been initialized before the render pass.
|
// texture subresource has not been initialized before the render pass.
|
||||||
if (!(usages.textureUsages[i] & dawn::TextureUsageBit::OutputAttachment)) {
|
if (!(usages.textureUsages[i] & dawn::TextureUsage::OutputAttachment)) {
|
||||||
texture->EnsureSubresourceContentInitialized(recordingContext, 0,
|
texture->EnsureSubresourceContentInitialized(recordingContext, 0,
|
||||||
texture->GetNumMipLevels(), 0,
|
texture->GetNumMipLevels(), 0,
|
||||||
texture->GetArrayLayers());
|
texture->GetArrayLayers());
|
||||||
|
@ -403,8 +403,8 @@ namespace dawn_native { namespace vulkan {
|
||||||
Buffer* srcBuffer = ToBackend(copy->source.Get());
|
Buffer* srcBuffer = ToBackend(copy->source.Get());
|
||||||
Buffer* dstBuffer = ToBackend(copy->destination.Get());
|
Buffer* dstBuffer = ToBackend(copy->destination.Get());
|
||||||
|
|
||||||
srcBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsageBit::CopySrc);
|
srcBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopySrc);
|
||||||
dstBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsageBit::CopyDst);
|
dstBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
VkBufferCopy region;
|
VkBufferCopy region;
|
||||||
region.srcOffset = copy->sourceOffset;
|
region.srcOffset = copy->sourceOffset;
|
||||||
|
@ -437,9 +437,9 @@ namespace dawn_native { namespace vulkan {
|
||||||
subresource.baseArrayLayer, 1);
|
subresource.baseArrayLayer, 1);
|
||||||
}
|
}
|
||||||
ToBackend(src.buffer)
|
ToBackend(src.buffer)
|
||||||
->TransitionUsageNow(recordingContext, dawn::BufferUsageBit::CopySrc);
|
->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopySrc);
|
||||||
ToBackend(dst.texture)
|
ToBackend(dst.texture)
|
||||||
->TransitionUsageNow(recordingContext, dawn::TextureUsageBit::CopyDst);
|
->TransitionUsageNow(recordingContext, dawn::TextureUsage::CopyDst);
|
||||||
VkBuffer srcBuffer = ToBackend(src.buffer)->GetHandle();
|
VkBuffer srcBuffer = ToBackend(src.buffer)->GetHandle();
|
||||||
VkImage dstImage = ToBackend(dst.texture)->GetHandle();
|
VkImage dstImage = ToBackend(dst.texture)->GetHandle();
|
||||||
|
|
||||||
|
@ -465,9 +465,9 @@ namespace dawn_native { namespace vulkan {
|
||||||
subresource.baseArrayLayer, 1);
|
subresource.baseArrayLayer, 1);
|
||||||
|
|
||||||
ToBackend(src.texture)
|
ToBackend(src.texture)
|
||||||
->TransitionUsageNow(recordingContext, dawn::TextureUsageBit::CopySrc);
|
->TransitionUsageNow(recordingContext, dawn::TextureUsage::CopySrc);
|
||||||
ToBackend(dst.buffer)
|
ToBackend(dst.buffer)
|
||||||
->TransitionUsageNow(recordingContext, dawn::BufferUsageBit::CopyDst);
|
->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
VkImage srcImage = ToBackend(src.texture)->GetHandle();
|
VkImage srcImage = ToBackend(src.texture)->GetHandle();
|
||||||
VkBuffer dstBuffer = ToBackend(dst.buffer)->GetHandle();
|
VkBuffer dstBuffer = ToBackend(dst.buffer)->GetHandle();
|
||||||
|
@ -497,9 +497,9 @@ namespace dawn_native { namespace vulkan {
|
||||||
}
|
}
|
||||||
|
|
||||||
ToBackend(src.texture)
|
ToBackend(src.texture)
|
||||||
->TransitionUsageNow(recordingContext, dawn::TextureUsageBit::CopySrc);
|
->TransitionUsageNow(recordingContext, dawn::TextureUsage::CopySrc);
|
||||||
ToBackend(dst.texture)
|
ToBackend(dst.texture)
|
||||||
->TransitionUsageNow(recordingContext, dawn::TextureUsageBit::CopyDst);
|
->TransitionUsageNow(recordingContext, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// In some situations we cannot do texture-to-texture copies with vkCmdCopyImage
|
// In some situations we cannot do texture-to-texture copies with vkCmdCopyImage
|
||||||
// because as Vulkan SPEC always validates image copies with the virtual size of
|
// because as Vulkan SPEC always validates image copies with the virtual size of
|
||||||
|
|
|
@ -568,7 +568,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
// Insert pipeline barrier to ensure correct ordering with previous memory operations on the
|
// Insert pipeline barrier to ensure correct ordering with previous memory operations on the
|
||||||
// buffer.
|
// buffer.
|
||||||
ToBackend(destination)
|
ToBackend(destination)
|
||||||
->TransitionUsageNow(GetPendingRecordingContext(), dawn::BufferUsageBit::CopyDst);
|
->TransitionUsageNow(GetPendingRecordingContext(), dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
VkBufferCopy copy;
|
VkBufferCopy copy;
|
||||||
copy.srcOffset = sourceOffset;
|
copy.srcOffset = sourceOffset;
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
DawnSwapChainError NativeSwapChainImpl::Configure(DawnTextureFormat format,
|
||||||
DawnTextureUsageBit usage,
|
DawnTextureUsage usage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
UpdateSurfaceConfig();
|
UpdateSurfaceConfig();
|
||||||
|
@ -99,7 +99,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
createInfo.imageExtent.width = width;
|
createInfo.imageExtent.width = width;
|
||||||
createInfo.imageExtent.height = height;
|
createInfo.imageExtent.height = height;
|
||||||
createInfo.imageArrayLayers = 1;
|
createInfo.imageArrayLayers = 1;
|
||||||
createInfo.imageUsage = VulkanImageUsage(static_cast<dawn::TextureUsageBit>(usage),
|
createInfo.imageUsage = VulkanImageUsage(static_cast<dawn::TextureUsage>(usage),
|
||||||
mDevice->GetValidInternalFormat(mConfig.format));
|
mDevice->GetValidInternalFormat(mConfig.format));
|
||||||
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
createInfo.queueFamilyIndexCount = 0;
|
createInfo.queueFamilyIndexCount = 0;
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
void Init(DawnWSIContextVulkan* context);
|
void Init(DawnWSIContextVulkan* context);
|
||||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
DawnSwapChainError Configure(DawnTextureFormat format,
|
||||||
DawnTextureUsageBit,
|
DawnTextureUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||||
|
|
|
@ -25,8 +25,8 @@ namespace dawn_native { namespace vulkan {
|
||||||
DawnWSIContextVulkan wsiContext = {};
|
DawnWSIContextVulkan wsiContext = {};
|
||||||
im.Init(im.userData, &wsiContext);
|
im.Init(im.userData, &wsiContext);
|
||||||
|
|
||||||
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_BIT_NONE);
|
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_NONE);
|
||||||
mTextureUsage = static_cast<dawn::TextureUsageBit>(im.textureUsage);
|
mTextureUsage = static_cast<dawn::TextureUsage>(im.textureUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
SwapChain::~SwapChain() {
|
SwapChain::~SwapChain() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
void OnBeforePresent(TextureBase* texture) override;
|
void OnBeforePresent(TextureBase* texture) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
dawn::TextureUsageBit mTextureUsage;
|
dawn::TextureUsage mTextureUsage;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::vulkan
|
}} // namespace dawn_native::vulkan
|
||||||
|
|
|
@ -55,22 +55,22 @@ namespace dawn_native { namespace vulkan {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Computes which vulkan access type could be required for the given Dawn usage.
|
// Computes which vulkan access type could be required for the given Dawn usage.
|
||||||
VkAccessFlags VulkanAccessFlags(dawn::TextureUsageBit usage, const Format& format) {
|
VkAccessFlags VulkanAccessFlags(dawn::TextureUsage usage, const Format& format) {
|
||||||
VkAccessFlags flags = 0;
|
VkAccessFlags flags = 0;
|
||||||
|
|
||||||
if (usage & dawn::TextureUsageBit::CopySrc) {
|
if (usage & dawn::TextureUsage::CopySrc) {
|
||||||
flags |= VK_ACCESS_TRANSFER_READ_BIT;
|
flags |= VK_ACCESS_TRANSFER_READ_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::CopyDst) {
|
if (usage & dawn::TextureUsage::CopyDst) {
|
||||||
flags |= VK_ACCESS_TRANSFER_WRITE_BIT;
|
flags |= VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::Sampled) {
|
if (usage & dawn::TextureUsage::Sampled) {
|
||||||
flags |= VK_ACCESS_SHADER_READ_BIT;
|
flags |= VK_ACCESS_SHADER_READ_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::Storage) {
|
if (usage & dawn::TextureUsage::Storage) {
|
||||||
flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
|
flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::OutputAttachment) {
|
if (usage & dawn::TextureUsage::OutputAttachment) {
|
||||||
if (format.HasDepthOrStencil()) {
|
if (format.HasDepthOrStencil()) {
|
||||||
flags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
flags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
|
||||||
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||||
|
@ -79,7 +79,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::Present) {
|
if (usage & dawn::TextureUsage::Present) {
|
||||||
// There is no access flag for present because the VK_KHR_SWAPCHAIN extension says
|
// There is no access flag for present because the VK_KHR_SWAPCHAIN extension says
|
||||||
// that vkQueuePresentKHR makes the memory of the image visible to the presentation
|
// that vkQueuePresentKHR makes the memory of the image visible to the presentation
|
||||||
// engine. There's also a note explicitly saying dstAccessMask should be 0. On the
|
// engine. There's also a note explicitly saying dstAccessMask should be 0. On the
|
||||||
|
@ -92,8 +92,8 @@ namespace dawn_native { namespace vulkan {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chooses which Vulkan image layout should be used for the given Dawn usage
|
// Chooses which Vulkan image layout should be used for the given Dawn usage
|
||||||
VkImageLayout VulkanImageLayout(dawn::TextureUsageBit usage, const Format& format) {
|
VkImageLayout VulkanImageLayout(dawn::TextureUsage usage, const Format& format) {
|
||||||
if (usage == dawn::TextureUsageBit::None) {
|
if (usage == dawn::TextureUsage::None) {
|
||||||
return VK_IMAGE_LAYOUT_UNDEFINED;
|
return VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,27 +103,27 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
// Usage has a single bit so we can switch on its value directly.
|
// Usage has a single bit so we can switch on its value directly.
|
||||||
switch (usage) {
|
switch (usage) {
|
||||||
case dawn::TextureUsageBit::CopyDst:
|
case dawn::TextureUsage::CopyDst:
|
||||||
return VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
return VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||||
case dawn::TextureUsageBit::Sampled:
|
case dawn::TextureUsage::Sampled:
|
||||||
return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
// Vulkan texture copy functions require the image to be in _one_ known layout.
|
// Vulkan texture copy functions require the image to be in _one_ known layout.
|
||||||
// Depending on whether parts of the texture have been transitioned to only
|
// Depending on whether parts of the texture have been transitioned to only
|
||||||
// CopySrc or a combination with something else, the texture could be in a
|
// CopySrc or a combination with something else, the texture could be in a
|
||||||
// combination of GENERAL and TRANSFER_SRC_OPTIMAL. This would be a problem, so we
|
// combination of GENERAL and TRANSFER_SRC_OPTIMAL. This would be a problem, so we
|
||||||
// make CopySrc use GENERAL.
|
// make CopySrc use GENERAL.
|
||||||
case dawn::TextureUsageBit::CopySrc:
|
case dawn::TextureUsage::CopySrc:
|
||||||
// Writable storage textures must use general. If we could know the texture is read
|
// Writable storage textures must use general. If we could know the texture is read
|
||||||
// only we could use SHADER_READ_ONLY_OPTIMAL
|
// only we could use SHADER_READ_ONLY_OPTIMAL
|
||||||
case dawn::TextureUsageBit::Storage:
|
case dawn::TextureUsage::Storage:
|
||||||
return VK_IMAGE_LAYOUT_GENERAL;
|
return VK_IMAGE_LAYOUT_GENERAL;
|
||||||
case dawn::TextureUsageBit::OutputAttachment:
|
case dawn::TextureUsage::OutputAttachment:
|
||||||
if (format.HasDepthOrStencil()) {
|
if (format.HasDepthOrStencil()) {
|
||||||
return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||||
} else {
|
} else {
|
||||||
return VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
return VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
}
|
}
|
||||||
case dawn::TextureUsageBit::Present:
|
case dawn::TextureUsage::Present:
|
||||||
return VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
return VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
@ -131,24 +131,23 @@ namespace dawn_native { namespace vulkan {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Computes which Vulkan pipeline stage can access a texture in the given Dawn usage
|
// Computes which Vulkan pipeline stage can access a texture in the given Dawn usage
|
||||||
VkPipelineStageFlags VulkanPipelineStage(dawn::TextureUsageBit usage,
|
VkPipelineStageFlags VulkanPipelineStage(dawn::TextureUsage usage, const Format& format) {
|
||||||
const Format& format) {
|
|
||||||
VkPipelineStageFlags flags = 0;
|
VkPipelineStageFlags flags = 0;
|
||||||
|
|
||||||
if (usage == dawn::TextureUsageBit::None) {
|
if (usage == dawn::TextureUsage::None) {
|
||||||
// This only happens when a texture is initially created (and for srcAccessMask) in
|
// This only happens when a texture is initially created (and for srcAccessMask) in
|
||||||
// which case there is no need to wait on anything to stop accessing this texture.
|
// which case there is no need to wait on anything to stop accessing this texture.
|
||||||
return VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
return VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
||||||
}
|
}
|
||||||
if (usage & (dawn::TextureUsageBit::CopySrc | dawn::TextureUsageBit::CopyDst)) {
|
if (usage & (dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst)) {
|
||||||
flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
|
flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||||
}
|
}
|
||||||
if (usage & (dawn::TextureUsageBit::Sampled | dawn::TextureUsageBit::Storage)) {
|
if (usage & (dawn::TextureUsage::Sampled | dawn::TextureUsage::Storage)) {
|
||||||
flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
|
flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
|
||||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
|
||||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
|
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::OutputAttachment) {
|
if (usage & dawn::TextureUsage::OutputAttachment) {
|
||||||
if (format.HasDepthOrStencil()) {
|
if (format.HasDepthOrStencil()) {
|
||||||
flags |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
|
flags |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
|
||||||
VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
||||||
|
@ -158,7 +157,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
flags |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
flags |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::Present) {
|
if (usage & dawn::TextureUsage::Present) {
|
||||||
// There is no pipeline stage for present but a pipeline stage is required so we use
|
// There is no pipeline stage for present but a pipeline stage is required so we use
|
||||||
// "bottom of pipe" to block as little as possible and vkQueuePresentKHR will make
|
// "bottom of pipe" to block as little as possible and vkQueuePresentKHR will make
|
||||||
// the memory visible to the presentation engine. The spec explicitly mentions that
|
// the memory visible to the presentation engine. The spec explicitly mentions that
|
||||||
|
@ -333,22 +332,22 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
// Converts the Dawn usage flags to Vulkan usage flags. Also needs the format to choose
|
// Converts the Dawn usage flags to Vulkan usage flags. Also needs the format to choose
|
||||||
// between color and depth attachment usages.
|
// between color and depth attachment usages.
|
||||||
VkImageUsageFlags VulkanImageUsage(dawn::TextureUsageBit usage, const Format& format) {
|
VkImageUsageFlags VulkanImageUsage(dawn::TextureUsage usage, const Format& format) {
|
||||||
VkImageUsageFlags flags = 0;
|
VkImageUsageFlags flags = 0;
|
||||||
|
|
||||||
if (usage & dawn::TextureUsageBit::CopySrc) {
|
if (usage & dawn::TextureUsage::CopySrc) {
|
||||||
flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::CopyDst) {
|
if (usage & dawn::TextureUsage::CopyDst) {
|
||||||
flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::Sampled) {
|
if (usage & dawn::TextureUsage::Sampled) {
|
||||||
flags |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
flags |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::Storage) {
|
if (usage & dawn::TextureUsage::Storage) {
|
||||||
flags |= VK_IMAGE_USAGE_STORAGE_BIT;
|
flags |= VK_IMAGE_USAGE_STORAGE_BIT;
|
||||||
}
|
}
|
||||||
if (usage & dawn::TextureUsageBit::OutputAttachment) {
|
if (usage & dawn::TextureUsage::OutputAttachment) {
|
||||||
if (format.HasDepthOrStencil()) {
|
if (format.HasDepthOrStencil()) {
|
||||||
flags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
flags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||||
} else {
|
} else {
|
||||||
|
@ -527,7 +526,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
// Release the texture
|
// Release the texture
|
||||||
mExternalState = ExternalState::PendingRelease;
|
mExternalState = ExternalState::PendingRelease;
|
||||||
TransitionUsageNow(device->GetPendingRecordingContext(), dawn::TextureUsageBit::None);
|
TransitionUsageNow(device->GetPendingRecordingContext(), dawn::TextureUsage::None);
|
||||||
|
|
||||||
// Queue submit to signal we are done with the texture
|
// Queue submit to signal we are done with the texture
|
||||||
device->GetPendingRecordingContext()->signalSemaphores.push_back(mSignalSemaphore);
|
device->GetPendingRecordingContext()->signalSemaphores.push_back(mSignalSemaphore);
|
||||||
|
@ -580,7 +579,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::TransitionUsageNow(CommandRecordingContext* recordingContext,
|
void Texture::TransitionUsageNow(CommandRecordingContext* recordingContext,
|
||||||
dawn::TextureUsageBit usage) {
|
dawn::TextureUsage usage) {
|
||||||
// Avoid encoding barriers when it isn't needed.
|
// Avoid encoding barriers when it isn't needed.
|
||||||
bool lastReadOnly = (mLastUsage & kReadOnlyTextureUsages) == mLastUsage;
|
bool lastReadOnly = (mLastUsage & kReadOnlyTextureUsages) == mLastUsage;
|
||||||
if (lastReadOnly && mLastUsage == usage && mLastExternalState == mExternalState) {
|
if (lastReadOnly && mLastUsage == usage && mLastExternalState == mExternalState) {
|
||||||
|
@ -654,7 +653,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
range.layerCount = layerCount;
|
range.layerCount = layerCount;
|
||||||
uint8_t clearColor = (clearValue == TextureBase::ClearValue::Zero) ? 0 : 1;
|
uint8_t clearColor = (clearValue == TextureBase::ClearValue::Zero) ? 0 : 1;
|
||||||
|
|
||||||
TransitionUsageNow(recordingContext, dawn::TextureUsageBit::CopyDst);
|
TransitionUsageNow(recordingContext, dawn::TextureUsage::CopyDst);
|
||||||
if (GetFormat().HasDepthOrStencil()) {
|
if (GetFormat().HasDepthOrStencil()) {
|
||||||
VkClearDepthStencilValue clearDepthStencilValue[1];
|
VkClearDepthStencilValue clearDepthStencilValue[1];
|
||||||
clearDepthStencilValue[0].depth = clearColor;
|
clearDepthStencilValue[0].depth = clearColor;
|
||||||
|
@ -679,7 +678,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
(GetSize().height / GetFormat().blockHeight) *
|
(GetSize().height / GetFormat().blockHeight) *
|
||||||
GetFormat().blockByteSize;
|
GetFormat().blockByteSize;
|
||||||
descriptor.nextInChain = nullptr;
|
descriptor.nextInChain = nullptr;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::MapWrite;
|
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::MapWrite;
|
||||||
std::unique_ptr<Buffer> srcBuffer =
|
std::unique_ptr<Buffer> srcBuffer =
|
||||||
std::make_unique<dawn_native::vulkan::Buffer>(device, &descriptor);
|
std::make_unique<dawn_native::vulkan::Buffer>(device, &descriptor);
|
||||||
uint8_t* clearBuffer = nullptr;
|
uint8_t* clearBuffer = nullptr;
|
||||||
|
@ -706,7 +705,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
ComputeBufferImageCopyRegion(bufferCopy, textureCopy, copySize);
|
ComputeBufferImageCopyRegion(bufferCopy, textureCopy, copySize);
|
||||||
|
|
||||||
// copy the clear buffer to the texture image
|
// copy the clear buffer to the texture image
|
||||||
srcBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsageBit::CopySrc);
|
srcBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopySrc);
|
||||||
ToBackend(GetDevice())
|
ToBackend(GetDevice())
|
||||||
->fn.CmdCopyBufferToImage(recordingContext->commandBuffer, srcBuffer->GetHandle(),
|
->fn.CmdCopyBufferToImage(recordingContext->commandBuffer, srcBuffer->GetHandle(),
|
||||||
GetHandle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1,
|
GetHandle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1,
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
struct ExternalImageDescriptor;
|
struct ExternalImageDescriptor;
|
||||||
|
|
||||||
VkFormat VulkanImageFormat(dawn::TextureFormat format);
|
VkFormat VulkanImageFormat(dawn::TextureFormat format);
|
||||||
VkImageUsageFlags VulkanImageUsage(dawn::TextureUsageBit usage, const Format& format);
|
VkImageUsageFlags VulkanImageUsage(dawn::TextureUsage usage, const Format& format);
|
||||||
VkSampleCountFlagBits VulkanSampleCount(uint32_t sampleCount);
|
VkSampleCountFlagBits VulkanSampleCount(uint32_t sampleCount);
|
||||||
|
|
||||||
MaybeError ValidateVulkanImageCanBeWrapped(const DeviceBase* device,
|
MaybeError ValidateVulkanImageCanBeWrapped(const DeviceBase* device,
|
||||||
|
@ -60,7 +60,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
// `commands`.
|
// `commands`.
|
||||||
// TODO(cwallez@chromium.org): coalesce barriers and do them early when possible.
|
// TODO(cwallez@chromium.org): coalesce barriers and do them early when possible.
|
||||||
void TransitionUsageNow(CommandRecordingContext* recordingContext,
|
void TransitionUsageNow(CommandRecordingContext* recordingContext,
|
||||||
dawn::TextureUsageBit usage);
|
dawn::TextureUsage usage);
|
||||||
void EnsureSubresourceContentInitialized(CommandRecordingContext* recordingContext,
|
void EnsureSubresourceContentInitialized(CommandRecordingContext* recordingContext,
|
||||||
uint32_t baseMipLevel,
|
uint32_t baseMipLevel,
|
||||||
uint32_t levelCount,
|
uint32_t levelCount,
|
||||||
|
@ -89,7 +89,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
// A usage of none will make sure the texture is transitioned before its first use as
|
// A usage of none will make sure the texture is transitioned before its first use as
|
||||||
// required by the spec.
|
// required by the spec.
|
||||||
dawn::TextureUsageBit mLastUsage = dawn::TextureUsageBit::None;
|
dawn::TextureUsage mLastUsage = dawn::TextureUsage::None;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextureView : public TextureViewBase {
|
class TextureView : public TextureViewBase {
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
DawnSwapChainImplementation impl;
|
DawnSwapChainImplementation impl;
|
||||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, surface));
|
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, surface));
|
||||||
impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
|
impl.textureUsage = DAWN_TEXTURE_USAGE_PRESENT;
|
||||||
|
|
||||||
return impl;
|
return impl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ typedef struct {
|
||||||
/// Configure/reconfigure the swap chain.
|
/// Configure/reconfigure the swap chain.
|
||||||
DawnSwapChainError (*Configure)(void* userData,
|
DawnSwapChainError (*Configure)(void* userData,
|
||||||
DawnTextureFormat format,
|
DawnTextureFormat format,
|
||||||
DawnTextureUsageBit allowedUsage,
|
DawnTextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ typedef struct {
|
||||||
void* userData;
|
void* userData;
|
||||||
|
|
||||||
/// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
|
/// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
|
||||||
DawnTextureUsageBit textureUsage;
|
DawnTextureUsage textureUsage;
|
||||||
} DawnSwapChainImplementation;
|
} DawnSwapChainImplementation;
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
|
#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
|
||||||
|
|
|
@ -587,7 +587,7 @@ DawnTest::ReadbackReservation DawnTest::ReserveReadback(uint64_t readbackSize) {
|
||||||
// TODO(cwallez@chromium.org): eventually make bigger buffers and allocate linearly?
|
// TODO(cwallez@chromium.org): eventually make bigger buffers and allocate linearly?
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = readbackSize;
|
descriptor.size = readbackSize;
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::MapRead | dawn::BufferUsage::CopyDst;
|
||||||
|
|
||||||
ReadbackSlot slot;
|
ReadbackSlot slot;
|
||||||
slot.bufferSize = readbackSize;
|
slot.bufferSize = readbackSize;
|
||||||
|
|
|
@ -24,7 +24,7 @@ class BasicTests : public DawnTest {
|
||||||
TEST_P(BasicTests, BufferSetSubData) {
|
TEST_P(BasicTests, BufferSetSubData) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
uint32_t value = 0x01020304;
|
uint32_t value = 0x01020304;
|
||||||
|
@ -38,7 +38,7 @@ TEST_P(BasicTests, BufferSetSubData) {
|
||||||
TEST_P(BasicTests, BufferSetSubDataError) {
|
TEST_P(BasicTests, BufferSetSubDataError) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
uint8_t value = 187;
|
uint8_t value = 187;
|
||||||
|
|
|
@ -79,7 +79,7 @@ TEST_P(BindGroupTests, ReusedBindGroupSingleSubmit) {
|
||||||
|
|
||||||
dawn::BufferDescriptor bufferDesc;
|
dawn::BufferDescriptor bufferDesc;
|
||||||
bufferDesc.size = sizeof(float);
|
bufferDesc.size = sizeof(float);
|
||||||
bufferDesc.usage = dawn::BufferUsageBit::CopyDst | dawn::BufferUsageBit::Uniform;
|
bufferDesc.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::Uniform;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&bufferDesc);
|
dawn::Buffer buffer = device.CreateBuffer(&bufferDesc);
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, sizeof(float)}});
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, sizeof(float)}});
|
||||||
|
|
||||||
|
@ -148,7 +148,8 @@ TEST_P(BindGroupTests, ReusedUBO) {
|
||||||
{ 0 },
|
{ 0 },
|
||||||
{ 0.f, 1.f, 0.f, 1.f },
|
{ 0.f, 1.f, 0.f, 1.f },
|
||||||
};
|
};
|
||||||
dawn::Buffer buffer = utils::CreateBufferFromData(device, &data, sizeof(data), dawn::BufferUsageBit::Uniform);
|
dawn::Buffer buffer =
|
||||||
|
utils::CreateBufferFromData(device, &data, sizeof(data), dawn::BufferUsage::Uniform);
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, buffer, 0, sizeof(Data::transform)},
|
{0, buffer, 0, sizeof(Data::transform)},
|
||||||
{1, buffer, 256, sizeof(Data::color)}
|
{1, buffer, 256, sizeof(Data::color)}
|
||||||
|
@ -222,7 +223,8 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
||||||
|
|
||||||
constexpr float dummy = 0.0f;
|
constexpr float dummy = 0.0f;
|
||||||
constexpr float transform[] = { 1.f, 0.f, dummy, dummy, 0.f, 1.f, dummy, dummy };
|
constexpr float transform[] = { 1.f, 0.f, dummy, dummy, 0.f, 1.f, dummy, dummy };
|
||||||
dawn::Buffer buffer = utils::CreateBufferFromData(device, &transform, sizeof(transform), dawn::BufferUsageBit::Uniform);
|
dawn::Buffer buffer = utils::CreateBufferFromData(device, &transform, sizeof(transform),
|
||||||
|
dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
dawn::SamplerDescriptor samplerDescriptor;
|
dawn::SamplerDescriptor samplerDescriptor;
|
||||||
samplerDescriptor.minFilter = dawn::FilterMode::Nearest;
|
samplerDescriptor.minFilter = dawn::FilterMode::Nearest;
|
||||||
|
@ -246,7 +248,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::Sampled;
|
descriptor.usage = dawn::TextureUsage::CopyDst | dawn::TextureUsage::Sampled;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
dawn::TextureView textureView = texture.CreateDefaultView();
|
dawn::TextureView textureView = texture.CreateDefaultView();
|
||||||
|
|
||||||
|
@ -259,8 +261,8 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
data[i] = RGBA8(0, 255, 0, 255);
|
data[i] = RGBA8(0, 255, 0, 255);
|
||||||
}
|
}
|
||||||
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(device, data.data(), sizeInBytes,
|
dawn::Buffer stagingBuffer =
|
||||||
dawn::BufferUsageBit::CopySrc);
|
utils::CreateBufferFromData(device, data.data(), sizeInBytes, dawn::BufferUsage::CopySrc);
|
||||||
|
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, buffer, 0, sizeof(transform)},
|
{0, buffer, 0, sizeof(transform)},
|
||||||
|
@ -360,8 +362,8 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
|
||||||
{{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}, {0}, {1.0f, 0.0f, 0.0f, 1.0f}});
|
{{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}, {0}, {1.0f, 0.0f, 0.0f, 1.0f}});
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
dawn::Buffer buffer = utils::CreateBufferFromData(device, &data[i], sizeof(Data),
|
dawn::Buffer buffer =
|
||||||
dawn::BufferUsageBit::Uniform);
|
utils::CreateBufferFromData(device, &data[i], sizeof(Data), dawn::BufferUsage::Uniform);
|
||||||
buffers.push_back(buffer);
|
buffers.push_back(buffer);
|
||||||
bindGroups.push_back(utils::MakeBindGroup(device, layout,
|
bindGroups.push_back(utils::MakeBindGroup(device, layout,
|
||||||
{{0, buffers[i], 0, sizeof(Data::transform)},
|
{{0, buffers[i], 0, sizeof(Data::transform)},
|
||||||
|
@ -441,8 +443,8 @@ TEST_P(BindGroupTests, DrawTwiceInSamePipelineWithFourBindGroupSets)
|
||||||
pass.SetPipeline(pipeline);
|
pass.SetPipeline(pipeline);
|
||||||
|
|
||||||
std::array<float, 4> color = { 0.25, 0, 0, 0.25 };
|
std::array<float, 4> color = { 0.25, 0, 0, 0.25 };
|
||||||
dawn::Buffer uniformBuffer = utils::CreateBufferFromData(
|
dawn::Buffer uniformBuffer =
|
||||||
device, &color, sizeof(color), dawn::BufferUsageBit::Uniform);
|
utils::CreateBufferFromData(device, &color, sizeof(color), dawn::BufferUsage::Uniform);
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
||||||
device, layout, { { 0, uniformBuffer, 0, sizeof(color) } });
|
device, layout, { { 0, uniformBuffer, 0, sizeof(color) } });
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class BufferMapReadTests : public DawnTest {
|
||||||
TEST_P(BufferMapReadTests, SmallReadAtZero) {
|
TEST_P(BufferMapReadTests, SmallReadAtZero) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::MapRead | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
uint32_t myData = 0x01020304;
|
uint32_t myData = 0x01020304;
|
||||||
|
@ -68,7 +68,7 @@ TEST_P(BufferMapReadTests, LargeRead) {
|
||||||
|
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = static_cast<uint32_t>(kDataSize * sizeof(uint32_t));
|
descriptor.size = static_cast<uint32_t>(kDataSize * sizeof(uint32_t));
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::MapRead | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
buffer.SetSubData(0, kDataSize * sizeof(uint32_t), myData.data());
|
buffer.SetSubData(0, kDataSize * sizeof(uint32_t), myData.data());
|
||||||
|
@ -115,7 +115,7 @@ class BufferMapWriteTests : public DawnTest {
|
||||||
TEST_P(BufferMapWriteTests, SmallWriteAtZero) {
|
TEST_P(BufferMapWriteTests, SmallWriteAtZero) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc;
|
descriptor.usage = dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
uint32_t myData = 2934875;
|
uint32_t myData = 2934875;
|
||||||
|
@ -136,7 +136,7 @@ TEST_P(BufferMapWriteTests, LargeWrite) {
|
||||||
|
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = static_cast<uint32_t>(kDataSize * sizeof(uint32_t));
|
descriptor.size = static_cast<uint32_t>(kDataSize * sizeof(uint32_t));
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc;
|
descriptor.usage = dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
void* mappedData = MapWriteAsyncAndWait(buffer);
|
void* mappedData = MapWriteAsyncAndWait(buffer);
|
||||||
|
@ -160,7 +160,7 @@ TEST_P(BufferMapWriteTests, ManyWrites) {
|
||||||
for (uint32_t i = 0; i < kBuffers; ++i) {
|
for (uint32_t i = 0; i < kBuffers; ++i) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = static_cast<uint32_t>(kDataSize * sizeof(uint32_t));
|
descriptor.size = static_cast<uint32_t>(kDataSize * sizeof(uint32_t));
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc;
|
descriptor.usage = dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
void* mappedData = MapWriteAsyncAndWait(buffer);
|
void* mappedData = MapWriteAsyncAndWait(buffer);
|
||||||
|
@ -184,7 +184,7 @@ class BufferSetSubDataTests : public DawnTest {
|
||||||
TEST_P(BufferSetSubDataTests, SmallDataAtZero) {
|
TEST_P(BufferSetSubDataTests, SmallDataAtZero) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
uint32_t value = 0x01020304;
|
uint32_t value = 0x01020304;
|
||||||
|
@ -197,7 +197,7 @@ TEST_P(BufferSetSubDataTests, SmallDataAtZero) {
|
||||||
TEST_P(BufferSetSubDataTests, SmallDataAtOffset) {
|
TEST_P(BufferSetSubDataTests, SmallDataAtOffset) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4000;
|
descriptor.size = 4000;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
constexpr uint64_t kOffset = 2000;
|
constexpr uint64_t kOffset = 2000;
|
||||||
|
@ -222,7 +222,7 @@ TEST_P(BufferSetSubDataTests, ManySetSubData) {
|
||||||
constexpr uint32_t kElements = 500 * 500;
|
constexpr uint32_t kElements = 500 * 500;
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = kSize;
|
descriptor.size = kSize;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
std::vector<uint32_t> expectedData;
|
std::vector<uint32_t> expectedData;
|
||||||
|
@ -240,7 +240,7 @@ TEST_P(BufferSetSubDataTests, LargeSetSubData) {
|
||||||
constexpr uint32_t kElements = 1000 * 1000;
|
constexpr uint32_t kElements = 1000 * 1000;
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = kSize;
|
descriptor.size = kSize;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
std::vector<uint32_t> expectedData;
|
std::vector<uint32_t> expectedData;
|
||||||
|
@ -290,7 +290,7 @@ class CreateBufferMappedTests : public DawnTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CreateBufferMappedResult CreateBufferMapped(dawn::BufferUsageBit usage, uint64_t size) {
|
dawn::CreateBufferMappedResult CreateBufferMapped(dawn::BufferUsage usage, uint64_t size) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.nextInChain = nullptr;
|
descriptor.nextInChain = nullptr;
|
||||||
descriptor.size = size;
|
descriptor.size = size;
|
||||||
|
@ -301,7 +301,7 @@ class CreateBufferMappedTests : public DawnTest {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CreateBufferMappedResult CreateBufferMappedWithData(dawn::BufferUsageBit usage,
|
dawn::CreateBufferMappedResult CreateBufferMappedWithData(dawn::BufferUsage usage,
|
||||||
const std::vector<uint32_t>& data) {
|
const std::vector<uint32_t>& data) {
|
||||||
size_t byteLength = data.size() * sizeof(uint32_t);
|
size_t byteLength = data.size() * sizeof(uint32_t);
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMapped(usage, byteLength);
|
dawn::CreateBufferMappedResult result = CreateBufferMapped(usage, byteLength);
|
||||||
|
@ -311,7 +311,7 @@ class CreateBufferMappedTests : public DawnTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <DawnBufferMapAsyncStatus expectedStatus = DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS>
|
template <DawnBufferMapAsyncStatus expectedStatus = DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS>
|
||||||
dawn::CreateBufferMappedResult CreateBufferMappedAsyncAndWait(dawn::BufferUsageBit usage,
|
dawn::CreateBufferMappedResult CreateBufferMappedAsyncAndWait(dawn::BufferUsage usage,
|
||||||
uint64_t size) {
|
uint64_t size) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.nextInChain = nullptr;
|
descriptor.nextInChain = nullptr;
|
||||||
|
@ -346,7 +346,7 @@ class CreateBufferMappedTests : public DawnTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CreateBufferMappedResult CreateBufferMappedAsyncWithDataAndWait(
|
dawn::CreateBufferMappedResult CreateBufferMappedAsyncWithDataAndWait(
|
||||||
dawn::BufferUsageBit usage,
|
dawn::BufferUsage usage,
|
||||||
const std::vector<uint32_t>& data) {
|
const std::vector<uint32_t>& data) {
|
||||||
size_t byteLength = data.size() * sizeof(uint32_t);
|
size_t byteLength = data.size() * sizeof(uint32_t);
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMappedAsyncAndWait(usage, byteLength);
|
dawn::CreateBufferMappedResult result = CreateBufferMappedAsyncAndWait(usage, byteLength);
|
||||||
|
@ -363,7 +363,7 @@ class CreateBufferMappedTests : public DawnTest {
|
||||||
TEST_P(CreateBufferMappedTests, MapWriteUsageSmall) {
|
TEST_P(CreateBufferMappedTests, MapWriteUsageSmall) {
|
||||||
uint32_t myData = 230502;
|
uint32_t myData = 230502;
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMappedWithData(
|
dawn::CreateBufferMappedResult result = CreateBufferMappedWithData(
|
||||||
dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc, {myData});
|
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,7 @@ TEST_P(CreateBufferMappedTests, MapWriteUsageSmall) {
|
||||||
TEST_P(CreateBufferMappedTests, MapReadUsageSmall) {
|
TEST_P(CreateBufferMappedTests, MapReadUsageSmall) {
|
||||||
uint32_t myData = 230502;
|
uint32_t myData = 230502;
|
||||||
dawn::CreateBufferMappedResult result =
|
dawn::CreateBufferMappedResult result =
|
||||||
CreateBufferMappedWithData(dawn::BufferUsageBit::MapRead, {myData});
|
CreateBufferMappedWithData(dawn::BufferUsage::MapRead, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
const void* mappedData = MapReadAsyncAndWait(result.buffer);
|
const void* mappedData = MapReadAsyncAndWait(result.buffer);
|
||||||
|
@ -384,7 +384,7 @@ TEST_P(CreateBufferMappedTests, MapReadUsageSmall) {
|
||||||
TEST_P(CreateBufferMappedTests, NonMappableUsageSmall) {
|
TEST_P(CreateBufferMappedTests, NonMappableUsageSmall) {
|
||||||
uint32_t myData = 4239;
|
uint32_t myData = 4239;
|
||||||
dawn::CreateBufferMappedResult result =
|
dawn::CreateBufferMappedResult result =
|
||||||
CreateBufferMappedWithData(dawn::BufferUsageBit::CopySrc, {myData});
|
CreateBufferMappedWithData(dawn::BufferUsage::CopySrc, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
||||||
|
@ -399,7 +399,7 @@ TEST_P(CreateBufferMappedTests, MapWriteUsageLarge) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMappedWithData(
|
dawn::CreateBufferMappedResult result = CreateBufferMappedWithData(
|
||||||
dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc, {myData});
|
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
EXPECT_BUFFER_U32_RANGE_EQ(myData.data(), result.buffer, 0, kDataSize);
|
EXPECT_BUFFER_U32_RANGE_EQ(myData.data(), result.buffer, 0, kDataSize);
|
||||||
|
@ -414,7 +414,7 @@ TEST_P(CreateBufferMappedTests, MapReadUsageLarge) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CreateBufferMappedResult result =
|
dawn::CreateBufferMappedResult result =
|
||||||
CreateBufferMappedWithData(dawn::BufferUsageBit::MapRead, myData);
|
CreateBufferMappedWithData(dawn::BufferUsage::MapRead, myData);
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
const void* mappedData = MapReadAsyncAndWait(result.buffer);
|
const void* mappedData = MapReadAsyncAndWait(result.buffer);
|
||||||
|
@ -431,7 +431,7 @@ TEST_P(CreateBufferMappedTests, NonMappableUsageLarge) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CreateBufferMappedResult result =
|
dawn::CreateBufferMappedResult result =
|
||||||
CreateBufferMappedWithData(dawn::BufferUsageBit::CopySrc, {myData});
|
CreateBufferMappedWithData(dawn::BufferUsage::CopySrc, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
EXPECT_BUFFER_U32_RANGE_EQ(myData.data(), result.buffer, 0, kDataSize);
|
EXPECT_BUFFER_U32_RANGE_EQ(myData.data(), result.buffer, 0, kDataSize);
|
||||||
|
@ -442,7 +442,7 @@ TEST_P(CreateBufferMappedTests, CreateThenMapSuccess) {
|
||||||
static uint32_t myData = 230502;
|
static uint32_t myData = 230502;
|
||||||
static uint32_t myData2 = 1337;
|
static uint32_t myData2 = 1337;
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMappedWithData(
|
dawn::CreateBufferMappedResult result = CreateBufferMappedWithData(
|
||||||
dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc, {myData});
|
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
||||||
|
@ -470,7 +470,7 @@ TEST_P(CreateBufferMappedTests, CreateThenMapSuccess) {
|
||||||
TEST_P(CreateBufferMappedTests, CreateThenMapBeforeUnmapFailure) {
|
TEST_P(CreateBufferMappedTests, CreateThenMapBeforeUnmapFailure) {
|
||||||
uint32_t myData = 230502;
|
uint32_t myData = 230502;
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMappedWithData(
|
dawn::CreateBufferMappedResult result = CreateBufferMappedWithData(
|
||||||
dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc, {myData});
|
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc, {myData});
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR([&]() {
|
ASSERT_DEVICE_ERROR([&]() {
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
@ -497,7 +497,7 @@ TEST_P(CreateBufferMappedTests, CreateThenMapBeforeUnmapFailure) {
|
||||||
TEST_P(CreateBufferMappedTests, MapWriteUsageSmallAsync) {
|
TEST_P(CreateBufferMappedTests, MapWriteUsageSmallAsync) {
|
||||||
uint32_t myData = 230502;
|
uint32_t myData = 230502;
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMappedAsyncWithDataAndWait(
|
dawn::CreateBufferMappedResult result = CreateBufferMappedAsyncWithDataAndWait(
|
||||||
dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc, {myData});
|
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ TEST_P(CreateBufferMappedTests, MapWriteUsageSmallAsync) {
|
||||||
TEST_P(CreateBufferMappedTests, MapReadUsageSmallAsync) {
|
TEST_P(CreateBufferMappedTests, MapReadUsageSmallAsync) {
|
||||||
uint32_t myData = 230502;
|
uint32_t myData = 230502;
|
||||||
dawn::CreateBufferMappedResult result =
|
dawn::CreateBufferMappedResult result =
|
||||||
CreateBufferMappedAsyncWithDataAndWait(dawn::BufferUsageBit::MapRead, {myData});
|
CreateBufferMappedAsyncWithDataAndWait(dawn::BufferUsage::MapRead, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
const void* mappedData = MapReadAsyncAndWait(result.buffer);
|
const void* mappedData = MapReadAsyncAndWait(result.buffer);
|
||||||
|
@ -518,7 +518,7 @@ TEST_P(CreateBufferMappedTests, MapReadUsageSmallAsync) {
|
||||||
TEST_P(CreateBufferMappedTests, NonMappableUsageSmallAsync) {
|
TEST_P(CreateBufferMappedTests, NonMappableUsageSmallAsync) {
|
||||||
uint32_t myData = 4239;
|
uint32_t myData = 4239;
|
||||||
dawn::CreateBufferMappedResult result =
|
dawn::CreateBufferMappedResult result =
|
||||||
CreateBufferMappedAsyncWithDataAndWait(dawn::BufferUsageBit::CopySrc, {myData});
|
CreateBufferMappedAsyncWithDataAndWait(dawn::BufferUsage::CopySrc, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
||||||
|
@ -533,7 +533,7 @@ TEST_P(CreateBufferMappedTests, MapWriteUsageLargeAsync) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMappedAsyncWithDataAndWait(
|
dawn::CreateBufferMappedResult result = CreateBufferMappedAsyncWithDataAndWait(
|
||||||
dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc, {myData});
|
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
EXPECT_BUFFER_U32_RANGE_EQ(myData.data(), result.buffer, 0, kDataSize);
|
EXPECT_BUFFER_U32_RANGE_EQ(myData.data(), result.buffer, 0, kDataSize);
|
||||||
|
@ -548,7 +548,7 @@ TEST_P(CreateBufferMappedTests, MapReadUsageLargeAsync) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CreateBufferMappedResult result =
|
dawn::CreateBufferMappedResult result =
|
||||||
CreateBufferMappedAsyncWithDataAndWait(dawn::BufferUsageBit::MapRead, {myData});
|
CreateBufferMappedAsyncWithDataAndWait(dawn::BufferUsage::MapRead, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
const void* mappedData = MapReadAsyncAndWait(result.buffer);
|
const void* mappedData = MapReadAsyncAndWait(result.buffer);
|
||||||
|
@ -565,7 +565,7 @@ TEST_P(CreateBufferMappedTests, NonMappableUsageLargeAsync) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CreateBufferMappedResult result =
|
dawn::CreateBufferMappedResult result =
|
||||||
CreateBufferMappedAsyncWithDataAndWait(dawn::BufferUsageBit::CopySrc, {myData});
|
CreateBufferMappedAsyncWithDataAndWait(dawn::BufferUsage::CopySrc, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
EXPECT_BUFFER_U32_RANGE_EQ(myData.data(), result.buffer, 0, kDataSize);
|
EXPECT_BUFFER_U32_RANGE_EQ(myData.data(), result.buffer, 0, kDataSize);
|
||||||
|
@ -576,7 +576,7 @@ TEST_P(CreateBufferMappedTests, CreateThenMapSuccessAsync) {
|
||||||
static uint32_t myData = 230502;
|
static uint32_t myData = 230502;
|
||||||
static uint32_t myData2 = 1337;
|
static uint32_t myData2 = 1337;
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMappedAsyncWithDataAndWait(
|
dawn::CreateBufferMappedResult result = CreateBufferMappedAsyncWithDataAndWait(
|
||||||
dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc, {myData});
|
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc, {myData});
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
|
||||||
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
EXPECT_BUFFER_U32_EQ(myData, result.buffer, 0);
|
||||||
|
@ -604,7 +604,7 @@ TEST_P(CreateBufferMappedTests, CreateThenMapSuccessAsync) {
|
||||||
TEST_P(CreateBufferMappedTests, CreateThenMapBeforeUnmapFailureAsync) {
|
TEST_P(CreateBufferMappedTests, CreateThenMapBeforeUnmapFailureAsync) {
|
||||||
uint32_t myData = 230502;
|
uint32_t myData = 230502;
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMappedAsyncWithDataAndWait(
|
dawn::CreateBufferMappedResult result = CreateBufferMappedAsyncWithDataAndWait(
|
||||||
dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc, {myData});
|
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc, {myData});
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR([&]() {
|
ASSERT_DEVICE_ERROR([&]() {
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
|
|
@ -59,7 +59,7 @@ class ClipSpaceTest : public DawnTest {
|
||||||
textureDescriptor.dimension = dawn::TextureDimension::e2D;
|
textureDescriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
textureDescriptor.format = format;
|
textureDescriptor.format = format;
|
||||||
textureDescriptor.usage =
|
textureDescriptor.usage =
|
||||||
dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
textureDescriptor.arrayLayerCount = 1;
|
textureDescriptor.arrayLayerCount = 1;
|
||||||
textureDescriptor.mipLevelCount = 1;
|
textureDescriptor.mipLevelCount = 1;
|
||||||
textureDescriptor.sampleCount = 1;
|
textureDescriptor.sampleCount = 1;
|
||||||
|
|
|
@ -101,7 +101,7 @@ class ColorStateTest : public DawnTest {
|
||||||
uint32_t bufferSize = static_cast<uint32_t>(4 * N * sizeof(float));
|
uint32_t bufferSize = static_cast<uint32_t>(4 * N * sizeof(float));
|
||||||
|
|
||||||
dawn::Buffer buffer =
|
dawn::Buffer buffer =
|
||||||
utils::CreateBufferFromData(device, &data, bufferSize, dawn::BufferUsageBit::Uniform);
|
utils::CreateBufferFromData(device, &data, bufferSize, dawn::BufferUsage::Uniform);
|
||||||
return utils::MakeBindGroup(device, bindGroupLayout, {{0, buffer, 0, bufferSize}});
|
return utils::MakeBindGroup(device, bindGroupLayout, {{0, buffer, 0, bufferSize}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,7 +762,7 @@ TEST_P(ColorStateTest, IndependentColorState) {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
descriptor.usage = dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < 4; ++i) {
|
for (uint32_t i = 0; i < 4; ++i) {
|
||||||
renderTargets[i] = device.CreateTexture(&descriptor);
|
renderTargets[i] = device.CreateTexture(&descriptor);
|
||||||
|
|
|
@ -93,7 +93,7 @@ class CompressedTextureBCFormatTest : public DawnTest {
|
||||||
|
|
||||||
// Copy texture data from a staging buffer to the destination texture.
|
// Copy texture data from a staging buffer to the destination texture.
|
||||||
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
||||||
device, uploadData.data(), uploadBufferSize, dawn::BufferUsageBit::CopySrc);
|
device, uploadData.data(), uploadBufferSize, dawn::BufferUsage::CopySrc);
|
||||||
dawn::BufferCopyView bufferCopyView =
|
dawn::BufferCopyView bufferCopyView =
|
||||||
utils::CreateBufferCopyView(stagingBuffer, copyConfig.bufferOffset,
|
utils::CreateBufferCopyView(stagingBuffer, copyConfig.bufferOffset,
|
||||||
copyConfig.rowPitchAlignment, copyConfig.imageHeight);
|
copyConfig.rowPitchAlignment, copyConfig.imageHeight);
|
||||||
|
@ -449,8 +449,8 @@ class CompressedTextureBCFormatTest : public DawnTest {
|
||||||
static constexpr uint32_t kBCBlockWidthInTexels = 4;
|
static constexpr uint32_t kBCBlockWidthInTexels = 4;
|
||||||
static constexpr uint32_t kBCBlockHeightInTexels = 4;
|
static constexpr uint32_t kBCBlockHeightInTexels = 4;
|
||||||
|
|
||||||
static constexpr dawn::TextureUsageBit kDefaultBCFormatTextureUsage =
|
static constexpr dawn::TextureUsage kDefaultBCFormatTextureUsage =
|
||||||
dawn::TextureUsageBit::Sampled | dawn::TextureUsageBit::CopyDst;
|
dawn::TextureUsage::Sampled | dawn::TextureUsage::CopyDst;
|
||||||
|
|
||||||
dawn::BindGroupLayout mBindGroupLayout;
|
dawn::BindGroupLayout mBindGroupLayout;
|
||||||
|
|
||||||
|
@ -633,9 +633,8 @@ TEST_P(CompressedTextureBCFormatTest, CopyWholeTextureSubResourceIntoNonZeroMipm
|
||||||
config.textureDescriptor.format = format;
|
config.textureDescriptor.format = format;
|
||||||
// Add the usage bit for both source and destination textures so that we don't need to
|
// Add the usage bit for both source and destination textures so that we don't need to
|
||||||
// create two copy configs.
|
// create two copy configs.
|
||||||
config.textureDescriptor.usage = dawn::TextureUsageBit::CopySrc |
|
config.textureDescriptor.usage =
|
||||||
dawn::TextureUsageBit::CopyDst |
|
dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst | dawn::TextureUsage::Sampled;
|
||||||
dawn::TextureUsageBit::Sampled;
|
|
||||||
|
|
||||||
dawn::Texture bcTextureSrc = CreateTextureWithCompressedData(config);
|
dawn::Texture bcTextureSrc = CreateTextureWithCompressedData(config);
|
||||||
|
|
||||||
|
@ -695,7 +694,7 @@ TEST_P(CompressedTextureBCFormatTest, CopyIntoSubresourceWithPhysicalSizeNotEqua
|
||||||
// compressed data.
|
// compressed data.
|
||||||
srcConfig.textureDescriptor.format = format;
|
srcConfig.textureDescriptor.format = format;
|
||||||
srcConfig.textureDescriptor.usage =
|
srcConfig.textureDescriptor.usage =
|
||||||
dawn::TextureUsageBit::CopySrc | dawn::TextureUsageBit::CopyDst;
|
dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst;
|
||||||
dawn::Texture bcTextureSrc = CreateTextureWithCompressedData(srcConfig);
|
dawn::Texture bcTextureSrc = CreateTextureWithCompressedData(srcConfig);
|
||||||
dawn::TextureCopyView textureCopyViewSrc =
|
dawn::TextureCopyView textureCopyViewSrc =
|
||||||
utils::CreateTextureCopyView(bcTextureSrc, srcConfig.viewMipmapLevel,
|
utils::CreateTextureCopyView(bcTextureSrc, srcConfig.viewMipmapLevel,
|
||||||
|
@ -755,7 +754,7 @@ TEST_P(CompressedTextureBCFormatTest, CopyFromSubresourceWithPhysicalSizeNotEqua
|
||||||
for (dawn::TextureFormat format : kBCFormats) {
|
for (dawn::TextureFormat format : kBCFormats) {
|
||||||
srcConfig.textureDescriptor.format = dstConfig.textureDescriptor.format = format;
|
srcConfig.textureDescriptor.format = dstConfig.textureDescriptor.format = format;
|
||||||
srcConfig.textureDescriptor.usage =
|
srcConfig.textureDescriptor.usage =
|
||||||
dawn::TextureUsageBit::CopySrc | dawn::TextureUsageBit::CopyDst;
|
dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst;
|
||||||
dstConfig.textureDescriptor.usage = kDefaultBCFormatTextureUsage;
|
dstConfig.textureDescriptor.usage = kDefaultBCFormatTextureUsage;
|
||||||
|
|
||||||
// Create bcTextureSrc as the source texture and initialize it with pre-prepared BC
|
// Create bcTextureSrc as the source texture and initialize it with pre-prepared BC
|
||||||
|
@ -828,7 +827,7 @@ TEST_P(CompressedTextureBCFormatTest, MultipleCopiesWithPhysicalSizeNotEqualToVi
|
||||||
srcConfigs[i].textureDescriptor.format = dstConfigs[i].textureDescriptor.format =
|
srcConfigs[i].textureDescriptor.format = dstConfigs[i].textureDescriptor.format =
|
||||||
format;
|
format;
|
||||||
srcConfigs[i].textureDescriptor.usage =
|
srcConfigs[i].textureDescriptor.usage =
|
||||||
dawn::TextureUsageBit::CopySrc | dawn::TextureUsageBit::CopyDst;
|
dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst;
|
||||||
dstConfigs[i].textureDescriptor.usage = kDefaultBCFormatTextureUsage;
|
dstConfigs[i].textureDescriptor.usage = kDefaultBCFormatTextureUsage;
|
||||||
|
|
||||||
// Create bcSrcTextures as the source textures and initialize them with pre-prepared BC
|
// Create bcSrcTextures as the source textures and initialize them with pre-prepared BC
|
||||||
|
|
|
@ -51,8 +51,8 @@ void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
|
||||||
// Set up src storage buffer
|
// Set up src storage buffer
|
||||||
dawn::BufferDescriptor srcDesc;
|
dawn::BufferDescriptor srcDesc;
|
||||||
srcDesc.size = kNumUints * sizeof(uint32_t);
|
srcDesc.size = kNumUints * sizeof(uint32_t);
|
||||||
srcDesc.usage = dawn::BufferUsageBit::Storage | dawn::BufferUsageBit::CopySrc |
|
srcDesc.usage =
|
||||||
dawn::BufferUsageBit::CopyDst;
|
dawn::BufferUsage::Storage | dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer src = device.CreateBuffer(&srcDesc);
|
dawn::Buffer src = device.CreateBuffer(&srcDesc);
|
||||||
|
|
||||||
std::array<uint32_t, kNumUints> expected;
|
std::array<uint32_t, kNumUints> expected;
|
||||||
|
@ -65,8 +65,8 @@ void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
|
||||||
// Set up dst storage buffer
|
// Set up dst storage buffer
|
||||||
dawn::BufferDescriptor dstDesc;
|
dawn::BufferDescriptor dstDesc;
|
||||||
dstDesc.size = kNumUints * sizeof(uint32_t);
|
dstDesc.size = kNumUints * sizeof(uint32_t);
|
||||||
dstDesc.usage = dawn::BufferUsageBit::Storage | dawn::BufferUsageBit::CopySrc |
|
dstDesc.usage =
|
||||||
dawn::BufferUsageBit::CopyDst;
|
dawn::BufferUsage::Storage | dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer dst = device.CreateBuffer(&dstDesc);
|
dawn::Buffer dst = device.CreateBuffer(&dstDesc);
|
||||||
|
|
||||||
std::array<uint32_t, kNumUints> zero{};
|
std::array<uint32_t, kNumUints> zero{};
|
||||||
|
|
|
@ -67,20 +67,19 @@ void ComputeIndirectTests::BasicTest(std::initializer_list<uint32_t> bufferList,
|
||||||
dawn::ComputePipeline pipeline = device.CreateComputePipeline(&csDesc);
|
dawn::ComputePipeline pipeline = device.CreateComputePipeline(&csDesc);
|
||||||
|
|
||||||
// Set up dst storage buffer to contain dispatch x, y, z
|
// Set up dst storage buffer to contain dispatch x, y, z
|
||||||
dawn::Buffer dst = utils::CreateBufferFromData<uint32_t>(device,
|
dawn::Buffer dst = utils::CreateBufferFromData<uint32_t>(
|
||||||
dawn::BufferUsageBit::Storage |
|
device,
|
||||||
dawn::BufferUsageBit::CopySrc |
|
dawn::BufferUsage::Storage | dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst,
|
||||||
dawn::BufferUsageBit::CopyDst,
|
|
||||||
{0, 0, 0});
|
{0, 0, 0});
|
||||||
|
|
||||||
std::vector<uint32_t> indirectBufferData = bufferList;
|
std::vector<uint32_t> indirectBufferData = bufferList;
|
||||||
|
|
||||||
dawn::Buffer indirectBuffer =
|
dawn::Buffer indirectBuffer =
|
||||||
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsageBit::Indirect, bufferList);
|
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Indirect, bufferList);
|
||||||
|
|
||||||
dawn::Buffer expectedBuffer =
|
dawn::Buffer expectedBuffer =
|
||||||
utils::CreateBufferFromData(device, &indirectBufferData[indirectOffset / sizeof(uint32_t)],
|
utils::CreateBufferFromData(device, &indirectBufferData[indirectOffset / sizeof(uint32_t)],
|
||||||
3 * sizeof(uint32_t), dawn::BufferUsageBit::Uniform);
|
3 * sizeof(uint32_t), dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
// Set up bind group and issue dispatch
|
// Set up bind group and issue dispatch
|
||||||
dawn::BindGroup bindGroup =
|
dawn::BindGroup bindGroup =
|
||||||
|
|
|
@ -48,8 +48,8 @@ void ComputeSharedMemoryTests::BasicTest(const char* shader) {
|
||||||
// Set up dst storage buffer
|
// Set up dst storage buffer
|
||||||
dawn::BufferDescriptor dstDesc;
|
dawn::BufferDescriptor dstDesc;
|
||||||
dstDesc.size = sizeof(uint32_t);
|
dstDesc.size = sizeof(uint32_t);
|
||||||
dstDesc.usage = dawn::BufferUsageBit::Storage | dawn::BufferUsageBit::CopySrc |
|
dstDesc.usage =
|
||||||
dawn::BufferUsageBit::CopyDst;
|
dawn::BufferUsage::Storage | dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer dst = device.CreateBuffer(&dstDesc);
|
dawn::Buffer dst = device.CreateBuffer(&dstDesc);
|
||||||
|
|
||||||
const uint32_t zero = 0;
|
const uint32_t zero = 0;
|
||||||
|
|
|
@ -85,7 +85,7 @@ class CopyTests_T2B : public CopyTests {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = textureSpec.level + 1;
|
descriptor.mipLevelCount = textureSpec.level + 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::CopySrc;
|
descriptor.usage = dawn::TextureUsage::CopyDst | dawn::TextureUsage::CopySrc;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
uint32_t width = textureSpec.width >> textureSpec.level;
|
uint32_t width = textureSpec.width >> textureSpec.level;
|
||||||
|
@ -106,7 +106,7 @@ class CopyTests_T2B : public CopyTests {
|
||||||
dawn::Buffer uploadBuffer = utils::CreateBufferFromData(
|
dawn::Buffer uploadBuffer = utils::CreateBufferFromData(
|
||||||
device, textureArrayData[slice].data(),
|
device, textureArrayData[slice].data(),
|
||||||
static_cast<uint32_t>(sizeof(RGBA8) * textureArrayData[slice].size()),
|
static_cast<uint32_t>(sizeof(RGBA8) * textureArrayData[slice].size()),
|
||||||
dawn::BufferUsageBit::CopySrc);
|
dawn::BufferUsage::CopySrc);
|
||||||
dawn::BufferCopyView bufferCopyView =
|
dawn::BufferCopyView bufferCopyView =
|
||||||
utils::CreateBufferCopyView(uploadBuffer, 0, rowPitch, 0);
|
utils::CreateBufferCopyView(uploadBuffer, 0, rowPitch, 0);
|
||||||
dawn::TextureCopyView textureCopyView =
|
dawn::TextureCopyView textureCopyView =
|
||||||
|
@ -120,7 +120,7 @@ class CopyTests_T2B : public CopyTests {
|
||||||
// and helps ensure that the padding due to the row pitch is not modified by the copy
|
// and helps ensure that the padding due to the row pitch is not modified by the copy
|
||||||
dawn::BufferDescriptor bufDescriptor;
|
dawn::BufferDescriptor bufDescriptor;
|
||||||
bufDescriptor.size = bufferSpec.size * textureSpec.arraySize;
|
bufDescriptor.size = bufferSpec.size * textureSpec.arraySize;
|
||||||
bufDescriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
bufDescriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&bufDescriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&bufDescriptor);
|
||||||
std::vector<RGBA8> emptyData(bufferSpec.size / kBytesPerTexel * textureSpec.arraySize);
|
std::vector<RGBA8> emptyData(bufferSpec.size / kBytesPerTexel * textureSpec.arraySize);
|
||||||
buffer.SetSubData(0, static_cast<uint32_t>(emptyData.size() * sizeof(RGBA8)),
|
buffer.SetSubData(0, static_cast<uint32_t>(emptyData.size() * sizeof(RGBA8)),
|
||||||
|
@ -182,7 +182,7 @@ protected:
|
||||||
// Create a buffer of size `size` and populate it with data
|
// Create a buffer of size `size` and populate it with data
|
||||||
dawn::BufferDescriptor bufDescriptor;
|
dawn::BufferDescriptor bufDescriptor;
|
||||||
bufDescriptor.size = bufferSpec.size;
|
bufDescriptor.size = bufferSpec.size;
|
||||||
bufDescriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
bufDescriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&bufDescriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&bufDescriptor);
|
||||||
|
|
||||||
std::vector<RGBA8> bufferData(bufferSpec.size / kBytesPerTexel);
|
std::vector<RGBA8> bufferData(bufferSpec.size / kBytesPerTexel);
|
||||||
|
@ -200,7 +200,7 @@ protected:
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = textureSpec.level + 1;
|
descriptor.mipLevelCount = textureSpec.level + 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::CopySrc;
|
descriptor.usage = dawn::TextureUsage::CopyDst | dawn::TextureUsage::CopySrc;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
@ -218,7 +218,7 @@ protected:
|
||||||
std::vector<RGBA8> emptyData(texelCount);
|
std::vector<RGBA8> emptyData(texelCount);
|
||||||
dawn::Buffer uploadBuffer = utils::CreateBufferFromData(
|
dawn::Buffer uploadBuffer = utils::CreateBufferFromData(
|
||||||
device, emptyData.data(), static_cast<uint32_t>(sizeof(RGBA8) * emptyData.size()),
|
device, emptyData.data(), static_cast<uint32_t>(sizeof(RGBA8) * emptyData.size()),
|
||||||
dawn::BufferUsageBit::CopySrc);
|
dawn::BufferUsage::CopySrc);
|
||||||
dawn::BufferCopyView bufferCopyView =
|
dawn::BufferCopyView bufferCopyView =
|
||||||
utils::CreateBufferCopyView(uploadBuffer, 0, rowPitch, 0);
|
utils::CreateBufferCopyView(uploadBuffer, 0, rowPitch, 0);
|
||||||
dawn::TextureCopyView textureCopyView =
|
dawn::TextureCopyView textureCopyView =
|
||||||
|
@ -281,7 +281,7 @@ class CopyTests_T2T : public CopyTests {
|
||||||
srcDescriptor.sampleCount = 1;
|
srcDescriptor.sampleCount = 1;
|
||||||
srcDescriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
srcDescriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
srcDescriptor.mipLevelCount = srcSpec.level + 1;
|
srcDescriptor.mipLevelCount = srcSpec.level + 1;
|
||||||
srcDescriptor.usage = dawn::TextureUsageBit::CopySrc | dawn::TextureUsageBit::CopyDst;
|
srcDescriptor.usage = dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst;
|
||||||
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
||||||
|
|
||||||
dawn::TextureDescriptor dstDescriptor;
|
dawn::TextureDescriptor dstDescriptor;
|
||||||
|
@ -293,7 +293,7 @@ class CopyTests_T2T : public CopyTests {
|
||||||
dstDescriptor.sampleCount = 1;
|
dstDescriptor.sampleCount = 1;
|
||||||
dstDescriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
dstDescriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
dstDescriptor.mipLevelCount = dstSpec.level + 1;
|
dstDescriptor.mipLevelCount = dstSpec.level + 1;
|
||||||
dstDescriptor.usage = dawn::TextureUsageBit::CopySrc | dawn::TextureUsageBit::CopyDst;
|
dstDescriptor.usage = dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst;
|
||||||
dawn::Texture dstTexture = device.CreateTexture(&dstDescriptor);
|
dawn::Texture dstTexture = device.CreateTexture(&dstDescriptor);
|
||||||
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
@ -315,7 +315,7 @@ class CopyTests_T2T : public CopyTests {
|
||||||
dawn::Buffer uploadBuffer = utils::CreateBufferFromData(
|
dawn::Buffer uploadBuffer = utils::CreateBufferFromData(
|
||||||
device, textureArrayData[slice].data(),
|
device, textureArrayData[slice].data(),
|
||||||
static_cast<uint32_t>(sizeof(RGBA8) * textureArrayData[slice].size()),
|
static_cast<uint32_t>(sizeof(RGBA8) * textureArrayData[slice].size()),
|
||||||
dawn::BufferUsageBit::CopySrc);
|
dawn::BufferUsage::CopySrc);
|
||||||
dawn::BufferCopyView bufferCopyView =
|
dawn::BufferCopyView bufferCopyView =
|
||||||
utils::CreateBufferCopyView(uploadBuffer, 0, rowPitch, 0);
|
utils::CreateBufferCopyView(uploadBuffer, 0, rowPitch, 0);
|
||||||
dawn::TextureCopyView textureCopyView =
|
dawn::TextureCopyView textureCopyView =
|
||||||
|
@ -339,7 +339,7 @@ class CopyTests_T2T : public CopyTests {
|
||||||
std::vector<RGBA8> emptyData(dstTexelCount);
|
std::vector<RGBA8> emptyData(dstTexelCount);
|
||||||
dawn::Buffer uploadBuffer = utils::CreateBufferFromData(
|
dawn::Buffer uploadBuffer = utils::CreateBufferFromData(
|
||||||
device, emptyData.data(), static_cast<uint32_t>(sizeof(RGBA8) * emptyData.size()),
|
device, emptyData.data(), static_cast<uint32_t>(sizeof(RGBA8) * emptyData.size()),
|
||||||
dawn::BufferUsageBit::CopySrc);
|
dawn::BufferUsage::CopySrc);
|
||||||
dawn::BufferCopyView bufferCopyView =
|
dawn::BufferCopyView bufferCopyView =
|
||||||
utils::CreateBufferCopyView(uploadBuffer, 0, dstRowPitch, 0);
|
utils::CreateBufferCopyView(uploadBuffer, 0, dstRowPitch, 0);
|
||||||
dawn::TextureCopyView textureCopyView =
|
dawn::TextureCopyView textureCopyView =
|
||||||
|
|
|
@ -63,7 +63,7 @@ class CullingTest : public DawnTest {
|
||||||
textureDescriptor.dimension = dawn::TextureDimension::e2D;
|
textureDescriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
textureDescriptor.format = format;
|
textureDescriptor.format = format;
|
||||||
textureDescriptor.usage =
|
textureDescriptor.usage =
|
||||||
dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
textureDescriptor.arrayLayerCount = 1;
|
textureDescriptor.arrayLayerCount = 1;
|
||||||
textureDescriptor.mipLevelCount = 1;
|
textureDescriptor.mipLevelCount = 1;
|
||||||
textureDescriptor.sampleCount = 1;
|
textureDescriptor.sampleCount = 1;
|
||||||
|
|
|
@ -35,7 +35,7 @@ class DepthStencilStateTest : public DawnTest {
|
||||||
renderTargetDescriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
renderTargetDescriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
renderTargetDescriptor.mipLevelCount = 1;
|
renderTargetDescriptor.mipLevelCount = 1;
|
||||||
renderTargetDescriptor.usage =
|
renderTargetDescriptor.usage =
|
||||||
dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
renderTarget = device.CreateTexture(&renderTargetDescriptor);
|
renderTarget = device.CreateTexture(&renderTargetDescriptor);
|
||||||
|
|
||||||
renderTargetView = renderTarget.CreateDefaultView();
|
renderTargetView = renderTarget.CreateDefaultView();
|
||||||
|
@ -49,7 +49,7 @@ class DepthStencilStateTest : public DawnTest {
|
||||||
depthDescriptor.sampleCount = 1;
|
depthDescriptor.sampleCount = 1;
|
||||||
depthDescriptor.format = dawn::TextureFormat::Depth24PlusStencil8;
|
depthDescriptor.format = dawn::TextureFormat::Depth24PlusStencil8;
|
||||||
depthDescriptor.mipLevelCount = 1;
|
depthDescriptor.mipLevelCount = 1;
|
||||||
depthDescriptor.usage = dawn::TextureUsageBit::OutputAttachment;
|
depthDescriptor.usage = dawn::TextureUsage::OutputAttachment;
|
||||||
depthTexture = device.CreateTexture(&depthDescriptor);
|
depthTexture = device.CreateTexture(&depthDescriptor);
|
||||||
|
|
||||||
depthTextureView = depthTexture.CreateDefaultView();
|
depthTextureView = depthTexture.CreateDefaultView();
|
||||||
|
@ -265,7 +265,8 @@ class DepthStencilStateTest : public DawnTest {
|
||||||
test.depth,
|
test.depth,
|
||||||
};
|
};
|
||||||
// Upload a buffer for each triangle's depth and color data
|
// Upload a buffer for each triangle's depth and color data
|
||||||
dawn::Buffer buffer = utils::CreateBufferFromData(device, &data, sizeof(TriangleData), dawn::BufferUsageBit::Uniform);
|
dawn::Buffer buffer = utils::CreateBufferFromData(
|
||||||
|
device, &data, sizeof(TriangleData), dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
// Create a bind group for the data
|
// Create a bind group for the data
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bindGroupLayout, {{0, buffer, 0, sizeof(TriangleData)}});
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(device, bindGroupLayout, {{0, buffer, 0, sizeof(TriangleData)}});
|
||||||
|
|
|
@ -55,7 +55,7 @@ class DestroyTest : public DawnTest {
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||||
|
|
||||||
vertexBuffer = utils::CreateBufferFromData<float>(
|
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
device, dawn::BufferUsageBit::Vertex,
|
device, dawn::BufferUsage::Vertex,
|
||||||
{// The bottom left triangle
|
{// The bottom left triangle
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
|
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f});
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ class DrawIndexedIndirectTest : public DawnTest {
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||||
|
|
||||||
vertexBuffer = utils::CreateBufferFromData<float>(
|
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
device, dawn::BufferUsageBit::Vertex,
|
device, dawn::BufferUsage::Vertex,
|
||||||
{// First quad: the first 3 vertices represent the bottom left triangle
|
{// First quad: the first 3 vertices represent the bottom left triangle
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f,
|
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f,
|
||||||
0.0f, 1.0f,
|
0.0f, 1.0f,
|
||||||
|
@ -64,7 +64,7 @@ class DrawIndexedIndirectTest : public DawnTest {
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f,
|
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f,
|
||||||
0.0f, 1.0f});
|
0.0f, 1.0f});
|
||||||
indexBuffer = utils::CreateBufferFromData<uint32_t>(
|
indexBuffer = utils::CreateBufferFromData<uint32_t>(
|
||||||
device, dawn::BufferUsageBit::Index,
|
device, dawn::BufferUsage::Index,
|
||||||
{0, 1, 2, 0, 3, 1,
|
{0, 1, 2, 0, 3, 1,
|
||||||
// The indices below are added to test negatve baseVertex
|
// The indices below are added to test negatve baseVertex
|
||||||
0 + 4, 1 + 4, 2 + 4, 0 + 4, 3 + 4, 1 + 4});
|
0 + 4, 1 + 4, 2 + 4, 0 + 4, 3 + 4, 1 + 4});
|
||||||
|
@ -80,8 +80,8 @@ class DrawIndexedIndirectTest : public DawnTest {
|
||||||
uint64_t indirectOffset,
|
uint64_t indirectOffset,
|
||||||
RGBA8 bottomLeftExpected,
|
RGBA8 bottomLeftExpected,
|
||||||
RGBA8 topRightExpected) {
|
RGBA8 topRightExpected) {
|
||||||
dawn::Buffer indirectBuffer = utils::CreateBufferFromData<uint32_t>(
|
dawn::Buffer indirectBuffer =
|
||||||
device, dawn::BufferUsageBit::Indirect, bufferList);
|
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Indirect, bufferList);
|
||||||
|
|
||||||
uint64_t zeroOffset = 0;
|
uint64_t zeroOffset = 0;
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
|
|
@ -54,21 +54,17 @@ class DrawIndexedTest : public DawnTest {
|
||||||
|
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||||
|
|
||||||
vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
|
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
// First quad: the first 3 vertices represent the bottom left triangle
|
device, dawn::BufferUsage::Vertex,
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f,
|
{// First quad: the first 3 vertices represent the bottom left triangle
|
||||||
1.0f, 1.0f, 0.0f, 1.0f,
|
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f,
|
-1.0f, 0.0f, 1.0f,
|
||||||
1.0f, -1.0f, 0.0f, 1.0f,
|
|
||||||
|
|
||||||
// Second quad: the first 3 vertices represent the top right triangle
|
// Second quad: the first 3 vertices represent the top right triangle
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f,
|
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f,
|
||||||
1.0f, 1.0f, 0.0f, 1.0f,
|
1.0f, 0.0f, 1.0f});
|
||||||
1.0f, -1.0f, 0.0f, 1.0f,
|
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f
|
|
||||||
});
|
|
||||||
indexBuffer = utils::CreateBufferFromData<uint32_t>(
|
indexBuffer = utils::CreateBufferFromData<uint32_t>(
|
||||||
device, dawn::BufferUsageBit::Index,
|
device, dawn::BufferUsage::Index,
|
||||||
{0, 1, 2, 0, 3, 1,
|
{0, 1, 2, 0, 3, 1,
|
||||||
// The indices below are added to test negatve baseVertex
|
// The indices below are added to test negatve baseVertex
|
||||||
0 + 4, 1 + 4, 2 + 4, 0 + 4, 3 + 4, 1 + 4});
|
0 + 4, 1 + 4, 2 + 4, 0 + 4, 3 + 4, 1 + 4});
|
||||||
|
|
|
@ -55,7 +55,7 @@ class DrawIndirectTest : public DawnTest {
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||||
|
|
||||||
vertexBuffer = utils::CreateBufferFromData<float>(
|
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
device, dawn::BufferUsageBit::Vertex,
|
device, dawn::BufferUsage::Vertex,
|
||||||
{// The bottom left triangle
|
{// The bottom left triangle
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
|
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
|
||||||
|
|
||||||
|
@ -71,8 +71,8 @@ class DrawIndirectTest : public DawnTest {
|
||||||
uint64_t indirectOffset,
|
uint64_t indirectOffset,
|
||||||
RGBA8 bottomLeftExpected,
|
RGBA8 bottomLeftExpected,
|
||||||
RGBA8 topRightExpected) {
|
RGBA8 topRightExpected) {
|
||||||
dawn::Buffer indirectBuffer = utils::CreateBufferFromData<uint32_t>(
|
dawn::Buffer indirectBuffer =
|
||||||
device, dawn::BufferUsageBit::Indirect, bufferList);
|
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Indirect, bufferList);
|
||||||
|
|
||||||
uint64_t zeroOffset = 0;
|
uint64_t zeroOffset = 0;
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
|
|
@ -55,7 +55,7 @@ class DrawTest : public DawnTest {
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||||
|
|
||||||
vertexBuffer = utils::CreateBufferFromData<float>(
|
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
device, dawn::BufferUsageBit::Vertex,
|
device, dawn::BufferUsage::Vertex,
|
||||||
{// The bottom left triangle
|
{// The bottom left triangle
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
|
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
|
||||||
|
|
||||||
|
|
|
@ -34,20 +34,19 @@ class DynamicBufferOffsetTests : public DawnTest {
|
||||||
uniformData[1] = 2;
|
uniformData[1] = 2;
|
||||||
|
|
||||||
mUniformBuffers[0] = utils::CreateBufferFromData(device, uniformData.data(), kBufferSize,
|
mUniformBuffers[0] = utils::CreateBufferFromData(device, uniformData.data(), kBufferSize,
|
||||||
dawn::BufferUsageBit::Uniform);
|
dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
uniformData[uniformData.size() - 2] = 5;
|
uniformData[uniformData.size() - 2] = 5;
|
||||||
uniformData[uniformData.size() - 1] = 6;
|
uniformData[uniformData.size() - 1] = 6;
|
||||||
|
|
||||||
// Dynamic uniform buffer
|
// Dynamic uniform buffer
|
||||||
mUniformBuffers[1] = utils::CreateBufferFromData(device, uniformData.data(), kBufferSize,
|
mUniformBuffers[1] = utils::CreateBufferFromData(device, uniformData.data(), kBufferSize,
|
||||||
dawn::BufferUsageBit::Uniform);
|
dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
dawn::BufferDescriptor storageBufferDescriptor;
|
dawn::BufferDescriptor storageBufferDescriptor;
|
||||||
storageBufferDescriptor.size = kBufferSize;
|
storageBufferDescriptor.size = kBufferSize;
|
||||||
storageBufferDescriptor.usage = dawn::BufferUsageBit::Storage |
|
storageBufferDescriptor.usage =
|
||||||
dawn::BufferUsageBit::CopyDst |
|
dawn::BufferUsage::Storage | dawn::BufferUsage::CopyDst | dawn::BufferUsage::CopySrc;
|
||||||
dawn::BufferUsageBit::CopySrc;
|
|
||||||
|
|
||||||
mStorageBuffers[0] = device.CreateBuffer(&storageBufferDescriptor);
|
mStorageBuffers[0] = device.CreateBuffer(&storageBufferDescriptor);
|
||||||
|
|
||||||
|
@ -74,7 +73,7 @@ class DynamicBufferOffsetTests : public DawnTest {
|
||||||
|
|
||||||
// Extra uniform buffer for inheriting test
|
// Extra uniform buffer for inheriting test
|
||||||
mUniformBuffers[2] = utils::CreateBufferFromData(device, uniformData.data(), kBufferSize,
|
mUniformBuffers[2] = utils::CreateBufferFromData(device, uniformData.data(), kBufferSize,
|
||||||
dawn::BufferUsageBit::Uniform);
|
dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
// Bind group layout for inheriting test
|
// Bind group layout for inheriting test
|
||||||
mBindGroupLayouts[1] = utils::MakeBindGroupLayout(
|
mBindGroupLayouts[1] = utils::MakeBindGroupLayout(
|
||||||
|
|
|
@ -118,7 +118,7 @@ class IOSurfaceValidationTests : public IOSurfaceTestBase {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.arrayLayerCount = 1;
|
descriptor.arrayLayerCount = 1;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
|
descriptor.usage = dawn::TextureUsage::OutputAttachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -248,7 +248,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
|
||||||
textureDescriptor.sampleCount = 1;
|
textureDescriptor.sampleCount = 1;
|
||||||
textureDescriptor.arrayLayerCount = 1;
|
textureDescriptor.arrayLayerCount = 1;
|
||||||
textureDescriptor.mipLevelCount = 1;
|
textureDescriptor.mipLevelCount = 1;
|
||||||
textureDescriptor.usage = dawn::TextureUsageBit::Sampled;
|
textureDescriptor.usage = dawn::TextureUsage::Sampled;
|
||||||
dawn::Texture wrappingTexture = WrapIOSurface(&textureDescriptor, ioSurface, 0);
|
dawn::Texture wrappingTexture = WrapIOSurface(&textureDescriptor, ioSurface, 0);
|
||||||
|
|
||||||
dawn::TextureView textureView = wrappingTexture.CreateDefaultView();
|
dawn::TextureView textureView = wrappingTexture.CreateDefaultView();
|
||||||
|
@ -341,7 +341,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
|
||||||
textureDescriptor.sampleCount = 1;
|
textureDescriptor.sampleCount = 1;
|
||||||
textureDescriptor.arrayLayerCount = 1;
|
textureDescriptor.arrayLayerCount = 1;
|
||||||
textureDescriptor.mipLevelCount = 1;
|
textureDescriptor.mipLevelCount = 1;
|
||||||
textureDescriptor.usage = dawn::TextureUsageBit::OutputAttachment;
|
textureDescriptor.usage = dawn::TextureUsage::OutputAttachment;
|
||||||
dawn::Texture ioSurfaceTexture = WrapIOSurface(&textureDescriptor, ioSurface, 0);
|
dawn::Texture ioSurfaceTexture = WrapIOSurface(&textureDescriptor, ioSurface, 0);
|
||||||
|
|
||||||
dawn::TextureView ioSurfaceView = ioSurfaceTexture.CreateDefaultView();
|
dawn::TextureView ioSurfaceView = ioSurfaceTexture.CreateDefaultView();
|
||||||
|
|
|
@ -66,16 +66,13 @@ class IndexFormatTest : public DawnTest {
|
||||||
TEST_P(IndexFormatTest, Uint32) {
|
TEST_P(IndexFormatTest, Uint32) {
|
||||||
dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint32);
|
dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint32);
|
||||||
|
|
||||||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
|
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1]
|
device, dawn::BufferUsage::Vertex,
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f,
|
{-1.0f, 1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1]
|
||||||
1.0f, 1.0f, 0.0f, 1.0f,
|
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f
|
|
||||||
});
|
|
||||||
// If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing.
|
// If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing.
|
||||||
dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsageBit::Index, {
|
dawn::Buffer indexBuffer =
|
||||||
1, 2, 3
|
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {1, 2, 3});
|
||||||
});
|
|
||||||
|
|
||||||
uint64_t zeroOffset = 0;
|
uint64_t zeroOffset = 0;
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
@ -98,15 +95,12 @@ TEST_P(IndexFormatTest, Uint32) {
|
||||||
TEST_P(IndexFormatTest, Uint16) {
|
TEST_P(IndexFormatTest, Uint16) {
|
||||||
dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint16);
|
dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint16);
|
||||||
|
|
||||||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
|
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f,
|
device, dawn::BufferUsage::Vertex,
|
||||||
1.0f, 1.0f, 0.0f, 1.0f,
|
{-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f
|
|
||||||
});
|
|
||||||
// If this is interpreted as uint32, it will have index 1 and 2 be both 0 and render nothing
|
// If this is interpreted as uint32, it will have index 1 and 2 be both 0 and render nothing
|
||||||
dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint16_t>(device, dawn::BufferUsageBit::Index, {
|
dawn::Buffer indexBuffer =
|
||||||
1, 2, 0, 0, 0, 0
|
utils::CreateBufferFromData<uint16_t>(device, dawn::BufferUsage::Index, {1, 2, 0, 0, 0, 0});
|
||||||
});
|
|
||||||
|
|
||||||
uint64_t zeroOffset = 0;
|
uint64_t zeroOffset = 0;
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
@ -141,15 +135,22 @@ TEST_P(IndexFormatTest, Uint16) {
|
||||||
TEST_P(IndexFormatTest, Uint32PrimitiveRestart) {
|
TEST_P(IndexFormatTest, Uint32PrimitiveRestart) {
|
||||||
dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint32);
|
dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint32);
|
||||||
|
|
||||||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
|
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
0.0f, 1.0f, 0.0f, 1.0f,
|
device, dawn::BufferUsage::Vertex,
|
||||||
1.0f, 0.0f, 0.0f, 1.0f,
|
{
|
||||||
0.0f, 0.0f, 0.0f, 1.0f,
|
0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
0.0f, -1.0f, 0.0f, 1.0f,
|
0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f,
|
|
||||||
});
|
});
|
||||||
dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsageBit::Index, {
|
dawn::Buffer indexBuffer =
|
||||||
0, 1, 2, 0xFFFFFFFFu, 3, 4, 2,
|
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index,
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
0xFFFFFFFFu,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
2,
|
||||||
});
|
});
|
||||||
|
|
||||||
uint64_t zeroOffset = 0;
|
uint64_t zeroOffset = 0;
|
||||||
|
@ -175,15 +176,22 @@ TEST_P(IndexFormatTest, Uint32PrimitiveRestart) {
|
||||||
TEST_P(IndexFormatTest, Uint16PrimitiveRestart) {
|
TEST_P(IndexFormatTest, Uint16PrimitiveRestart) {
|
||||||
dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint16);
|
dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint16);
|
||||||
|
|
||||||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
|
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
0.0f, 1.0f, 0.0f, 1.0f,
|
device, dawn::BufferUsage::Vertex,
|
||||||
1.0f, 0.0f, 0.0f, 1.0f,
|
{
|
||||||
0.0f, 0.0f, 0.0f, 1.0f,
|
0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
0.0f, -1.0f, 0.0f, 1.0f,
|
0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f,
|
|
||||||
});
|
});
|
||||||
dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint16_t>(device, dawn::BufferUsageBit::Index, {
|
dawn::Buffer indexBuffer =
|
||||||
0, 1, 2, 0xFFFFu, 3, 4, 2,
|
utils::CreateBufferFromData<uint16_t>(device, dawn::BufferUsage::Index,
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
0xFFFFu,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
2,
|
||||||
// This value is for padding.
|
// This value is for padding.
|
||||||
0xFFFFu,
|
0xFFFFu,
|
||||||
});
|
});
|
||||||
|
@ -216,16 +224,13 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
|
||||||
dawn::RenderPipeline pipeline32 = MakeTestPipeline(dawn::IndexFormat::Uint32);
|
dawn::RenderPipeline pipeline32 = MakeTestPipeline(dawn::IndexFormat::Uint32);
|
||||||
dawn::RenderPipeline pipeline16 = MakeTestPipeline(dawn::IndexFormat::Uint16);
|
dawn::RenderPipeline pipeline16 = MakeTestPipeline(dawn::IndexFormat::Uint16);
|
||||||
|
|
||||||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
|
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1]
|
device, dawn::BufferUsage::Vertex,
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f,
|
{-1.0f, 1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1]
|
||||||
1.0f, 1.0f, 0.0f, 1.0f,
|
-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f
|
|
||||||
});
|
|
||||||
// If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing.
|
// If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing.
|
||||||
dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsageBit::Index, {
|
dawn::Buffer indexBuffer =
|
||||||
1, 2, 3
|
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {1, 2, 3});
|
||||||
});
|
|
||||||
|
|
||||||
uint64_t zeroOffset = 0;
|
uint64_t zeroOffset = 0;
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
@ -253,14 +258,11 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
|
||||||
TEST_P(IndexFormatTest, DISABLED_SetIndexBufferBeforeSetPipeline) {
|
TEST_P(IndexFormatTest, DISABLED_SetIndexBufferBeforeSetPipeline) {
|
||||||
dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint32);
|
dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint32);
|
||||||
|
|
||||||
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
|
dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f,
|
device, dawn::BufferUsage::Vertex,
|
||||||
1.0f, 1.0f, 0.0f, 1.0f,
|
{-1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f});
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f
|
dawn::Buffer indexBuffer =
|
||||||
});
|
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Index, {0, 1, 2});
|
||||||
dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsageBit::Index, {
|
|
||||||
0, 1, 2
|
|
||||||
});
|
|
||||||
|
|
||||||
uint64_t zeroOffset = 0;
|
uint64_t zeroOffset = 0;
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
|
|
@ -95,7 +95,7 @@ class MultisampledRenderingTest : public DawnTest {
|
||||||
descriptor.sampleCount = sampleCount;
|
descriptor.sampleCount = sampleCount;
|
||||||
descriptor.format = format;
|
descriptor.format = format;
|
||||||
descriptor.mipLevelCount = mipLevelCount;
|
descriptor.mipLevelCount = mipLevelCount;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
descriptor.usage = dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
return device.CreateTexture(&descriptor);
|
return device.CreateTexture(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,9 +104,8 @@ class MultisampledRenderingTest : public DawnTest {
|
||||||
const dawn::RenderPipeline& pipeline,
|
const dawn::RenderPipeline& pipeline,
|
||||||
const float* uniformData,
|
const float* uniformData,
|
||||||
uint32_t uniformDataSize) {
|
uint32_t uniformDataSize) {
|
||||||
dawn::Buffer uniformBuffer =
|
dawn::Buffer uniformBuffer = utils::CreateBufferFromData(
|
||||||
utils::CreateBufferFromData(device, uniformData, uniformDataSize,
|
device, uniformData, uniformDataSize, dawn::BufferUsage::Uniform);
|
||||||
dawn::BufferUsageBit::Uniform);
|
|
||||||
dawn::BindGroup bindGroup =
|
dawn::BindGroup bindGroup =
|
||||||
utils::MakeBindGroup(device, mBindGroupLayout,
|
utils::MakeBindGroup(device, mBindGroupLayout,
|
||||||
{{0, uniformBuffer, 0, uniformDataSize}});
|
{{0, uniformBuffer, 0, uniformDataSize}});
|
||||||
|
|
|
@ -37,7 +37,7 @@ TEST_P(NonzeroTextureCreationTests, TextureCreationClearsOneBits) {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
descriptor.usage = dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
RGBA8 filledWithOnes(255, 255, 255, 255);
|
RGBA8 filledWithOnes(255, 255, 255, 255);
|
||||||
|
@ -57,7 +57,7 @@ TEST_P(NonzeroTextureCreationTests, MipMapClears) {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = mipLevels;
|
descriptor.mipLevelCount = mipLevels;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
descriptor.usage = dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
std::vector<RGBA8> expected;
|
std::vector<RGBA8> expected;
|
||||||
|
@ -82,7 +82,7 @@ TEST_P(NonzeroTextureCreationTests, ArrayLayerClears) {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
descriptor.usage = dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
std::vector<RGBA8> expected;
|
std::vector<RGBA8> expected;
|
||||||
|
@ -107,14 +107,14 @@ TEST_P(NonzeroTextureCreationTests, NonrenderableTextureFormat) {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Snorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Snorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::CopySrc;
|
descriptor.usage = dawn::TextureUsage::CopySrc;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
// Set buffer with dirty data so we know it is cleared by the lazy cleared texture copy
|
// Set buffer with dirty data so we know it is cleared by the lazy cleared texture copy
|
||||||
uint32_t bufferSize = 4 * kSize * kSize;
|
uint32_t bufferSize = 4 * kSize * kSize;
|
||||||
std::vector<uint8_t> data(bufferSize, 100);
|
std::vector<uint8_t> data(bufferSize, 100);
|
||||||
dawn::Buffer bufferDst = utils::CreateBufferFromData(
|
dawn::Buffer bufferDst = utils::CreateBufferFromData(
|
||||||
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsageBit::CopySrc);
|
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsage::CopySrc);
|
||||||
|
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(bufferDst, 0, 0, 0);
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(bufferDst, 0, 0, 0);
|
||||||
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||||
|
|
|
@ -26,7 +26,7 @@ class OpArrayLengthTest : public DawnTest {
|
||||||
// Create buffers of various size to check the length() implementation
|
// Create buffers of various size to check the length() implementation
|
||||||
dawn::BufferDescriptor bufferDesc;
|
dawn::BufferDescriptor bufferDesc;
|
||||||
bufferDesc.size = 4;
|
bufferDesc.size = 4;
|
||||||
bufferDesc.usage = dawn::BufferUsageBit::Storage;
|
bufferDesc.usage = dawn::BufferUsage::Storage;
|
||||||
mStorageBuffer4 = device.CreateBuffer(&bufferDesc);
|
mStorageBuffer4 = device.CreateBuffer(&bufferDesc);
|
||||||
|
|
||||||
bufferDesc.size = 256;
|
bufferDesc.size = 256;
|
||||||
|
@ -95,7 +95,7 @@ TEST_P(OpArrayLengthTest, Compute) {
|
||||||
|
|
||||||
// Create a buffer to hold the result sizes and create a bindgroup for it.
|
// Create a buffer to hold the result sizes and create a bindgroup for it.
|
||||||
dawn::BufferDescriptor bufferDesc;
|
dawn::BufferDescriptor bufferDesc;
|
||||||
bufferDesc.usage = dawn::BufferUsageBit::Storage | dawn::BufferUsageBit::CopySrc;
|
bufferDesc.usage = dawn::BufferUsage::Storage | dawn::BufferUsage::CopySrc;
|
||||||
bufferDesc.size = sizeof(uint32_t) * mExpectedLengths.size();
|
bufferDesc.size = sizeof(uint32_t) * mExpectedLengths.size();
|
||||||
dawn::Buffer resultBuffer = device.CreateBuffer(&bufferDesc);
|
dawn::Buffer resultBuffer = device.CreateBuffer(&bufferDesc);
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,8 @@ class PrimitiveTopologyTest : public DawnTest {
|
||||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
|
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
|
||||||
})");
|
})");
|
||||||
|
|
||||||
vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), dawn::BufferUsageBit::Vertex);
|
vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
|
||||||
|
dawn::BufferUsage::Vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LocationSpec {
|
struct LocationSpec {
|
||||||
|
|
|
@ -59,9 +59,9 @@ class RenderBundleTest : public DawnTest {
|
||||||
kColors[1].a / 255.f};
|
kColors[1].a / 255.f};
|
||||||
|
|
||||||
dawn::Buffer buffer0 = utils::CreateBufferFromData(device, colors0, 4 * sizeof(float),
|
dawn::Buffer buffer0 = utils::CreateBufferFromData(device, colors0, 4 * sizeof(float),
|
||||||
dawn::BufferUsageBit::Uniform);
|
dawn::BufferUsage::Uniform);
|
||||||
dawn::Buffer buffer1 = utils::CreateBufferFromData(device, colors1, 4 * sizeof(float),
|
dawn::Buffer buffer1 = utils::CreateBufferFromData(device, colors1, 4 * sizeof(float),
|
||||||
dawn::BufferUsageBit::Uniform);
|
dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
bindGroups[0] = utils::MakeBindGroup(device, bgl, {{0, buffer0, 0, 4 * sizeof(float)}});
|
bindGroups[0] = utils::MakeBindGroup(device, bgl, {{0, buffer0, 0, 4 * sizeof(float)}});
|
||||||
bindGroups[1] = utils::MakeBindGroup(device, bgl, {{0, buffer1, 0, 4 * sizeof(float)}});
|
bindGroups[1] = utils::MakeBindGroup(device, bgl, {{0, buffer1, 0, 4 * sizeof(float)}});
|
||||||
|
@ -86,7 +86,7 @@ class RenderBundleTest : public DawnTest {
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||||
|
|
||||||
vertexBuffer = utils::CreateBufferFromData<float>(
|
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
device, dawn::BufferUsageBit::Vertex,
|
device, dawn::BufferUsage::Vertex,
|
||||||
{// The bottom left triangle
|
{// The bottom left triangle
|
||||||
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
|
-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,7 @@ class RenderPassLoadOpTests : public DawnTest {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage =
|
descriptor.usage = dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
|
||||||
renderTarget = device.CreateTexture(&descriptor);
|
renderTarget = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
renderTargetView = renderTarget.CreateDefaultView();
|
renderTargetView = renderTarget.CreateDefaultView();
|
||||||
|
|
|
@ -62,7 +62,7 @@ protected:
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = kFormat;
|
descriptor.format = kFormat;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
descriptor.usage = dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
return device.CreateTexture(&descriptor);
|
return device.CreateTexture(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ protected:
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::Sampled;
|
descriptor.usage = dawn::TextureUsage::CopyDst | dawn::TextureUsage::Sampled;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
// Create a 2x2 checkerboard texture, with black in the top left and bottom right corners.
|
// Create a 2x2 checkerboard texture, with black in the top left and bottom right corners.
|
||||||
|
@ -102,7 +102,7 @@ protected:
|
||||||
data[1] = data[rowPixels] = white;
|
data[1] = data[rowPixels] = white;
|
||||||
|
|
||||||
dawn::Buffer stagingBuffer =
|
dawn::Buffer stagingBuffer =
|
||||||
utils::CreateBufferFromData(device, data, sizeof(data), dawn::BufferUsageBit::CopySrc);
|
utils::CreateBufferFromData(device, data, sizeof(data), dawn::BufferUsage::CopySrc);
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 256, 0);
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 256, 0);
|
||||||
dawn::TextureCopyView textureCopyView =
|
dawn::TextureCopyView textureCopyView =
|
||||||
utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||||
|
|
|
@ -245,20 +245,19 @@ class TextureFormatTest : public DawnTest {
|
||||||
|
|
||||||
// Create the texture we will sample from
|
// Create the texture we will sample from
|
||||||
dawn::TextureDescriptor sampleTextureDesc;
|
dawn::TextureDescriptor sampleTextureDesc;
|
||||||
sampleTextureDesc.usage = dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::Sampled;
|
sampleTextureDesc.usage = dawn::TextureUsage::CopyDst | dawn::TextureUsage::Sampled;
|
||||||
sampleTextureDesc.size = {width, 1, 1};
|
sampleTextureDesc.size = {width, 1, 1};
|
||||||
sampleTextureDesc.format = sampleFormatInfo.format;
|
sampleTextureDesc.format = sampleFormatInfo.format;
|
||||||
dawn::Texture sampleTexture = device.CreateTexture(&sampleTextureDesc);
|
dawn::Texture sampleTexture = device.CreateTexture(&sampleTextureDesc);
|
||||||
|
|
||||||
dawn::Buffer uploadBuffer = utils::CreateBufferFromData(device, sampleData, sampleDataSize,
|
dawn::Buffer uploadBuffer = utils::CreateBufferFromData(device, sampleData, sampleDataSize,
|
||||||
dawn::BufferUsageBit::CopySrc);
|
dawn::BufferUsage::CopySrc);
|
||||||
|
|
||||||
// Create the texture that we will render results to
|
// Create the texture that we will render results to
|
||||||
ASSERT(expectedRenderDataSize == width * renderFormatInfo.texelByteSize);
|
ASSERT(expectedRenderDataSize == width * renderFormatInfo.texelByteSize);
|
||||||
|
|
||||||
dawn::TextureDescriptor renderTargetDesc;
|
dawn::TextureDescriptor renderTargetDesc;
|
||||||
renderTargetDesc.usage =
|
renderTargetDesc.usage = dawn::TextureUsage::CopySrc | dawn::TextureUsage::OutputAttachment;
|
||||||
dawn::TextureUsageBit::CopySrc | dawn::TextureUsageBit::OutputAttachment;
|
|
||||||
renderTargetDesc.size = {width, 1, 1};
|
renderTargetDesc.size = {width, 1, 1};
|
||||||
renderTargetDesc.format = renderFormatInfo.format;
|
renderTargetDesc.format = renderFormatInfo.format;
|
||||||
|
|
||||||
|
@ -266,7 +265,7 @@ class TextureFormatTest : public DawnTest {
|
||||||
|
|
||||||
// Create the readback buffer for the data in renderTarget
|
// Create the readback buffer for the data in renderTarget
|
||||||
dawn::BufferDescriptor readbackBufferDesc;
|
dawn::BufferDescriptor readbackBufferDesc;
|
||||||
readbackBufferDesc.usage = dawn::BufferUsageBit::CopyDst | dawn::BufferUsageBit::CopySrc;
|
readbackBufferDesc.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::CopySrc;
|
||||||
readbackBufferDesc.size = 4 * width * sampleFormatInfo.componentCount;
|
readbackBufferDesc.size = 4 * width * sampleFormatInfo.componentCount;
|
||||||
dawn::Buffer readbackBuffer = device.CreateBuffer(&readbackBufferDesc);
|
dawn::Buffer readbackBuffer = device.CreateBuffer(&readbackBufferDesc);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace {
|
||||||
uint32_t height,
|
uint32_t height,
|
||||||
uint32_t arrayLayerCount,
|
uint32_t arrayLayerCount,
|
||||||
uint32_t mipLevelCount,
|
uint32_t mipLevelCount,
|
||||||
dawn::TextureUsageBit usage) {
|
dawn::TextureUsage usage) {
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
descriptor.size.width = width;
|
descriptor.size.width = width;
|
||||||
|
@ -114,8 +114,8 @@ protected:
|
||||||
|
|
||||||
const uint32_t textureWidthLevel0 = 1 << mipLevelCount;
|
const uint32_t textureWidthLevel0 = 1 << mipLevelCount;
|
||||||
const uint32_t textureHeightLevel0 = 1 << mipLevelCount;
|
const uint32_t textureHeightLevel0 = 1 << mipLevelCount;
|
||||||
constexpr dawn::TextureUsageBit kUsage =
|
constexpr dawn::TextureUsage kUsage =
|
||||||
dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::Sampled;
|
dawn::TextureUsage::CopyDst | dawn::TextureUsage::Sampled;
|
||||||
mTexture = Create2DTexture(
|
mTexture = Create2DTexture(
|
||||||
device, textureWidthLevel0, textureHeightLevel0, arrayLayerCount, mipLevelCount, kUsage);
|
device, textureWidthLevel0, textureHeightLevel0, arrayLayerCount, mipLevelCount, kUsage);
|
||||||
|
|
||||||
|
@ -143,9 +143,8 @@ protected:
|
||||||
|
|
||||||
constexpr uint32_t kPaddedTexWidth = kPixelsPerRowPitch;
|
constexpr uint32_t kPaddedTexWidth = kPixelsPerRowPitch;
|
||||||
std::vector<RGBA8> data(kPaddedTexWidth * texHeight, RGBA8(0, 0, 0, pixelValue));
|
std::vector<RGBA8> data(kPaddedTexWidth * texHeight, RGBA8(0, 0, 0, pixelValue));
|
||||||
dawn::Buffer stagingBuffer =
|
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
||||||
utils::CreateBufferFromData(device, data.data(), data.size() * sizeof(RGBA8),
|
device, data.data(), data.size() * sizeof(RGBA8), dawn::BufferUsage::CopySrc);
|
||||||
dawn::BufferUsageBit::CopySrc);
|
|
||||||
dawn::BufferCopyView bufferCopyView =
|
dawn::BufferCopyView bufferCopyView =
|
||||||
utils::CreateBufferCopyView(stagingBuffer, 0, kTextureRowPitchAlignment, 0);
|
utils::CreateBufferCopyView(stagingBuffer, 0, kTextureRowPitchAlignment, 0);
|
||||||
dawn::TextureCopyView textureCopyView =
|
dawn::TextureCopyView textureCopyView =
|
||||||
|
@ -474,8 +473,8 @@ class TextureViewRenderingTest : public DawnTest {
|
||||||
|
|
||||||
const uint32_t textureWidthLevel0 = 1 << levelCount;
|
const uint32_t textureWidthLevel0 = 1 << levelCount;
|
||||||
const uint32_t textureHeightLevel0 = 1 << levelCount;
|
const uint32_t textureHeightLevel0 = 1 << levelCount;
|
||||||
constexpr dawn::TextureUsageBit kUsage =
|
constexpr dawn::TextureUsage kUsage =
|
||||||
dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
dawn::Texture texture = Create2DTexture(
|
dawn::Texture texture = Create2DTexture(
|
||||||
device, textureWidthLevel0, textureHeightLevel0, layerCount, levelCount, kUsage);
|
device, textureWidthLevel0, textureHeightLevel0, layerCount, levelCount, kUsage);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class TextureZeroInitTest : public DawnTest {
|
||||||
}
|
}
|
||||||
dawn::TextureDescriptor CreateTextureDescriptor(uint32_t mipLevelCount,
|
dawn::TextureDescriptor CreateTextureDescriptor(uint32_t mipLevelCount,
|
||||||
uint32_t arrayLayerCount,
|
uint32_t arrayLayerCount,
|
||||||
dawn::TextureUsageBit usage,
|
dawn::TextureUsage usage,
|
||||||
dawn::TextureFormat format) {
|
dawn::TextureFormat format) {
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
|
@ -93,8 +93,7 @@ class TextureZeroInitTest : public DawnTest {
|
||||||
// This tests that the code path of CopyTextureToBuffer clears correctly to Zero after first usage
|
// This tests that the code path of CopyTextureToBuffer clears correctly to Zero after first usage
|
||||||
TEST_P(TextureZeroInitTest, CopyTextureToBufferSource) {
|
TEST_P(TextureZeroInitTest, CopyTextureToBufferSource) {
|
||||||
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||||
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc,
|
1, 1, dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc, kColorFormat);
|
||||||
kColorFormat);
|
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
// Texture's first usage is in EXPECT_PIXEL_RGBA8_EQ's call to CopyTextureToBuffer
|
// Texture's first usage is in EXPECT_PIXEL_RGBA8_EQ's call to CopyTextureToBuffer
|
||||||
|
@ -106,8 +105,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToBufferSource) {
|
||||||
// This goes through the BeginRenderPass's code path
|
// This goes through the BeginRenderPass's code path
|
||||||
TEST_P(TextureZeroInitTest, RenderingMipMapClearsToZero) {
|
TEST_P(TextureZeroInitTest, RenderingMipMapClearsToZero) {
|
||||||
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||||
4, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc,
|
4, 1, dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc, kColorFormat);
|
||||||
kColorFormat);
|
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
dawn::TextureViewDescriptor viewDescriptor = CreateTextureViewDescriptor(2, 0);
|
dawn::TextureViewDescriptor viewDescriptor = CreateTextureViewDescriptor(2, 0);
|
||||||
|
@ -135,8 +133,7 @@ TEST_P(TextureZeroInitTest, RenderingMipMapClearsToZero) {
|
||||||
// This goes through the BeginRenderPass's code path
|
// This goes through the BeginRenderPass's code path
|
||||||
TEST_P(TextureZeroInitTest, RenderingArrayLayerClearsToZero) {
|
TEST_P(TextureZeroInitTest, RenderingArrayLayerClearsToZero) {
|
||||||
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||||
1, 4, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc,
|
1, 4, dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc, kColorFormat);
|
||||||
kColorFormat);
|
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
dawn::TextureViewDescriptor viewDescriptor = CreateTextureViewDescriptor(0, 2);
|
dawn::TextureViewDescriptor viewDescriptor = CreateTextureViewDescriptor(0, 2);
|
||||||
|
@ -162,16 +159,15 @@ TEST_P(TextureZeroInitTest, RenderingArrayLayerClearsToZero) {
|
||||||
// TODO(natlee@microsoft.com): Add backdoor to dawn native to query the number of zero-inited
|
// TODO(natlee@microsoft.com): Add backdoor to dawn native to query the number of zero-inited
|
||||||
// subresources
|
// subresources
|
||||||
TEST_P(TextureZeroInitTest, CopyBufferToTexture) {
|
TEST_P(TextureZeroInitTest, CopyBufferToTexture) {
|
||||||
dawn::TextureDescriptor descriptor =
|
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||||
CreateTextureDescriptor(4, 1,
|
4, 1,
|
||||||
dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::Sampled |
|
dawn::TextureUsage::CopyDst | dawn::TextureUsage::Sampled | dawn::TextureUsage::CopySrc,
|
||||||
dawn::TextureUsageBit::CopySrc,
|
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
||||||
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
||||||
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsageBit::CopySrc);
|
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsage::CopySrc);
|
||||||
|
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
||||||
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||||
|
@ -190,16 +186,15 @@ TEST_P(TextureZeroInitTest, CopyBufferToTexture) {
|
||||||
// Test for a copy only to a subset of the subresource, lazy init is necessary to clear the other
|
// Test for a copy only to a subset of the subresource, lazy init is necessary to clear the other
|
||||||
// half.
|
// half.
|
||||||
TEST_P(TextureZeroInitTest, CopyBufferToTextureHalf) {
|
TEST_P(TextureZeroInitTest, CopyBufferToTextureHalf) {
|
||||||
dawn::TextureDescriptor descriptor =
|
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||||
CreateTextureDescriptor(4, 1,
|
4, 1,
|
||||||
dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::Sampled |
|
dawn::TextureUsage::CopyDst | dawn::TextureUsage::Sampled | dawn::TextureUsage::CopySrc,
|
||||||
dawn::TextureUsageBit::CopySrc,
|
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
||||||
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
||||||
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsageBit::CopySrc);
|
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsage::CopySrc);
|
||||||
|
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
||||||
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||||
|
@ -221,7 +216,7 @@ TEST_P(TextureZeroInitTest, CopyBufferToTextureHalf) {
|
||||||
// This tests CopyTextureToTexture fully overwrites copy so lazy init is not needed.
|
// This tests CopyTextureToTexture fully overwrites copy so lazy init is not needed.
|
||||||
TEST_P(TextureZeroInitTest, CopyTextureToTexture) {
|
TEST_P(TextureZeroInitTest, CopyTextureToTexture) {
|
||||||
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
||||||
1, 1, dawn::TextureUsageBit::Sampled | dawn::TextureUsageBit::CopySrc, kColorFormat);
|
1, 1, dawn::TextureUsage::Sampled | dawn::TextureUsage::CopySrc, kColorFormat);
|
||||||
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
||||||
|
|
||||||
dawn::TextureCopyView srcTextureCopyView =
|
dawn::TextureCopyView srcTextureCopyView =
|
||||||
|
@ -229,8 +224,8 @@ TEST_P(TextureZeroInitTest, CopyTextureToTexture) {
|
||||||
|
|
||||||
dawn::TextureDescriptor dstDescriptor =
|
dawn::TextureDescriptor dstDescriptor =
|
||||||
CreateTextureDescriptor(1, 1,
|
CreateTextureDescriptor(1, 1,
|
||||||
dawn::TextureUsageBit::OutputAttachment |
|
dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopyDst |
|
||||||
dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::CopySrc,
|
dawn::TextureUsage::CopySrc,
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture dstTexture = device.CreateTexture(&dstDescriptor);
|
dawn::Texture dstTexture = device.CreateTexture(&dstDescriptor);
|
||||||
|
|
||||||
|
@ -253,10 +248,9 @@ TEST_P(TextureZeroInitTest, CopyTextureToTexture) {
|
||||||
// This Tests the CopyTextureToTexture's copy only to a subset of the subresource, lazy init is
|
// This Tests the CopyTextureToTexture's copy only to a subset of the subresource, lazy init is
|
||||||
// necessary to clear the other half.
|
// necessary to clear the other half.
|
||||||
TEST_P(TextureZeroInitTest, CopyTextureToTextureHalf) {
|
TEST_P(TextureZeroInitTest, CopyTextureToTextureHalf) {
|
||||||
dawn::TextureDescriptor srcDescriptor =
|
dawn::TextureDescriptor srcDescriptor = CreateTextureDescriptor(
|
||||||
CreateTextureDescriptor(1, 1,
|
1, 1,
|
||||||
dawn::TextureUsageBit::Sampled | dawn::TextureUsageBit::CopySrc |
|
dawn::TextureUsage::Sampled | dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst,
|
||||||
dawn::TextureUsageBit::CopyDst,
|
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
||||||
|
|
||||||
|
@ -264,7 +258,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToTextureHalf) {
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
std::vector<uint8_t> data(4 * kSize * kSize, 100);
|
||||||
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
||||||
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsageBit::CopySrc);
|
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsage::CopySrc);
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
||||||
dawn::TextureCopyView textureCopyView =
|
dawn::TextureCopyView textureCopyView =
|
||||||
utils::CreateTextureCopyView(srcTexture, 0, 0, {0, 0, 0});
|
utils::CreateTextureCopyView(srcTexture, 0, 0, {0, 0, 0});
|
||||||
|
@ -280,8 +274,8 @@ TEST_P(TextureZeroInitTest, CopyTextureToTextureHalf) {
|
||||||
|
|
||||||
dawn::TextureDescriptor dstDescriptor =
|
dawn::TextureDescriptor dstDescriptor =
|
||||||
CreateTextureDescriptor(1, 1,
|
CreateTextureDescriptor(1, 1,
|
||||||
dawn::TextureUsageBit::OutputAttachment |
|
dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopyDst |
|
||||||
dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::CopySrc,
|
dawn::TextureUsage::CopySrc,
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture dstTexture = device.CreateTexture(&dstDescriptor);
|
dawn::Texture dstTexture = device.CreateTexture(&dstDescriptor);
|
||||||
|
|
||||||
|
@ -308,13 +302,13 @@ TEST_P(TextureZeroInitTest, CopyTextureToTextureHalf) {
|
||||||
TEST_P(TextureZeroInitTest, RenderingLoadingDepth) {
|
TEST_P(TextureZeroInitTest, RenderingLoadingDepth) {
|
||||||
dawn::TextureDescriptor srcDescriptor =
|
dawn::TextureDescriptor srcDescriptor =
|
||||||
CreateTextureDescriptor(1, 1,
|
CreateTextureDescriptor(1, 1,
|
||||||
dawn::TextureUsageBit::CopySrc | dawn::TextureUsageBit::CopyDst |
|
dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst |
|
||||||
dawn::TextureUsageBit::OutputAttachment,
|
dawn::TextureUsage::OutputAttachment,
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
||||||
|
|
||||||
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
||||||
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc,
|
1, 1, dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc,
|
||||||
kDepthStencilFormat);
|
kDepthStencilFormat);
|
||||||
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
||||||
|
|
||||||
|
@ -343,13 +337,13 @@ TEST_P(TextureZeroInitTest, RenderingLoadingDepth) {
|
||||||
TEST_P(TextureZeroInitTest, RenderingLoadingStencil) {
|
TEST_P(TextureZeroInitTest, RenderingLoadingStencil) {
|
||||||
dawn::TextureDescriptor srcDescriptor =
|
dawn::TextureDescriptor srcDescriptor =
|
||||||
CreateTextureDescriptor(1, 1,
|
CreateTextureDescriptor(1, 1,
|
||||||
dawn::TextureUsageBit::CopySrc | dawn::TextureUsageBit::CopyDst |
|
dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst |
|
||||||
dawn::TextureUsageBit::OutputAttachment,
|
dawn::TextureUsage::OutputAttachment,
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
||||||
|
|
||||||
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
||||||
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc,
|
1, 1, dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc,
|
||||||
kDepthStencilFormat);
|
kDepthStencilFormat);
|
||||||
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
||||||
|
|
||||||
|
@ -378,13 +372,13 @@ TEST_P(TextureZeroInitTest, RenderingLoadingStencil) {
|
||||||
TEST_P(TextureZeroInitTest, RenderingLoadingDepthStencil) {
|
TEST_P(TextureZeroInitTest, RenderingLoadingDepthStencil) {
|
||||||
dawn::TextureDescriptor srcDescriptor =
|
dawn::TextureDescriptor srcDescriptor =
|
||||||
CreateTextureDescriptor(1, 1,
|
CreateTextureDescriptor(1, 1,
|
||||||
dawn::TextureUsageBit::CopySrc | dawn::TextureUsageBit::CopyDst |
|
dawn::TextureUsage::CopySrc | dawn::TextureUsage::CopyDst |
|
||||||
dawn::TextureUsageBit::OutputAttachment,
|
dawn::TextureUsage::OutputAttachment,
|
||||||
kColorFormat);
|
kColorFormat);
|
||||||
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
dawn::Texture srcTexture = device.CreateTexture(&srcDescriptor);
|
||||||
|
|
||||||
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor depthStencilDescriptor = CreateTextureDescriptor(
|
||||||
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc,
|
1, 1, dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc,
|
||||||
kDepthStencilFormat);
|
kDepthStencilFormat);
|
||||||
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
dawn::Texture depthStencilTexture = device.CreateTexture(&depthStencilDescriptor);
|
||||||
|
|
||||||
|
@ -410,8 +404,7 @@ TEST_P(TextureZeroInitTest, RenderingLoadingDepthStencil) {
|
||||||
// This tests the color attachments clear to 0s
|
// This tests the color attachments clear to 0s
|
||||||
TEST_P(TextureZeroInitTest, ColorAttachmentsClear) {
|
TEST_P(TextureZeroInitTest, ColorAttachmentsClear) {
|
||||||
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||||
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc,
|
1, 1, dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc, kColorFormat);
|
||||||
kColorFormat);
|
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat);
|
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat);
|
||||||
renderPass.renderPassInfo.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Load;
|
renderPass.renderPassInfo.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Load;
|
||||||
|
@ -431,12 +424,11 @@ TEST_P(TextureZeroInitTest, ColorAttachmentsClear) {
|
||||||
TEST_P(TextureZeroInitTest, RenderPassSampledTextureClear) {
|
TEST_P(TextureZeroInitTest, RenderPassSampledTextureClear) {
|
||||||
// Create needed resources
|
// Create needed resources
|
||||||
dawn::TextureDescriptor descriptor =
|
dawn::TextureDescriptor descriptor =
|
||||||
CreateTextureDescriptor(1, 1, dawn::TextureUsageBit::Sampled, kColorFormat);
|
CreateTextureDescriptor(1, 1, dawn::TextureUsage::Sampled, kColorFormat);
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
dawn::TextureDescriptor renderTextureDescriptor = CreateTextureDescriptor(
|
dawn::TextureDescriptor renderTextureDescriptor = CreateTextureDescriptor(
|
||||||
1, 1, dawn::TextureUsageBit::CopySrc | dawn::TextureUsageBit::OutputAttachment,
|
1, 1, dawn::TextureUsage::CopySrc | dawn::TextureUsage::OutputAttachment, kColorFormat);
|
||||||
kColorFormat);
|
|
||||||
dawn::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor);
|
dawn::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor);
|
||||||
|
|
||||||
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
|
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
|
||||||
|
@ -501,7 +493,7 @@ TEST_P(TextureZeroInitTest, RenderPassSampledTextureClear) {
|
||||||
TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) {
|
TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) {
|
||||||
// Create needed resources
|
// Create needed resources
|
||||||
dawn::TextureDescriptor descriptor =
|
dawn::TextureDescriptor descriptor =
|
||||||
CreateTextureDescriptor(1, 1, dawn::TextureUsageBit::Sampled, kColorFormat);
|
CreateTextureDescriptor(1, 1, dawn::TextureUsage::Sampled, kColorFormat);
|
||||||
descriptor.size.width = 1;
|
descriptor.size.width = 1;
|
||||||
descriptor.size.height = 1;
|
descriptor.size.height = 1;
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
@ -509,8 +501,8 @@ TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) {
|
||||||
uint32_t bufferSize = 4 * sizeof(uint32_t);
|
uint32_t bufferSize = 4 * sizeof(uint32_t);
|
||||||
dawn::BufferDescriptor bufferDescriptor;
|
dawn::BufferDescriptor bufferDescriptor;
|
||||||
bufferDescriptor.size = bufferSize;
|
bufferDescriptor.size = bufferSize;
|
||||||
bufferDescriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::Storage |
|
bufferDescriptor.usage =
|
||||||
dawn::BufferUsageBit::CopyDst;
|
dawn::BufferUsage::CopySrc | dawn::BufferUsage::Storage | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer bufferTex = device.CreateBuffer(&bufferDescriptor);
|
dawn::Buffer bufferTex = device.CreateBuffer(&bufferDescriptor);
|
||||||
// Add data to buffer to ensure it is initialized
|
// Add data to buffer to ensure it is initialized
|
||||||
uint32_t data = 100;
|
uint32_t data = 100;
|
||||||
|
@ -571,14 +563,14 @@ TEST_P(TextureZeroInitTest, NonRenderableTextureClear) {
|
||||||
DAWN_SKIP_TEST_IF(IsOpenGL() || IsD3D12());
|
DAWN_SKIP_TEST_IF(IsOpenGL() || IsD3D12());
|
||||||
|
|
||||||
dawn::TextureDescriptor descriptor =
|
dawn::TextureDescriptor descriptor =
|
||||||
CreateTextureDescriptor(1, 1, dawn::TextureUsageBit::CopySrc, kNonrenderableColorFormat);
|
CreateTextureDescriptor(1, 1, dawn::TextureUsage::CopySrc, kNonrenderableColorFormat);
|
||||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
// Set buffer with dirty data so we know it is cleared by the lazy cleared texture copy
|
// Set buffer with dirty data so we know it is cleared by the lazy cleared texture copy
|
||||||
uint32_t bufferSize = 4 * kSize * kSize;
|
uint32_t bufferSize = 4 * kSize * kSize;
|
||||||
std::vector<uint8_t> data(bufferSize, 100);
|
std::vector<uint8_t> data(bufferSize, 100);
|
||||||
dawn::Buffer bufferDst = utils::CreateBufferFromData(
|
dawn::Buffer bufferDst = utils::CreateBufferFromData(
|
||||||
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsageBit::CopySrc);
|
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsage::CopySrc);
|
||||||
|
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(bufferDst, 0, 0, 0);
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(bufferDst, 0, 0, 0);
|
||||||
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||||
|
|
|
@ -376,9 +376,8 @@ class VertexFormatTest : public DawnTest {
|
||||||
std::vector<VertexType> vertex,
|
std::vector<VertexType> vertex,
|
||||||
std::vector<ExpectedType> expectedData) {
|
std::vector<ExpectedType> expectedData) {
|
||||||
dawn::RenderPipeline pipeline = MakeTestPipeline(format, expectedData);
|
dawn::RenderPipeline pipeline = MakeTestPipeline(format, expectedData);
|
||||||
dawn::Buffer vertexBuffer =
|
dawn::Buffer vertexBuffer = utils::CreateBufferFromData(
|
||||||
utils::CreateBufferFromData(device, vertex.data(), vertex.size() * sizeof(VertexType),
|
device, vertex.data(), vertex.size() * sizeof(VertexType), dawn::BufferUsage::Vertex);
|
||||||
dawn::BufferUsageBit::Vertex);
|
|
||||||
uint64_t zeroOffset = 0;
|
uint64_t zeroOffset = 0;
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
{
|
{
|
||||||
|
|
|
@ -179,7 +179,7 @@ class VertexInputTest : public DawnTest {
|
||||||
dawn::Buffer MakeVertexBuffer(std::vector<T> data) {
|
dawn::Buffer MakeVertexBuffer(std::vector<T> data) {
|
||||||
return utils::CreateBufferFromData(device, data.data(),
|
return utils::CreateBufferFromData(device, data.data(),
|
||||||
static_cast<uint32_t>(data.size() * sizeof(T)),
|
static_cast<uint32_t>(data.size() * sizeof(T)),
|
||||||
dawn::BufferUsageBit::Vertex);
|
dawn::BufferUsage::Vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DrawVertexBuffer {
|
struct DrawVertexBuffer {
|
||||||
|
|
|
@ -68,7 +68,7 @@ class ViewportTest : public DawnTest {
|
||||||
textureDescriptor.dimension = dawn::TextureDimension::e2D;
|
textureDescriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
textureDescriptor.format = format;
|
textureDescriptor.format = format;
|
||||||
textureDescriptor.usage =
|
textureDescriptor.usage =
|
||||||
dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::CopySrc;
|
dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
||||||
textureDescriptor.arrayLayerCount = 1;
|
textureDescriptor.arrayLayerCount = 1;
|
||||||
textureDescriptor.mipLevelCount = 1;
|
textureDescriptor.mipLevelCount = 1;
|
||||||
textureDescriptor.sampleCount = 1;
|
textureDescriptor.sampleCount = 1;
|
||||||
|
|
|
@ -25,13 +25,13 @@ class BindGroupValidationTest : public ValidationTest {
|
||||||
{
|
{
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 1024;
|
descriptor.size = 1024;
|
||||||
descriptor.usage = dawn::BufferUsageBit::Uniform;
|
descriptor.usage = dawn::BufferUsage::Uniform;
|
||||||
mUBO = device.CreateBuffer(&descriptor);
|
mUBO = device.CreateBuffer(&descriptor);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 1024;
|
descriptor.size = 1024;
|
||||||
descriptor.usage = dawn::BufferUsageBit::Storage;
|
descriptor.usage = dawn::BufferUsage::Storage;
|
||||||
mSSBO = device.CreateBuffer(&descriptor);
|
mSSBO = device.CreateBuffer(&descriptor);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ class BindGroupValidationTest : public ValidationTest {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::Sampled;
|
descriptor.usage = dawn::TextureUsage::Sampled;
|
||||||
mSampledTexture = device.CreateTexture(&descriptor);
|
mSampledTexture = device.CreateTexture(&descriptor);
|
||||||
mSampledTextureView = mSampledTexture.CreateDefaultView();
|
mSampledTextureView = mSampledTexture.CreateDefaultView();
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ TEST_F(BindGroupValidationTest, BufferBindingType) {
|
||||||
{
|
{
|
||||||
dawn::BufferDescriptor bufferDesc;
|
dawn::BufferDescriptor bufferDesc;
|
||||||
bufferDesc.size = 1024;
|
bufferDesc.size = 1024;
|
||||||
bufferDesc.usage = static_cast<dawn::BufferUsageBit>(0xFFFFFFFF);
|
bufferDesc.usage = static_cast<dawn::BufferUsage>(0xFFFFFFFF);
|
||||||
|
|
||||||
dawn::Buffer errorBuffer;
|
dawn::Buffer errorBuffer;
|
||||||
ASSERT_DEVICE_ERROR(errorBuffer = device.CreateBuffer(&bufferDesc));
|
ASSERT_DEVICE_ERROR(errorBuffer = device.CreateBuffer(&bufferDesc));
|
||||||
|
@ -300,7 +300,7 @@ TEST_F(BindGroupValidationTest, TextureUsage) {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
|
descriptor.usage = dawn::TextureUsage::OutputAttachment;
|
||||||
dawn::Texture outputTexture = device.CreateTexture(&descriptor);
|
dawn::Texture outputTexture = device.CreateTexture(&descriptor);
|
||||||
dawn::TextureView outputTextureView = outputTexture.CreateDefaultView();
|
dawn::TextureView outputTextureView = outputTexture.CreateDefaultView();
|
||||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, outputTextureView}}));
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, outputTextureView}}));
|
||||||
|
@ -323,7 +323,7 @@ TEST_F(BindGroupValidationTest, TextureComponentType) {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Uint;
|
descriptor.format = dawn::TextureFormat::RGBA8Uint;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsageBit::Sampled;
|
descriptor.usage = dawn::TextureUsage::Sampled;
|
||||||
dawn::Texture uintTexture = device.CreateTexture(&descriptor);
|
dawn::Texture uintTexture = device.CreateTexture(&descriptor);
|
||||||
dawn::TextureView uintTextureView = uintTexture.CreateDefaultView();
|
dawn::TextureView uintTextureView = uintTexture.CreateDefaultView();
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ TEST_F(BindGroupValidationTest, BufferBindingOOB) {
|
||||||
|
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 1024;
|
descriptor.size = 1024;
|
||||||
descriptor.usage = dawn::BufferUsageBit::Uniform;
|
descriptor.usage = dawn::BufferUsage::Uniform;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
// Success case, touching the start of the buffer works
|
// Success case, touching the start of the buffer works
|
||||||
|
@ -602,7 +602,7 @@ class SetBindGroupValidationTest : public ValidationTest {
|
||||||
dawn::BindingType::StorageBuffer, true}});
|
dawn::BindingType::StorageBuffer, true}});
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::Buffer CreateBuffer(uint64_t bufferSize, dawn::BufferUsageBit usage) {
|
dawn::Buffer CreateBuffer(uint64_t bufferSize, dawn::BufferUsage usage) {
|
||||||
dawn::BufferDescriptor bufferDescriptor;
|
dawn::BufferDescriptor bufferDescriptor;
|
||||||
bufferDescriptor.size = bufferSize;
|
bufferDescriptor.size = bufferSize;
|
||||||
bufferDescriptor.usage = usage;
|
bufferDescriptor.usage = usage;
|
||||||
|
@ -717,8 +717,8 @@ class SetBindGroupValidationTest : public ValidationTest {
|
||||||
// This is the test case that should work.
|
// This is the test case that should work.
|
||||||
TEST_F(SetBindGroupValidationTest, Basic) {
|
TEST_F(SetBindGroupValidationTest, Basic) {
|
||||||
// Set up the bind group.
|
// Set up the bind group.
|
||||||
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Uniform);
|
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform);
|
||||||
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Storage);
|
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage);
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
||||||
device, mBindGroupLayout,
|
device, mBindGroupLayout,
|
||||||
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
||||||
|
@ -733,8 +733,8 @@ TEST_F(SetBindGroupValidationTest, Basic) {
|
||||||
// Test cases that test dynamic offsets count mismatch with bind group layout.
|
// Test cases that test dynamic offsets count mismatch with bind group layout.
|
||||||
TEST_F(SetBindGroupValidationTest, DynamicOffsetsMismatch) {
|
TEST_F(SetBindGroupValidationTest, DynamicOffsetsMismatch) {
|
||||||
// Set up bind group.
|
// Set up bind group.
|
||||||
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Uniform);
|
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform);
|
||||||
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Storage);
|
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage);
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
||||||
device, mBindGroupLayout,
|
device, mBindGroupLayout,
|
||||||
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
||||||
|
@ -750,8 +750,8 @@ TEST_F(SetBindGroupValidationTest, DynamicOffsetsMismatch) {
|
||||||
// Test cases that test dynamic offsets not aligned
|
// Test cases that test dynamic offsets not aligned
|
||||||
TEST_F(SetBindGroupValidationTest, DynamicOffsetsNotAligned) {
|
TEST_F(SetBindGroupValidationTest, DynamicOffsetsNotAligned) {
|
||||||
// Set up bind group.
|
// Set up bind group.
|
||||||
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Uniform);
|
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform);
|
||||||
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Storage);
|
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage);
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
||||||
device, mBindGroupLayout,
|
device, mBindGroupLayout,
|
||||||
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
||||||
|
@ -767,8 +767,8 @@ TEST_F(SetBindGroupValidationTest, DynamicOffsetsNotAligned) {
|
||||||
// Test cases that test dynamic uniform buffer out of bound situation.
|
// Test cases that test dynamic uniform buffer out of bound situation.
|
||||||
TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicUniformBuffer) {
|
TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicUniformBuffer) {
|
||||||
// Set up bind group.
|
// Set up bind group.
|
||||||
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Uniform);
|
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform);
|
||||||
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Storage);
|
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage);
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
||||||
device, mBindGroupLayout,
|
device, mBindGroupLayout,
|
||||||
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
||||||
|
@ -784,8 +784,8 @@ TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicUniformBuffer) {
|
||||||
// Test cases that test dynamic storage buffer out of bound situation.
|
// Test cases that test dynamic storage buffer out of bound situation.
|
||||||
TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicStorageBuffer) {
|
TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicStorageBuffer) {
|
||||||
// Set up bind group.
|
// Set up bind group.
|
||||||
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Uniform);
|
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform);
|
||||||
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Storage);
|
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage);
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
||||||
device, mBindGroupLayout,
|
device, mBindGroupLayout,
|
||||||
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
||||||
|
@ -801,8 +801,8 @@ TEST_F(SetBindGroupValidationTest, OffsetOutOfBoundDynamicStorageBuffer) {
|
||||||
// Test cases that test dynamic uniform buffer out of bound situation because of binding size.
|
// Test cases that test dynamic uniform buffer out of bound situation because of binding size.
|
||||||
TEST_F(SetBindGroupValidationTest, BindingSizeOutOfBoundDynamicUniformBuffer) {
|
TEST_F(SetBindGroupValidationTest, BindingSizeOutOfBoundDynamicUniformBuffer) {
|
||||||
// Set up bind group, but binding size is larger than
|
// Set up bind group, but binding size is larger than
|
||||||
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Uniform);
|
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform);
|
||||||
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Storage);
|
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage);
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
||||||
device, mBindGroupLayout,
|
device, mBindGroupLayout,
|
||||||
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
||||||
|
@ -818,8 +818,8 @@ TEST_F(SetBindGroupValidationTest, BindingSizeOutOfBoundDynamicUniformBuffer) {
|
||||||
|
|
||||||
// Test cases that test dynamic storage buffer out of bound situation because of binding size.
|
// Test cases that test dynamic storage buffer out of bound situation because of binding size.
|
||||||
TEST_F(SetBindGroupValidationTest, BindingSizeOutOfBoundDynamicStorageBuffer) {
|
TEST_F(SetBindGroupValidationTest, BindingSizeOutOfBoundDynamicStorageBuffer) {
|
||||||
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Uniform);
|
dawn::Buffer uniformBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Uniform);
|
||||||
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsageBit::Storage);
|
dawn::Buffer storageBuffer = CreateBuffer(kBufferSize, dawn::BufferUsage::Storage);
|
||||||
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
dawn::BindGroup bindGroup = utils::MakeBindGroup(
|
||||||
device, mBindGroupLayout,
|
device, mBindGroupLayout,
|
||||||
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
{{0, uniformBuffer, 0, kBindingSize}, {1, storageBuffer, 0, kBindingSize}});
|
||||||
|
|
|
@ -63,27 +63,26 @@ class BufferValidationTest : public ValidationTest {
|
||||||
dawn::Buffer CreateMapReadBuffer(uint64_t size) {
|
dawn::Buffer CreateMapReadBuffer(uint64_t size) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = size;
|
descriptor.size = size;
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapRead;
|
descriptor.usage = dawn::BufferUsage::MapRead;
|
||||||
|
|
||||||
return device.CreateBuffer(&descriptor);
|
return device.CreateBuffer(&descriptor);
|
||||||
}
|
}
|
||||||
dawn::Buffer CreateMapWriteBuffer(uint64_t size) {
|
dawn::Buffer CreateMapWriteBuffer(uint64_t size) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = size;
|
descriptor.size = size;
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapWrite;
|
descriptor.usage = dawn::BufferUsage::MapWrite;
|
||||||
|
|
||||||
return device.CreateBuffer(&descriptor);
|
return device.CreateBuffer(&descriptor);
|
||||||
}
|
}
|
||||||
dawn::Buffer CreateSetSubDataBuffer(uint64_t size) {
|
dawn::Buffer CreateSetSubDataBuffer(uint64_t size) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = size;
|
descriptor.size = size;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::CopyDst;
|
||||||
|
|
||||||
return device.CreateBuffer(&descriptor);
|
return device.CreateBuffer(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CreateBufferMappedResult CreateBufferMapped(uint64_t size,
|
dawn::CreateBufferMappedResult CreateBufferMapped(uint64_t size, dawn::BufferUsage usage) {
|
||||||
dawn::BufferUsageBit usage) {
|
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = size;
|
descriptor.size = size;
|
||||||
descriptor.usage = usage;
|
descriptor.usage = usage;
|
||||||
|
@ -117,7 +116,7 @@ TEST_F(BufferValidationTest, CreationSuccess) {
|
||||||
{
|
{
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::Uniform;
|
descriptor.usage = dawn::BufferUsage::Uniform;
|
||||||
|
|
||||||
device.CreateBuffer(&descriptor);
|
device.CreateBuffer(&descriptor);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +128,7 @@ TEST_F(BufferValidationTest, CreationMapUsageRestrictions) {
|
||||||
{
|
{
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::MapRead | dawn::BufferUsage::CopyDst;
|
||||||
|
|
||||||
device.CreateBuffer(&descriptor);
|
device.CreateBuffer(&descriptor);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +137,7 @@ TEST_F(BufferValidationTest, CreationMapUsageRestrictions) {
|
||||||
{
|
{
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::Uniform;
|
descriptor.usage = dawn::BufferUsage::MapRead | dawn::BufferUsage::Uniform;
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor));
|
||||||
}
|
}
|
||||||
|
@ -147,7 +146,7 @@ TEST_F(BufferValidationTest, CreationMapUsageRestrictions) {
|
||||||
{
|
{
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc;
|
descriptor.usage = dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc;
|
||||||
|
|
||||||
device.CreateBuffer(&descriptor);
|
device.CreateBuffer(&descriptor);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +155,7 @@ TEST_F(BufferValidationTest, CreationMapUsageRestrictions) {
|
||||||
{
|
{
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::Uniform;
|
descriptor.usage = dawn::BufferUsage::MapWrite | dawn::BufferUsage::Uniform;
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor));
|
||||||
}
|
}
|
||||||
|
@ -192,7 +191,7 @@ TEST_F(BufferValidationTest, MapWriteSuccess) {
|
||||||
|
|
||||||
// Test the success case for CreateBufferMapped
|
// Test the success case for CreateBufferMapped
|
||||||
TEST_F(BufferValidationTest, CreateBufferMappedSuccess) {
|
TEST_F(BufferValidationTest, CreateBufferMappedSuccess) {
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMapped(4, dawn::BufferUsageBit::MapWrite);
|
dawn::CreateBufferMappedResult result = CreateBufferMapped(4, dawn::BufferUsage::MapWrite);
|
||||||
ASSERT_NE(result.data, nullptr);
|
ASSERT_NE(result.data, nullptr);
|
||||||
ASSERT_EQ(result.dataLength, 4u);
|
ASSERT_EQ(result.dataLength, 4u);
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
@ -200,7 +199,7 @@ TEST_F(BufferValidationTest, CreateBufferMappedSuccess) {
|
||||||
|
|
||||||
// Test the success case for non-mappable CreateBufferMapped
|
// Test the success case for non-mappable CreateBufferMapped
|
||||||
TEST_F(BufferValidationTest, NonMappableCreateBufferMappedSuccess) {
|
TEST_F(BufferValidationTest, NonMappableCreateBufferMappedSuccess) {
|
||||||
dawn::CreateBufferMappedResult result = CreateBufferMapped(4, dawn::BufferUsageBit::CopySrc);
|
dawn::CreateBufferMappedResult result = CreateBufferMapped(4, dawn::BufferUsage::CopySrc);
|
||||||
ASSERT_NE(result.data, nullptr);
|
ASSERT_NE(result.data, nullptr);
|
||||||
ASSERT_EQ(result.dataLength, 4u);
|
ASSERT_EQ(result.dataLength, 4u);
|
||||||
result.buffer.Unmap();
|
result.buffer.Unmap();
|
||||||
|
@ -210,7 +209,7 @@ TEST_F(BufferValidationTest, NonMappableCreateBufferMappedSuccess) {
|
||||||
TEST_F(BufferValidationTest, MapReadWrongUsage) {
|
TEST_F(BufferValidationTest, MapReadWrongUsage) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::CopyDst;
|
||||||
|
|
||||||
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
|
@ -225,7 +224,7 @@ TEST_F(BufferValidationTest, MapReadWrongUsage) {
|
||||||
TEST_F(BufferValidationTest, MapWriteWrongUsage) {
|
TEST_F(BufferValidationTest, MapWriteWrongUsage) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopySrc;
|
descriptor.usage = dawn::BufferUsage::CopySrc;
|
||||||
|
|
||||||
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
|
@ -467,7 +466,7 @@ TEST_F(BufferValidationTest, SetSubDataOutOfBoundsOverflow) {
|
||||||
TEST_F(BufferValidationTest, SetSubDataWrongUsage) {
|
TEST_F(BufferValidationTest, SetSubDataWrongUsage) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::Vertex;
|
descriptor.usage = dawn::BufferUsage::Vertex;
|
||||||
|
|
||||||
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
|
@ -479,7 +478,7 @@ TEST_F(BufferValidationTest, SetSubDataWrongUsage) {
|
||||||
TEST_F(BufferValidationTest, SetSubDataWithUnalignedSize) {
|
TEST_F(BufferValidationTest, SetSubDataWithUnalignedSize) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
|
|
||||||
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
|
@ -491,7 +490,7 @@ TEST_F(BufferValidationTest, SetSubDataWithUnalignedSize) {
|
||||||
TEST_F(BufferValidationTest, SetSubDataWithUnalignedOffset) {
|
TEST_F(BufferValidationTest, SetSubDataWithUnalignedOffset) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4000;
|
descriptor.size = 4000;
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
|
|
||||||
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
dawn::Buffer buf = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
|
@ -612,12 +611,12 @@ TEST_F(BufferValidationTest, MapMappedBuffer) {
|
||||||
// Test that is is invalid to Map a CreateBufferMapped buffer
|
// Test that is is invalid to Map a CreateBufferMapped buffer
|
||||||
TEST_F(BufferValidationTest, MapCreateBufferMappedBuffer) {
|
TEST_F(BufferValidationTest, MapCreateBufferMappedBuffer) {
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateBufferMapped(4, dawn::BufferUsageBit::MapRead).buffer;
|
dawn::Buffer buf = CreateBufferMapped(4, dawn::BufferUsage::MapRead).buffer;
|
||||||
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr));
|
ASSERT_DEVICE_ERROR(buf.MapReadAsync(ToMockBufferMapReadCallback, nullptr));
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
dawn::Buffer buf = CreateBufferMapped(4, dawn::BufferUsageBit::MapWrite).buffer;
|
dawn::Buffer buf = CreateBufferMapped(4, dawn::BufferUsage::MapWrite).buffer;
|
||||||
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr));
|
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(ToMockBufferMapWriteCallback, nullptr));
|
||||||
queue.Submit(0, nullptr);
|
queue.Submit(0, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -645,11 +644,11 @@ TEST_F(BufferValidationTest, SetSubDataMappedBuffer) {
|
||||||
TEST_F(BufferValidationTest, SubmitBufferWithMapUsage) {
|
TEST_F(BufferValidationTest, SubmitBufferWithMapUsage) {
|
||||||
dawn::BufferDescriptor descriptorA;
|
dawn::BufferDescriptor descriptorA;
|
||||||
descriptorA.size = 4;
|
descriptorA.size = 4;
|
||||||
descriptorA.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::MapWrite;
|
descriptorA.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::MapWrite;
|
||||||
|
|
||||||
dawn::BufferDescriptor descriptorB;
|
dawn::BufferDescriptor descriptorB;
|
||||||
descriptorB.size = 4;
|
descriptorB.size = 4;
|
||||||
descriptorB.usage = dawn::BufferUsageBit::CopyDst | dawn::BufferUsageBit::MapRead;
|
descriptorB.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::MapRead;
|
||||||
|
|
||||||
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
||||||
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
||||||
|
@ -664,11 +663,11 @@ TEST_F(BufferValidationTest, SubmitBufferWithMapUsage) {
|
||||||
TEST_F(BufferValidationTest, SubmitMappedBuffer) {
|
TEST_F(BufferValidationTest, SubmitMappedBuffer) {
|
||||||
dawn::BufferDescriptor descriptorA;
|
dawn::BufferDescriptor descriptorA;
|
||||||
descriptorA.size = 4;
|
descriptorA.size = 4;
|
||||||
descriptorA.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::MapWrite;
|
descriptorA.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::MapWrite;
|
||||||
|
|
||||||
dawn::BufferDescriptor descriptorB;
|
dawn::BufferDescriptor descriptorB;
|
||||||
descriptorB.size = 4;
|
descriptorB.size = 4;
|
||||||
descriptorB.usage = dawn::BufferUsageBit::CopyDst | dawn::BufferUsageBit::MapRead;
|
descriptorB.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::MapRead;
|
||||||
{
|
{
|
||||||
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
||||||
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
||||||
|
@ -719,11 +718,11 @@ TEST_F(BufferValidationTest, SubmitMappedBuffer) {
|
||||||
TEST_F(BufferValidationTest, SubmitDestroyedBuffer) {
|
TEST_F(BufferValidationTest, SubmitDestroyedBuffer) {
|
||||||
dawn::BufferDescriptor descriptorA;
|
dawn::BufferDescriptor descriptorA;
|
||||||
descriptorA.size = 4;
|
descriptorA.size = 4;
|
||||||
descriptorA.usage = dawn::BufferUsageBit::CopySrc;
|
descriptorA.usage = dawn::BufferUsage::CopySrc;
|
||||||
|
|
||||||
dawn::BufferDescriptor descriptorB;
|
dawn::BufferDescriptor descriptorB;
|
||||||
descriptorB.size = 4;
|
descriptorB.size = 4;
|
||||||
descriptorB.usage = dawn::BufferUsageBit::CopyDst;
|
descriptorB.usage = dawn::BufferUsage::CopyDst;
|
||||||
|
|
||||||
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
dawn::Buffer bufA = device.CreateBuffer(&descriptorA);
|
||||||
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
dawn::Buffer bufB = device.CreateBuffer(&descriptorB);
|
||||||
|
|
|
@ -152,7 +152,7 @@ TEST_F(CommandBufferValidationTest, CallsAfterASuccessfulFinish) {
|
||||||
// A buffer that can be used in CopyBufferToBuffer
|
// A buffer that can be used in CopyBufferToBuffer
|
||||||
dawn::BufferDescriptor copyBufferDesc;
|
dawn::BufferDescriptor copyBufferDesc;
|
||||||
copyBufferDesc.size = 16;
|
copyBufferDesc.size = 16;
|
||||||
copyBufferDesc.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
copyBufferDesc.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer copyBuffer = device.CreateBuffer(©BufferDesc);
|
dawn::Buffer copyBuffer = device.CreateBuffer(©BufferDesc);
|
||||||
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
@ -166,13 +166,13 @@ TEST_F(CommandBufferValidationTest, CallsAfterAFailedFinish) {
|
||||||
// A buffer that can be used in CopyBufferToBuffer
|
// A buffer that can be used in CopyBufferToBuffer
|
||||||
dawn::BufferDescriptor copyBufferDesc;
|
dawn::BufferDescriptor copyBufferDesc;
|
||||||
copyBufferDesc.size = 16;
|
copyBufferDesc.size = 16;
|
||||||
copyBufferDesc.usage = dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst;
|
copyBufferDesc.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer copyBuffer = device.CreateBuffer(©BufferDesc);
|
dawn::Buffer copyBuffer = device.CreateBuffer(©BufferDesc);
|
||||||
|
|
||||||
// A buffer that can't be used in CopyBufferToBuffer
|
// A buffer that can't be used in CopyBufferToBuffer
|
||||||
dawn::BufferDescriptor bufferDesc;
|
dawn::BufferDescriptor bufferDesc;
|
||||||
bufferDesc.size = 16;
|
bufferDesc.size = 16;
|
||||||
bufferDesc.usage = dawn::BufferUsageBit::Uniform;
|
bufferDesc.usage = dawn::BufferUsage::Uniform;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&bufferDesc);
|
dawn::Buffer buffer = device.CreateBuffer(&bufferDesc);
|
||||||
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
@ -186,7 +186,7 @@ TEST_F(CommandBufferValidationTest, CallsAfterAFailedFinish) {
|
||||||
TEST_F(CommandBufferValidationTest, BufferWithMultipleReadUsage) {
|
TEST_F(CommandBufferValidationTest, BufferWithMultipleReadUsage) {
|
||||||
// Create a buffer used as both vertex and index buffer.
|
// Create a buffer used as both vertex and index buffer.
|
||||||
dawn::BufferDescriptor bufferDescriptor;
|
dawn::BufferDescriptor bufferDescriptor;
|
||||||
bufferDescriptor.usage = dawn::BufferUsageBit::Vertex | dawn::BufferUsageBit::Index;
|
bufferDescriptor.usage = dawn::BufferUsage::Vertex | dawn::BufferUsage::Index;
|
||||||
bufferDescriptor.size = 4;
|
bufferDescriptor.size = 4;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&bufferDescriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&bufferDescriptor);
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ TEST_F(CommandBufferValidationTest, BufferWithMultipleReadUsage) {
|
||||||
TEST_F(CommandBufferValidationTest, BufferWithReadAndWriteUsage) {
|
TEST_F(CommandBufferValidationTest, BufferWithReadAndWriteUsage) {
|
||||||
// Create a buffer that will be used as an index buffer and as a storage buffer
|
// Create a buffer that will be used as an index buffer and as a storage buffer
|
||||||
dawn::BufferDescriptor bufferDescriptor;
|
dawn::BufferDescriptor bufferDescriptor;
|
||||||
bufferDescriptor.usage = dawn::BufferUsageBit::Storage | dawn::BufferUsageBit::Index;
|
bufferDescriptor.usage = dawn::BufferUsage::Storage | dawn::BufferUsage::Index;
|
||||||
bufferDescriptor.size = 4;
|
bufferDescriptor.size = 4;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&bufferDescriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&bufferDescriptor);
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ TEST_F(CommandBufferValidationTest, BufferWithReadAndWriteUsage) {
|
||||||
TEST_F(CommandBufferValidationTest, TextureWithReadAndWriteUsage) {
|
TEST_F(CommandBufferValidationTest, TextureWithReadAndWriteUsage) {
|
||||||
// Create a texture that will be used both as a sampled texture and a render target
|
// Create a texture that will be used both as a sampled texture and a render target
|
||||||
dawn::TextureDescriptor textureDescriptor;
|
dawn::TextureDescriptor textureDescriptor;
|
||||||
textureDescriptor.usage = dawn::TextureUsageBit::Sampled | dawn::TextureUsageBit::OutputAttachment;
|
textureDescriptor.usage = dawn::TextureUsage::Sampled | dawn::TextureUsage::OutputAttachment;
|
||||||
textureDescriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
textureDescriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
textureDescriptor.dimension = dawn::TextureDimension::e2D;
|
textureDescriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
textureDescriptor.size = {1, 1, 1};
|
textureDescriptor.size = {1, 1, 1};
|
||||||
|
|
|
@ -54,8 +54,8 @@ class ComputeIndirectValidationTest : public ValidationTest {
|
||||||
void TestIndirectOffset(utils::Expectation expectation,
|
void TestIndirectOffset(utils::Expectation expectation,
|
||||||
std::initializer_list<uint32_t> bufferList,
|
std::initializer_list<uint32_t> bufferList,
|
||||||
uint64_t indirectOffset) {
|
uint64_t indirectOffset) {
|
||||||
dawn::Buffer indirectBuffer = utils::CreateBufferFromData<uint32_t>(
|
dawn::Buffer indirectBuffer =
|
||||||
device, dawn::BufferUsageBit::Indirect, bufferList);
|
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Indirect, bufferList);
|
||||||
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
class CopyCommandTest : public ValidationTest {
|
class CopyCommandTest : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
dawn::Buffer CreateBuffer(uint64_t size, dawn::BufferUsageBit usage) {
|
dawn::Buffer CreateBuffer(uint64_t size, dawn::BufferUsage usage) {
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.size = size;
|
descriptor.size = size;
|
||||||
descriptor.usage = usage;
|
descriptor.usage = usage;
|
||||||
|
@ -33,7 +33,7 @@ class CopyCommandTest : public ValidationTest {
|
||||||
uint32_t mipLevelCount,
|
uint32_t mipLevelCount,
|
||||||
uint32_t arrayLayerCount,
|
uint32_t arrayLayerCount,
|
||||||
dawn::TextureFormat format,
|
dawn::TextureFormat format,
|
||||||
dawn::TextureUsageBit usage,
|
dawn::TextureUsage usage,
|
||||||
uint32_t sampleCount = 1) {
|
uint32_t sampleCount = 1) {
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
|
@ -150,8 +150,8 @@ class CopyCommandTest_B2B : public CopyCommandTest {};
|
||||||
|
|
||||||
// Test a successfull B2B copy
|
// Test a successfull B2B copy
|
||||||
TEST_F(CopyCommandTest_B2B, Success) {
|
TEST_F(CopyCommandTest_B2B, Success) {
|
||||||
dawn::Buffer source = CreateBuffer(16, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(16, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Buffer destination = CreateBuffer(16, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(16, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
// Copy different copies, including some that touch the OOB condition
|
// Copy different copies, including some that touch the OOB condition
|
||||||
{
|
{
|
||||||
|
@ -174,8 +174,8 @@ TEST_F(CopyCommandTest_B2B, Success) {
|
||||||
|
|
||||||
// Test B2B copies with OOB
|
// Test B2B copies with OOB
|
||||||
TEST_F(CopyCommandTest_B2B, OutOfBounds) {
|
TEST_F(CopyCommandTest_B2B, OutOfBounds) {
|
||||||
dawn::Buffer source = CreateBuffer(16, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(16, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Buffer destination = CreateBuffer(16, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(16, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
// OOB on the source
|
// OOB on the source
|
||||||
{
|
{
|
||||||
|
@ -194,9 +194,9 @@ TEST_F(CopyCommandTest_B2B, OutOfBounds) {
|
||||||
|
|
||||||
// Test B2B copies with incorrect buffer usage
|
// Test B2B copies with incorrect buffer usage
|
||||||
TEST_F(CopyCommandTest_B2B, BadUsage) {
|
TEST_F(CopyCommandTest_B2B, BadUsage) {
|
||||||
dawn::Buffer source = CreateBuffer(16, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(16, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Buffer destination = CreateBuffer(16, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(16, dawn::BufferUsage::CopyDst);
|
||||||
dawn::Buffer vertex = CreateBuffer(16, dawn::BufferUsageBit::Vertex);
|
dawn::Buffer vertex = CreateBuffer(16, dawn::BufferUsage::Vertex);
|
||||||
|
|
||||||
// Source with incorrect usage
|
// Source with incorrect usage
|
||||||
{
|
{
|
||||||
|
@ -215,8 +215,8 @@ TEST_F(CopyCommandTest_B2B, BadUsage) {
|
||||||
|
|
||||||
// Test B2B copies with unaligned data size
|
// Test B2B copies with unaligned data size
|
||||||
TEST_F(CopyCommandTest_B2B, UnalignedSize) {
|
TEST_F(CopyCommandTest_B2B, UnalignedSize) {
|
||||||
dawn::Buffer source = CreateBuffer(16, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(16, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Buffer destination = CreateBuffer(16, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(16, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
encoder.CopyBufferToBuffer(source, 8, destination, 0, sizeof(uint8_t));
|
encoder.CopyBufferToBuffer(source, 8, destination, 0, sizeof(uint8_t));
|
||||||
|
@ -225,8 +225,8 @@ TEST_F(CopyCommandTest_B2B, UnalignedSize) {
|
||||||
|
|
||||||
// Test B2B copies with unaligned offset
|
// Test B2B copies with unaligned offset
|
||||||
TEST_F(CopyCommandTest_B2B, UnalignedOffset) {
|
TEST_F(CopyCommandTest_B2B, UnalignedOffset) {
|
||||||
dawn::Buffer source = CreateBuffer(16, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(16, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Buffer destination = CreateBuffer(16, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(16, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
// Unaligned source offset
|
// Unaligned source offset
|
||||||
{
|
{
|
||||||
|
@ -247,11 +247,11 @@ TEST_F(CopyCommandTest_B2B, UnalignedOffset) {
|
||||||
TEST_F(CopyCommandTest_B2B, BuffersInErrorState) {
|
TEST_F(CopyCommandTest_B2B, BuffersInErrorState) {
|
||||||
dawn::BufferDescriptor errorBufferDescriptor;
|
dawn::BufferDescriptor errorBufferDescriptor;
|
||||||
errorBufferDescriptor.size = 4;
|
errorBufferDescriptor.size = 4;
|
||||||
errorBufferDescriptor.usage = dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::CopySrc;
|
errorBufferDescriptor.usage = dawn::BufferUsage::MapRead | dawn::BufferUsage::CopySrc;
|
||||||
ASSERT_DEVICE_ERROR(dawn::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor));
|
ASSERT_DEVICE_ERROR(dawn::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor));
|
||||||
|
|
||||||
constexpr uint64_t bufferSize = 4;
|
constexpr uint64_t bufferSize = 4;
|
||||||
dawn::Buffer validBuffer = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer validBuffer = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
|
|
||||||
{
|
{
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
@ -271,9 +271,9 @@ class CopyCommandTest_B2T : public CopyCommandTest {};
|
||||||
// Test a successfull B2T copy
|
// Test a successfull B2T copy
|
||||||
TEST_F(CopyCommandTest_B2T, Success) {
|
TEST_F(CopyCommandTest_B2T, Success) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Different copies, including some that touch the OOB condition
|
// Different copies, including some that touch the OOB condition
|
||||||
{
|
{
|
||||||
|
@ -324,9 +324,9 @@ TEST_F(CopyCommandTest_B2T, Success) {
|
||||||
// Test OOB conditions on the buffer
|
// Test OOB conditions on the buffer
|
||||||
TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {
|
TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// OOB on the buffer because we copy too many pixels
|
// OOB on the buffer because we copy too many pixels
|
||||||
TestB2TCopy(utils::Expectation::Failure, source, 0, 256, 0, destination, 0, 0, {0, 0, 0},
|
TestB2TCopy(utils::Expectation::Failure, source, 0, 256, 0, destination, 0, 0, {0, 0, 0},
|
||||||
|
@ -346,7 +346,7 @@ TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {
|
||||||
{
|
{
|
||||||
uint32_t sourceBufferSize = BufferSizeForTextureCopy(7, 3, 1);
|
uint32_t sourceBufferSize = BufferSizeForTextureCopy(7, 3, 1);
|
||||||
ASSERT_TRUE(256 * 3 > sourceBufferSize) << "row pitch * height should overflow buffer";
|
ASSERT_TRUE(256 * 3 > sourceBufferSize) << "row pitch * height should overflow buffer";
|
||||||
dawn::Buffer sourceBuffer = CreateBuffer(sourceBufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer sourceBuffer = CreateBuffer(sourceBufferSize, dawn::BufferUsage::CopySrc);
|
||||||
|
|
||||||
TestB2TCopy(utils::Expectation::Success, source, 0, 256, 0, destination, 0, 0, {0, 0, 0},
|
TestB2TCopy(utils::Expectation::Success, source, 0, 256, 0, destination, 0, 0, {0, 0, 0},
|
||||||
{7, 3, 1});
|
{7, 3, 1});
|
||||||
|
@ -356,9 +356,9 @@ TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {
|
||||||
// Test OOB conditions on the texture
|
// Test OOB conditions on the texture
|
||||||
TEST_F(CopyCommandTest_B2T, OutOfBoundsOnTexture) {
|
TEST_F(CopyCommandTest_B2T, OutOfBoundsOnTexture) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// OOB on the texture because x + width overflows
|
// OOB on the texture because x + width overflows
|
||||||
TestB2TCopy(utils::Expectation::Failure, source, 0, 256, 0, destination, 0, 0, {13, 12, 0},
|
TestB2TCopy(utils::Expectation::Failure, source, 0, 256, 0, destination, 0, 0, {13, 12, 0},
|
||||||
|
@ -383,9 +383,9 @@ TEST_F(CopyCommandTest_B2T, OutOfBoundsOnTexture) {
|
||||||
|
|
||||||
// Test that we force Z=0 and Depth=1 on copies to 2D textures
|
// Test that we force Z=0 and Depth=1 on copies to 2D textures
|
||||||
TEST_F(CopyCommandTest_B2T, ZDepthConstraintFor2DTextures) {
|
TEST_F(CopyCommandTest_B2T, ZDepthConstraintFor2DTextures) {
|
||||||
dawn::Buffer source = CreateBuffer(16 * 4, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(16 * 4, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Z=1 on an empty copy still errors
|
// Z=1 on an empty copy still errors
|
||||||
TestB2TCopy(utils::Expectation::Failure, source, 0, 0, 0, destination, 0, 0, {0, 0, 1},
|
TestB2TCopy(utils::Expectation::Failure, source, 0, 0, 0, destination, 0, 0, {0, 0, 1},
|
||||||
|
@ -398,12 +398,12 @@ TEST_F(CopyCommandTest_B2T, ZDepthConstraintFor2DTextures) {
|
||||||
|
|
||||||
// Test B2T copies with incorrect buffer usage
|
// Test B2T copies with incorrect buffer usage
|
||||||
TEST_F(CopyCommandTest_B2T, IncorrectUsage) {
|
TEST_F(CopyCommandTest_B2T, IncorrectUsage) {
|
||||||
dawn::Buffer source = CreateBuffer(16 * 4, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(16 * 4, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Buffer vertex = CreateBuffer(16 * 4, dawn::BufferUsageBit::Vertex);
|
dawn::Buffer vertex = CreateBuffer(16 * 4, dawn::BufferUsage::Vertex);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
dawn::Texture sampled = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture sampled =
|
||||||
dawn::TextureUsageBit::Sampled);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::Sampled);
|
||||||
|
|
||||||
// Incorrect source usage
|
// Incorrect source usage
|
||||||
TestB2TCopy(utils::Expectation::Failure, vertex, 0, 256, 0, destination, 0, 0, {0, 0, 0},
|
TestB2TCopy(utils::Expectation::Failure, vertex, 0, 256, 0, destination, 0, 0, {0, 0, 0},
|
||||||
|
@ -416,9 +416,9 @@ TEST_F(CopyCommandTest_B2T, IncorrectUsage) {
|
||||||
|
|
||||||
TEST_F(CopyCommandTest_B2T, IncorrectRowPitch) {
|
TEST_F(CopyCommandTest_B2T, IncorrectRowPitch) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
|
||||||
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(128, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination = Create2DTexture(128, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
||||||
dawn::TextureUsageBit::CopyDst);
|
dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Default row pitch is not 256-byte aligned
|
// Default row pitch is not 256-byte aligned
|
||||||
TestB2TCopy(utils::Expectation::Failure, source, 0, 0, 0, destination, 0, 0, {0, 0, 0},
|
TestB2TCopy(utils::Expectation::Failure, source, 0, 0, 0, destination, 0, 0, {0, 0, 0},
|
||||||
|
@ -435,9 +435,9 @@ TEST_F(CopyCommandTest_B2T, IncorrectRowPitch) {
|
||||||
|
|
||||||
TEST_F(CopyCommandTest_B2T, ImageHeightConstraint) {
|
TEST_F(CopyCommandTest_B2T, ImageHeightConstraint) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(5, 5, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(5, 5, 1);
|
||||||
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Image height is zero (Valid)
|
// Image height is zero (Valid)
|
||||||
TestB2TCopy(utils::Expectation::Success, source, 0, 256, 0, destination, 0, 0, {0, 0, 0},
|
TestB2TCopy(utils::Expectation::Success, source, 0, 256, 0, destination, 0, 0, {0, 0, 0},
|
||||||
|
@ -459,9 +459,9 @@ TEST_F(CopyCommandTest_B2T, ImageHeightConstraint) {
|
||||||
// Test B2T copies with incorrect buffer offset usage
|
// Test B2T copies with incorrect buffer offset usage
|
||||||
TEST_F(CopyCommandTest_B2T, IncorrectBufferOffset) {
|
TEST_F(CopyCommandTest_B2T, IncorrectBufferOffset) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Correct usage
|
// Correct usage
|
||||||
TestB2TCopy(utils::Expectation::Success, source, bufferSize - 4, 256, 0, destination, 0, 0,
|
TestB2TCopy(utils::Expectation::Success, source, bufferSize - 4, 256, 0, destination, 0, 0,
|
||||||
|
@ -481,9 +481,9 @@ TEST_F(CopyCommandTest_B2T, IncorrectBufferOffset) {
|
||||||
// Test multisampled textures cannot be used in B2T copies.
|
// Test multisampled textures cannot be used in B2T copies.
|
||||||
TEST_F(CopyCommandTest_B2T, CopyToMultisampledTexture) {
|
TEST_F(CopyCommandTest_B2T, CopyToMultisampledTexture) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(16, 16, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(16, 16, 1);
|
||||||
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(2, 2, 1, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination = Create2DTexture(2, 2, 1, 1, dawn::TextureFormat::RGBA8Unorm,
|
||||||
dawn::TextureUsageBit::CopyDst, 4);
|
dawn::TextureUsage::CopyDst, 4);
|
||||||
|
|
||||||
TestB2TCopy(utils::Expectation::Failure, source, 0, 256, 0, destination, 0, 0, {0, 0, 0},
|
TestB2TCopy(utils::Expectation::Failure, source, 0, 256, 0, destination, 0, 0, {0, 0, 0},
|
||||||
{2, 2, 1});
|
{2, 2, 1});
|
||||||
|
@ -493,7 +493,7 @@ TEST_F(CopyCommandTest_B2T, CopyToMultisampledTexture) {
|
||||||
TEST_F(CopyCommandTest_B2T, BufferOrTextureInErrorState) {
|
TEST_F(CopyCommandTest_B2T, BufferOrTextureInErrorState) {
|
||||||
dawn::BufferDescriptor errorBufferDescriptor;
|
dawn::BufferDescriptor errorBufferDescriptor;
|
||||||
errorBufferDescriptor.size = 4;
|
errorBufferDescriptor.size = 4;
|
||||||
errorBufferDescriptor.usage = dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::CopySrc;
|
errorBufferDescriptor.usage = dawn::BufferUsage::MapRead | dawn::BufferUsage::CopySrc;
|
||||||
ASSERT_DEVICE_ERROR(dawn::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor));
|
ASSERT_DEVICE_ERROR(dawn::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor));
|
||||||
|
|
||||||
dawn::TextureDescriptor errorTextureDescriptor;
|
dawn::TextureDescriptor errorTextureDescriptor;
|
||||||
|
@ -508,7 +508,7 @@ TEST_F(CopyCommandTest_B2T, BufferOrTextureInErrorState) {
|
||||||
|
|
||||||
{
|
{
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination = Create2DTexture(16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm,
|
||||||
dawn::TextureUsageBit::CopyDst);
|
dawn::TextureUsage::CopyDst);
|
||||||
dawn::TextureCopyView textureCopyView =
|
dawn::TextureCopyView textureCopyView =
|
||||||
utils::CreateTextureCopyView(destination, 0, 0, {1, 1, 1});
|
utils::CreateTextureCopyView(destination, 0, 0, {1, 1, 1});
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ TEST_F(CopyCommandTest_B2T, BufferOrTextureInErrorState) {
|
||||||
|
|
||||||
{
|
{
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
|
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(source, 0, 0, 0);
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(source, 0, 0, 0);
|
||||||
|
|
||||||
|
@ -544,9 +544,9 @@ TEST_F(CopyCommandTest_B2T, TextureCopyBufferSizeLastRowComputation) {
|
||||||
constexpr uint32_t kInvalidBufferSize = kRowPitch * (kHeight - 1) + kWidth;
|
constexpr uint32_t kInvalidBufferSize = kRowPitch * (kHeight - 1) + kWidth;
|
||||||
|
|
||||||
for (dawn::TextureFormat format : kFormats) {
|
for (dawn::TextureFormat format : kFormats) {
|
||||||
dawn::Buffer source = CreateBuffer(kInvalidBufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(kInvalidBufferSize, dawn::BufferUsage::CopySrc);
|
||||||
dawn::Texture destination =
|
dawn::Texture destination =
|
||||||
Create2DTexture(kWidth, kHeight, 1, 1, format, dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(kWidth, kHeight, 1, 1, format, dawn::TextureUsage::CopyDst);
|
||||||
TestB2TCopy(utils::Expectation::Failure, source, 0, kRowPitch, 0, destination, 0, 0,
|
TestB2TCopy(utils::Expectation::Failure, source, 0, kRowPitch, 0, destination, 0, 0,
|
||||||
{0, 0, 0}, {kWidth, kHeight, 1});
|
{0, 0, 0}, {kWidth, kHeight, 1});
|
||||||
}
|
}
|
||||||
|
@ -556,20 +556,19 @@ TEST_F(CopyCommandTest_B2T, TextureCopyBufferSizeLastRowComputation) {
|
||||||
for (dawn::TextureFormat format : kFormats) {
|
for (dawn::TextureFormat format : kFormats) {
|
||||||
uint32_t validBufferSize = BufferSizeForTextureCopy(kWidth, kHeight, 1, format);
|
uint32_t validBufferSize = BufferSizeForTextureCopy(kWidth, kHeight, 1, format);
|
||||||
dawn::Texture destination =
|
dawn::Texture destination =
|
||||||
Create2DTexture(kWidth, kHeight, 1, 1, format, dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(kWidth, kHeight, 1, 1, format, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Verify the return value of BufferSizeForTextureCopy() is exactly the minimum valid
|
// Verify the return value of BufferSizeForTextureCopy() is exactly the minimum valid
|
||||||
// buffer size in this test.
|
// buffer size in this test.
|
||||||
{
|
{
|
||||||
uint32_t invalidBuffferSize = validBufferSize - 1;
|
uint32_t invalidBuffferSize = validBufferSize - 1;
|
||||||
dawn::Buffer source =
|
dawn::Buffer source = CreateBuffer(invalidBuffferSize, dawn::BufferUsage::CopySrc);
|
||||||
CreateBuffer(invalidBuffferSize, dawn::BufferUsageBit::CopySrc);
|
|
||||||
TestB2TCopy(utils::Expectation::Failure, source, 0, kRowPitch, 0, destination, 0, 0,
|
TestB2TCopy(utils::Expectation::Failure, source, 0, kRowPitch, 0, destination, 0, 0,
|
||||||
{0, 0, 0}, {kWidth, kHeight, 1});
|
{0, 0, 0}, {kWidth, kHeight, 1});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
dawn::Buffer source = CreateBuffer(validBufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(validBufferSize, dawn::BufferUsage::CopySrc);
|
||||||
TestB2TCopy(utils::Expectation::Success, source, 0, kRowPitch, 0, destination, 0, 0,
|
TestB2TCopy(utils::Expectation::Success, source, 0, kRowPitch, 0, destination, 0, 0,
|
||||||
{0, 0, 0}, {kWidth, kHeight, 1});
|
{0, 0, 0}, {kWidth, kHeight, 1});
|
||||||
}
|
}
|
||||||
|
@ -580,10 +579,10 @@ TEST_F(CopyCommandTest_B2T, TextureCopyBufferSizeLastRowComputation) {
|
||||||
// Test copy from buffer to mip map of non square texture
|
// Test copy from buffer to mip map of non square texture
|
||||||
TEST_F(CopyCommandTest_B2T, CopyToMipmapOfNonSquareTexture) {
|
TEST_F(CopyCommandTest_B2T, CopyToMipmapOfNonSquareTexture) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 2, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 2, 1);
|
||||||
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
uint32_t maxMipmapLevel = 3;
|
uint32_t maxMipmapLevel = 3;
|
||||||
dawn::Texture destination = Create2DTexture(
|
dawn::Texture destination = Create2DTexture(
|
||||||
4, 2, maxMipmapLevel, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsageBit::CopyDst);
|
4, 2, maxMipmapLevel, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Copy to top level mip map
|
// Copy to top level mip map
|
||||||
TestB2TCopy(utils::Expectation::Success, source, 0, 256, 0, destination, maxMipmapLevel - 1, 0,
|
TestB2TCopy(utils::Expectation::Success, source, 0, 256, 0, destination, maxMipmapLevel - 1, 0,
|
||||||
|
@ -607,9 +606,9 @@ class CopyCommandTest_T2B : public CopyCommandTest {};
|
||||||
// Test a successfull T2B copy
|
// Test a successfull T2B copy
|
||||||
TEST_F(CopyCommandTest_T2B, Success) {
|
TEST_F(CopyCommandTest_T2B, Success) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source =
|
||||||
dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc);
|
||||||
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
// Different copies, including some that touch the OOB condition
|
// Different copies, including some that touch the OOB condition
|
||||||
{
|
{
|
||||||
|
@ -660,9 +659,9 @@ TEST_F(CopyCommandTest_T2B, Success) {
|
||||||
// Test OOB conditions on the texture
|
// Test OOB conditions on the texture
|
||||||
TEST_F(CopyCommandTest_T2B, OutOfBoundsOnTexture) {
|
TEST_F(CopyCommandTest_T2B, OutOfBoundsOnTexture) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source =
|
||||||
dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc);
|
||||||
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
// OOB on the texture because x + width overflows
|
// OOB on the texture because x + width overflows
|
||||||
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {13, 12, 0}, destination, 0, 256, 0,
|
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {13, 12, 0}, destination, 0, 256, 0,
|
||||||
|
@ -684,9 +683,9 @@ TEST_F(CopyCommandTest_T2B, OutOfBoundsOnTexture) {
|
||||||
// Test OOB conditions on the buffer
|
// Test OOB conditions on the buffer
|
||||||
TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) {
|
TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source =
|
||||||
dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc);
|
||||||
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
// OOB on the buffer because we copy too many pixels
|
// OOB on the buffer because we copy too many pixels
|
||||||
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0, 256, 0,
|
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0, 256, 0,
|
||||||
|
@ -707,7 +706,7 @@ TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) {
|
||||||
uint32_t destinationBufferSize = BufferSizeForTextureCopy(7, 3, 1);
|
uint32_t destinationBufferSize = BufferSizeForTextureCopy(7, 3, 1);
|
||||||
ASSERT_TRUE(256 * 3 > destinationBufferSize) << "row pitch * height should overflow buffer";
|
ASSERT_TRUE(256 * 3 > destinationBufferSize) << "row pitch * height should overflow buffer";
|
||||||
dawn::Buffer destinationBuffer =
|
dawn::Buffer destinationBuffer =
|
||||||
CreateBuffer(destinationBufferSize, dawn::BufferUsageBit::CopyDst);
|
CreateBuffer(destinationBufferSize, dawn::BufferUsage::CopyDst);
|
||||||
TestT2BCopy(utils::Expectation::Success, source, 0, 0, {0, 0, 0}, destinationBuffer, 0, 256,
|
TestT2BCopy(utils::Expectation::Success, source, 0, 0, {0, 0, 0}, destinationBuffer, 0, 256,
|
||||||
0, {7, 3, 1});
|
0, {7, 3, 1});
|
||||||
}
|
}
|
||||||
|
@ -716,9 +715,9 @@ TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) {
|
||||||
// Test that we force Z=0 and Depth=1 on copies from to 2D textures
|
// Test that we force Z=0 and Depth=1 on copies from to 2D textures
|
||||||
TEST_F(CopyCommandTest_T2B, ZDepthConstraintFor2DTextures) {
|
TEST_F(CopyCommandTest_T2B, ZDepthConstraintFor2DTextures) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source =
|
||||||
dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc);
|
||||||
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
// Z=1 on an empty copy still errors
|
// Z=1 on an empty copy still errors
|
||||||
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 1}, destination, 0, 0, 0,
|
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 1}, destination, 0, 0, 0,
|
||||||
|
@ -732,12 +731,12 @@ TEST_F(CopyCommandTest_T2B, ZDepthConstraintFor2DTextures) {
|
||||||
// Test T2B copies with incorrect buffer usage
|
// Test T2B copies with incorrect buffer usage
|
||||||
TEST_F(CopyCommandTest_T2B, IncorrectUsage) {
|
TEST_F(CopyCommandTest_T2B, IncorrectUsage) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source =
|
||||||
dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc);
|
||||||
dawn::Texture sampled = Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture sampled =
|
||||||
dawn::TextureUsageBit::Sampled);
|
Create2DTexture(16, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::Sampled);
|
||||||
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsage::CopyDst);
|
||||||
dawn::Buffer vertex = CreateBuffer(bufferSize, dawn::BufferUsageBit::Vertex);
|
dawn::Buffer vertex = CreateBuffer(bufferSize, dawn::BufferUsage::Vertex);
|
||||||
|
|
||||||
// Incorrect source usage
|
// Incorrect source usage
|
||||||
TestT2BCopy(utils::Expectation::Failure, sampled, 0, 0, {0, 0, 0}, destination, 0, 256, 0,
|
TestT2BCopy(utils::Expectation::Failure, sampled, 0, 0, {0, 0, 0}, destination, 0, 256, 0,
|
||||||
|
@ -750,8 +749,8 @@ TEST_F(CopyCommandTest_T2B, IncorrectUsage) {
|
||||||
TEST_F(CopyCommandTest_T2B, IncorrectRowPitch) {
|
TEST_F(CopyCommandTest_T2B, IncorrectRowPitch) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
|
||||||
dawn::Texture source = Create2DTexture(128, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source = Create2DTexture(128, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
||||||
dawn::TextureUsageBit::CopyDst);
|
dawn::TextureUsage::CopyDst);
|
||||||
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
|
|
||||||
// Default row pitch is not 256-byte aligned
|
// Default row pitch is not 256-byte aligned
|
||||||
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0, 256, 0,
|
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0, 256, 0,
|
||||||
|
@ -768,9 +767,9 @@ TEST_F(CopyCommandTest_T2B, IncorrectRowPitch) {
|
||||||
|
|
||||||
TEST_F(CopyCommandTest_T2B, ImageHeightConstraint) {
|
TEST_F(CopyCommandTest_T2B, ImageHeightConstraint) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(5, 5, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(5, 5, 1);
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source =
|
||||||
dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc);
|
||||||
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
// Image height is zero (Valid)
|
// Image height is zero (Valid)
|
||||||
TestT2BCopy(utils::Expectation::Success, source, 0, 0, {0, 0, 0}, destination, 0, 256, 0,
|
TestT2BCopy(utils::Expectation::Success, source, 0, 0, {0, 0, 0}, destination, 0, 256, 0,
|
||||||
|
@ -793,8 +792,8 @@ TEST_F(CopyCommandTest_T2B, ImageHeightConstraint) {
|
||||||
TEST_F(CopyCommandTest_T2B, IncorrectBufferOffset) {
|
TEST_F(CopyCommandTest_T2B, IncorrectBufferOffset) {
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
|
||||||
dawn::Texture source = Create2DTexture(128, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source = Create2DTexture(128, 16, 5, 1, dawn::TextureFormat::RGBA8Unorm,
|
||||||
dawn::TextureUsageBit::CopySrc);
|
dawn::TextureUsage::CopySrc);
|
||||||
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
// Correct usage
|
// Correct usage
|
||||||
TestT2BCopy(utils::Expectation::Success, source, 0, 0, {0, 0, 0}, destination, bufferSize - 4,
|
TestT2BCopy(utils::Expectation::Success, source, 0, 0, {0, 0, 0}, destination, bufferSize - 4,
|
||||||
|
@ -812,9 +811,9 @@ TEST_F(CopyCommandTest_T2B, IncorrectBufferOffset) {
|
||||||
// Test multisampled textures cannot be used in T2B copies.
|
// Test multisampled textures cannot be used in T2B copies.
|
||||||
TEST_F(CopyCommandTest_T2B, CopyFromMultisampledTexture) {
|
TEST_F(CopyCommandTest_T2B, CopyFromMultisampledTexture) {
|
||||||
dawn::Texture source = Create2DTexture(2, 2, 1, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source = Create2DTexture(2, 2, 1, 1, dawn::TextureFormat::RGBA8Unorm,
|
||||||
dawn::TextureUsageBit::CopySrc, 4);
|
dawn::TextureUsage::CopySrc, 4);
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(16, 16, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(16, 16, 1);
|
||||||
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0, 256, 0,
|
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0, 256, 0,
|
||||||
{2, 2, 1});
|
{2, 2, 1});
|
||||||
|
@ -824,7 +823,7 @@ TEST_F(CopyCommandTest_T2B, CopyFromMultisampledTexture) {
|
||||||
TEST_F(CopyCommandTest_T2B, BufferOrTextureInErrorState) {
|
TEST_F(CopyCommandTest_T2B, BufferOrTextureInErrorState) {
|
||||||
dawn::BufferDescriptor errorBufferDescriptor;
|
dawn::BufferDescriptor errorBufferDescriptor;
|
||||||
errorBufferDescriptor.size = 4;
|
errorBufferDescriptor.size = 4;
|
||||||
errorBufferDescriptor.usage = dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::CopySrc;
|
errorBufferDescriptor.usage = dawn::BufferUsage::MapRead | dawn::BufferUsage::CopySrc;
|
||||||
ASSERT_DEVICE_ERROR(dawn::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor));
|
ASSERT_DEVICE_ERROR(dawn::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor));
|
||||||
|
|
||||||
dawn::TextureDescriptor errorTextureDescriptor;
|
dawn::TextureDescriptor errorTextureDescriptor;
|
||||||
|
@ -839,7 +838,7 @@ TEST_F(CopyCommandTest_T2B, BufferOrTextureInErrorState) {
|
||||||
|
|
||||||
{
|
{
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopySrc);
|
dawn::Buffer source = CreateBuffer(bufferSize, dawn::BufferUsage::CopySrc);
|
||||||
|
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(source, 0, 0, 0);
|
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(source, 0, 0, 0);
|
||||||
|
|
||||||
|
@ -850,7 +849,7 @@ TEST_F(CopyCommandTest_T2B, BufferOrTextureInErrorState) {
|
||||||
|
|
||||||
{
|
{
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination = Create2DTexture(16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm,
|
||||||
dawn::TextureUsageBit::CopyDst);
|
dawn::TextureUsage::CopyDst);
|
||||||
dawn::TextureCopyView textureCopyView =
|
dawn::TextureCopyView textureCopyView =
|
||||||
utils::CreateTextureCopyView(destination, 0, 0, {1, 1, 1});
|
utils::CreateTextureCopyView(destination, 0, 0, {1, 1, 1});
|
||||||
|
|
||||||
|
@ -876,10 +875,9 @@ TEST_F(CopyCommandTest_T2B, TextureCopyBufferSizeLastRowComputation) {
|
||||||
|
|
||||||
for (dawn::TextureFormat format : kFormats) {
|
for (dawn::TextureFormat format : kFormats) {
|
||||||
dawn::Texture source =
|
dawn::Texture source =
|
||||||
Create2DTexture(kWidth, kHeight, 1, 1, format, dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(kWidth, kHeight, 1, 1, format, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
dawn::Buffer destination =
|
dawn::Buffer destination = CreateBuffer(kInvalidBufferSize, dawn::BufferUsage::CopySrc);
|
||||||
CreateBuffer(kInvalidBufferSize, dawn::BufferUsageBit::CopySrc);
|
|
||||||
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0,
|
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0,
|
||||||
kRowPitch, 0, {kWidth, kHeight, 1});
|
kRowPitch, 0, {kWidth, kHeight, 1});
|
||||||
}
|
}
|
||||||
|
@ -889,21 +887,21 @@ TEST_F(CopyCommandTest_T2B, TextureCopyBufferSizeLastRowComputation) {
|
||||||
for (dawn::TextureFormat format : kFormats) {
|
for (dawn::TextureFormat format : kFormats) {
|
||||||
uint32_t validBufferSize = BufferSizeForTextureCopy(kWidth, kHeight, 1, format);
|
uint32_t validBufferSize = BufferSizeForTextureCopy(kWidth, kHeight, 1, format);
|
||||||
dawn::Texture source =
|
dawn::Texture source =
|
||||||
Create2DTexture(kWidth, kHeight, 1, 1, format, dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(kWidth, kHeight, 1, 1, format, dawn::TextureUsage::CopySrc);
|
||||||
|
|
||||||
// Verify the return value of BufferSizeForTextureCopy() is exactly the minimum valid
|
// Verify the return value of BufferSizeForTextureCopy() is exactly the minimum valid
|
||||||
// buffer size in this test.
|
// buffer size in this test.
|
||||||
{
|
{
|
||||||
uint32_t invalidBufferSize = validBufferSize - 1;
|
uint32_t invalidBufferSize = validBufferSize - 1;
|
||||||
dawn::Buffer destination =
|
dawn::Buffer destination =
|
||||||
CreateBuffer(invalidBufferSize, dawn::BufferUsageBit::CopyDst);
|
CreateBuffer(invalidBufferSize, dawn::BufferUsage::CopyDst);
|
||||||
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0,
|
TestT2BCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0,
|
||||||
kRowPitch, 0, {kWidth, kHeight, 1});
|
kRowPitch, 0, {kWidth, kHeight, 1});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
dawn::Buffer destination =
|
dawn::Buffer destination =
|
||||||
CreateBuffer(validBufferSize, dawn::BufferUsageBit::CopyDst);
|
CreateBuffer(validBufferSize, dawn::BufferUsage::CopyDst);
|
||||||
TestT2BCopy(utils::Expectation::Success, source, 0, 0, {0, 0, 0}, destination, 0,
|
TestT2BCopy(utils::Expectation::Success, source, 0, 0, {0, 0, 0}, destination, 0,
|
||||||
kRowPitch, 0, {kWidth, kHeight, 1});
|
kRowPitch, 0, {kWidth, kHeight, 1});
|
||||||
}
|
}
|
||||||
|
@ -915,9 +913,9 @@ TEST_F(CopyCommandTest_T2B, TextureCopyBufferSizeLastRowComputation) {
|
||||||
TEST_F(CopyCommandTest_T2B, CopyFromMipmapOfNonSquareTexture) {
|
TEST_F(CopyCommandTest_T2B, CopyFromMipmapOfNonSquareTexture) {
|
||||||
uint32_t maxMipmapLevel = 3;
|
uint32_t maxMipmapLevel = 3;
|
||||||
dawn::Texture source = Create2DTexture(4, 2, maxMipmapLevel, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source = Create2DTexture(4, 2, maxMipmapLevel, 1, dawn::TextureFormat::RGBA8Unorm,
|
||||||
dawn::TextureUsageBit::CopySrc);
|
dawn::TextureUsage::CopySrc);
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 2, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 2, 1);
|
||||||
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsageBit::CopyDst);
|
dawn::Buffer destination = CreateBuffer(bufferSize, dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
// Copy from top level mip map
|
// Copy from top level mip map
|
||||||
TestT2BCopy(utils::Expectation::Success, source, maxMipmapLevel - 1, 0, {0, 0, 0}, destination,
|
TestT2BCopy(utils::Expectation::Success, source, maxMipmapLevel - 1, 0, {0, 0, 0}, destination,
|
||||||
|
@ -939,10 +937,10 @@ TEST_F(CopyCommandTest_T2B, CopyFromMipmapOfNonSquareTexture) {
|
||||||
class CopyCommandTest_T2T : public CopyCommandTest {};
|
class CopyCommandTest_T2T : public CopyCommandTest {};
|
||||||
|
|
||||||
TEST_F(CopyCommandTest_T2T, Success) {
|
TEST_F(CopyCommandTest_T2T, Success) {
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source =
|
||||||
dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Different copies, including some that touch the OOB condition
|
// Different copies, including some that touch the OOB condition
|
||||||
{
|
{
|
||||||
|
@ -992,10 +990,10 @@ TEST_F(CopyCommandTest_T2T, Success) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CopyCommandTest_T2T, IncorrectUsage) {
|
TEST_F(CopyCommandTest_T2T, IncorrectUsage) {
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source =
|
||||||
dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Incorrect source usage causes failure
|
// Incorrect source usage causes failure
|
||||||
TestT2TCopy(utils::Expectation::Failure, destination, 0, 0, {0, 0, 0}, destination, 0, 0,
|
TestT2TCopy(utils::Expectation::Failure, destination, 0, 0, {0, 0, 0}, destination, 0, 0,
|
||||||
|
@ -1007,10 +1005,10 @@ TEST_F(CopyCommandTest_T2T, IncorrectUsage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CopyCommandTest_T2T, OutOfBounds) {
|
TEST_F(CopyCommandTest_T2T, OutOfBounds) {
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source =
|
||||||
dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// OOB on source
|
// OOB on source
|
||||||
{
|
{
|
||||||
|
@ -1060,10 +1058,10 @@ TEST_F(CopyCommandTest_T2T, OutOfBounds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CopyCommandTest_T2T, 2DTextureDepthConstraints) {
|
TEST_F(CopyCommandTest_T2T, 2DTextureDepthConstraints) {
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source =
|
||||||
dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Empty copy on source with z > 0 fails
|
// Empty copy on source with z > 0 fails
|
||||||
TestT2TCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 1}, destination, 0, 0, {0, 0, 0},
|
TestT2TCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 1}, destination, 0, 0, {0, 0, 0},
|
||||||
|
@ -1080,9 +1078,9 @@ TEST_F(CopyCommandTest_T2T, 2DTextureDepthConstraints) {
|
||||||
|
|
||||||
TEST_F(CopyCommandTest_T2T, 2DTextureDepthStencil) {
|
TEST_F(CopyCommandTest_T2T, 2DTextureDepthStencil) {
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 1, 1, dawn::TextureFormat::Depth24PlusStencil8,
|
dawn::Texture source = Create2DTexture(16, 16, 1, 1, dawn::TextureFormat::Depth24PlusStencil8,
|
||||||
dawn::TextureUsageBit::CopySrc);
|
dawn::TextureUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(
|
dawn::Texture destination = Create2DTexture(
|
||||||
16, 16, 1, 1, dawn::TextureFormat::Depth24PlusStencil8, dawn::TextureUsageBit::CopyDst);
|
16, 16, 1, 1, dawn::TextureFormat::Depth24PlusStencil8, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Success when entire depth stencil subresource is copied
|
// Success when entire depth stencil subresource is copied
|
||||||
TestT2TCopy(utils::Expectation::Success, source, 0, 0, {0, 0, 0}, destination, 0, 0, {0, 0, 0},
|
TestT2TCopy(utils::Expectation::Success, source, 0, 0, {0, 0, 0}, destination, 0, 0, {0, 0, 0},
|
||||||
|
@ -1094,10 +1092,10 @@ TEST_F(CopyCommandTest_T2T, 2DTextureDepthStencil) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CopyCommandTest_T2T, FormatsMismatch) {
|
TEST_F(CopyCommandTest_T2T, FormatsMismatch) {
|
||||||
dawn::Texture source = Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Uint,
|
dawn::Texture source =
|
||||||
dawn::TextureUsageBit::CopySrc);
|
Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Uint, dawn::TextureUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture destination =
|
||||||
dawn::TextureUsageBit::CopyDst);
|
Create2DTexture(16, 16, 5, 2, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
|
|
||||||
// Failure when formats don't match
|
// Failure when formats don't match
|
||||||
TestT2TCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0, 0, {0, 0, 0},
|
TestT2TCopy(utils::Expectation::Failure, source, 0, 0, {0, 0, 0}, destination, 0, 0, {0, 0, 0},
|
||||||
|
@ -1106,11 +1104,11 @@ TEST_F(CopyCommandTest_T2T, FormatsMismatch) {
|
||||||
|
|
||||||
TEST_F(CopyCommandTest_T2T, MultisampledCopies) {
|
TEST_F(CopyCommandTest_T2T, MultisampledCopies) {
|
||||||
dawn::Texture sourceMultiSampled1x = Create2DTexture(
|
dawn::Texture sourceMultiSampled1x = Create2DTexture(
|
||||||
16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsageBit::CopySrc, 1);
|
16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc, 1);
|
||||||
dawn::Texture sourceMultiSampled4x = Create2DTexture(
|
dawn::Texture sourceMultiSampled4x = Create2DTexture(
|
||||||
16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsageBit::CopySrc, 4);
|
16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopySrc, 4);
|
||||||
dawn::Texture destinationMultiSampled4x = Create2DTexture(
|
dawn::Texture destinationMultiSampled4x = Create2DTexture(
|
||||||
16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsageBit::CopyDst, 4);
|
16, 16, 1, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst, 4);
|
||||||
|
|
||||||
// Success when entire multisampled subresource is copied
|
// Success when entire multisampled subresource is copied
|
||||||
{
|
{
|
||||||
|
@ -1134,9 +1132,9 @@ TEST_F(CopyCommandTest_T2T, MultisampledCopies) {
|
||||||
TEST_F(CopyCommandTest_T2T, CopyToMipmapOfNonSquareTexture) {
|
TEST_F(CopyCommandTest_T2T, CopyToMipmapOfNonSquareTexture) {
|
||||||
uint32_t maxMipmapLevel = 3;
|
uint32_t maxMipmapLevel = 3;
|
||||||
dawn::Texture source = Create2DTexture(4, 2, maxMipmapLevel, 1, dawn::TextureFormat::RGBA8Unorm,
|
dawn::Texture source = Create2DTexture(4, 2, maxMipmapLevel, 1, dawn::TextureFormat::RGBA8Unorm,
|
||||||
dawn::TextureUsageBit::CopySrc);
|
dawn::TextureUsage::CopySrc);
|
||||||
dawn::Texture destination = Create2DTexture(
|
dawn::Texture destination = Create2DTexture(
|
||||||
4, 2, maxMipmapLevel, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsageBit::CopyDst);
|
4, 2, maxMipmapLevel, 1, dawn::TextureFormat::RGBA8Unorm, dawn::TextureUsage::CopyDst);
|
||||||
// Copy to top level mip map
|
// Copy to top level mip map
|
||||||
TestT2TCopy(utils::Expectation::Success, source, maxMipmapLevel - 1, 0, {0, 0, 0}, destination,
|
TestT2TCopy(utils::Expectation::Success, source, maxMipmapLevel - 1, 0, {0, 0, 0}, destination,
|
||||||
maxMipmapLevel - 1, 0, {0, 0, 0}, {1, 1, 1});
|
maxMipmapLevel - 1, 0, {0, 0, 0}, {1, 1, 1});
|
||||||
|
@ -1165,9 +1163,8 @@ class CopyCommandTest_CompressedTextureFormats : public CopyCommandTest {
|
||||||
uint32_t mipmapLevels = 1,
|
uint32_t mipmapLevels = 1,
|
||||||
uint32_t width = kWidth,
|
uint32_t width = kWidth,
|
||||||
uint32_t height = kHeight) {
|
uint32_t height = kHeight) {
|
||||||
constexpr dawn::TextureUsageBit kUsage = dawn::TextureUsageBit::CopyDst |
|
constexpr dawn::TextureUsage kUsage =
|
||||||
dawn::TextureUsageBit::CopySrc |
|
dawn::TextureUsage::CopyDst | dawn::TextureUsage::CopySrc | dawn::TextureUsage::Sampled;
|
||||||
dawn::TextureUsageBit::Sampled;
|
|
||||||
constexpr uint32_t kArrayLayers = 1;
|
constexpr uint32_t kArrayLayers = 1;
|
||||||
return CopyCommandTest::Create2DTexture(width, height, mipmapLevels, kArrayLayers, format,
|
return CopyCommandTest::Create2DTexture(width, height, mipmapLevels, kArrayLayers, format,
|
||||||
kUsage, 1);
|
kUsage, 1);
|
||||||
|
@ -1246,7 +1243,7 @@ class CopyCommandTest_CompressedTextureFormats : public CopyCommandTest {
|
||||||
// in buffer-to-texture or texture-to-buffer copies with compressed texture formats.
|
// in buffer-to-texture or texture-to-buffer copies with compressed texture formats.
|
||||||
TEST_F(CopyCommandTest_CompressedTextureFormats, BufferOffset) {
|
TEST_F(CopyCommandTest_CompressedTextureFormats, BufferOffset) {
|
||||||
dawn::Buffer buffer =
|
dawn::Buffer buffer =
|
||||||
CreateBuffer(512, dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst);
|
CreateBuffer(512, dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
for (dawn::TextureFormat bcFormat : kBCFormats) {
|
for (dawn::TextureFormat bcFormat : kBCFormats) {
|
||||||
dawn::Texture texture = Create2DTexture(bcFormat);
|
dawn::Texture texture = Create2DTexture(bcFormat);
|
||||||
|
@ -1274,7 +1271,7 @@ TEST_F(CopyCommandTest_CompressedTextureFormats, BufferOffset) {
|
||||||
// the multiple of compressed texture block width in bytes.
|
// the multiple of compressed texture block width in bytes.
|
||||||
TEST_F(CopyCommandTest_CompressedTextureFormats, RowPitch) {
|
TEST_F(CopyCommandTest_CompressedTextureFormats, RowPitch) {
|
||||||
dawn::Buffer buffer =
|
dawn::Buffer buffer =
|
||||||
CreateBuffer(1024, dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst);
|
CreateBuffer(1024, dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
{
|
{
|
||||||
constexpr uint32_t kTestWidth = 160;
|
constexpr uint32_t kTestWidth = 160;
|
||||||
|
@ -1343,7 +1340,7 @@ TEST_F(CopyCommandTest_CompressedTextureFormats, RowPitch) {
|
||||||
// buffer-to-texture or texture-to-buffer copies with compressed texture formats.
|
// buffer-to-texture or texture-to-buffer copies with compressed texture formats.
|
||||||
TEST_F(CopyCommandTest_CompressedTextureFormats, ImageHeight) {
|
TEST_F(CopyCommandTest_CompressedTextureFormats, ImageHeight) {
|
||||||
dawn::Buffer buffer =
|
dawn::Buffer buffer =
|
||||||
CreateBuffer(512, dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst);
|
CreateBuffer(512, dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
for (dawn::TextureFormat bcFormat : kBCFormats) {
|
for (dawn::TextureFormat bcFormat : kBCFormats) {
|
||||||
dawn::Texture texture = Create2DTexture(bcFormat);
|
dawn::Texture texture = Create2DTexture(bcFormat);
|
||||||
|
@ -1369,7 +1366,7 @@ TEST_F(CopyCommandTest_CompressedTextureFormats, ImageHeight) {
|
||||||
// texture-to-buffer or texture-to-texture copies with compressed texture formats.
|
// texture-to-buffer or texture-to-texture copies with compressed texture formats.
|
||||||
TEST_F(CopyCommandTest_CompressedTextureFormats, ImageOffset) {
|
TEST_F(CopyCommandTest_CompressedTextureFormats, ImageOffset) {
|
||||||
dawn::Buffer buffer =
|
dawn::Buffer buffer =
|
||||||
CreateBuffer(512, dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst);
|
CreateBuffer(512, dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
for (dawn::TextureFormat bcFormat : kBCFormats) {
|
for (dawn::TextureFormat bcFormat : kBCFormats) {
|
||||||
dawn::Texture texture = Create2DTexture(bcFormat);
|
dawn::Texture texture = Create2DTexture(bcFormat);
|
||||||
|
@ -1412,7 +1409,7 @@ TEST_F(CopyCommandTest_CompressedTextureFormats, ImageOffset) {
|
||||||
// texture-to-buffer or texture-to-texture copies with compressed texture formats.
|
// texture-to-buffer or texture-to-texture copies with compressed texture formats.
|
||||||
TEST_F(CopyCommandTest_CompressedTextureFormats, ImageExtent) {
|
TEST_F(CopyCommandTest_CompressedTextureFormats, ImageExtent) {
|
||||||
dawn::Buffer buffer =
|
dawn::Buffer buffer =
|
||||||
CreateBuffer(512, dawn::BufferUsageBit::CopySrc | dawn::BufferUsageBit::CopyDst);
|
CreateBuffer(512, dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst);
|
||||||
|
|
||||||
constexpr uint32_t kMipmapLevels = 3;
|
constexpr uint32_t kMipmapLevels = 3;
|
||||||
constexpr uint32_t kTestWidth = 60;
|
constexpr uint32_t kTestWidth = 60;
|
||||||
|
|
|
@ -73,8 +73,8 @@ class DrawIndirectValidationTest : public ValidationTest {
|
||||||
std::initializer_list<uint32_t> bufferList,
|
std::initializer_list<uint32_t> bufferList,
|
||||||
uint64_t indirectOffset,
|
uint64_t indirectOffset,
|
||||||
bool indexed) {
|
bool indexed) {
|
||||||
dawn::Buffer indirectBuffer = utils::CreateBufferFromData<uint32_t>(
|
dawn::Buffer indirectBuffer =
|
||||||
device, dawn::BufferUsageBit::Indirect, bufferList);
|
utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsage::Indirect, bufferList);
|
||||||
|
|
||||||
DummyRenderPass renderPass(device);
|
DummyRenderPass renderPass(device);
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
@ -82,8 +82,8 @@ class DrawIndirectValidationTest : public ValidationTest {
|
||||||
pass.SetPipeline(pipeline);
|
pass.SetPipeline(pipeline);
|
||||||
if (indexed) {
|
if (indexed) {
|
||||||
uint32_t zeros[100] = {};
|
uint32_t zeros[100] = {};
|
||||||
dawn::Buffer indexBuffer = utils::CreateBufferFromData(device, zeros, sizeof(zeros),
|
dawn::Buffer indexBuffer =
|
||||||
dawn::BufferUsageBit::Index);
|
utils::CreateBufferFromData(device, zeros, sizeof(zeros), dawn::BufferUsage::Index);
|
||||||
pass.SetIndexBuffer(indexBuffer, 0);
|
pass.SetIndexBuffer(indexBuffer, 0);
|
||||||
pass.DrawIndexedIndirect(indirectBuffer, indirectOffset);
|
pass.DrawIndexedIndirect(indirectBuffer, indirectOffset);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -32,12 +32,12 @@ static void StoreTrueMapWriteCallback(DawnBufferMapAsyncStatus status,
|
||||||
TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
||||||
// Create a map-write buffer.
|
// Create a map-write buffer.
|
||||||
dawn::BufferDescriptor descriptor;
|
dawn::BufferDescriptor descriptor;
|
||||||
descriptor.usage = dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::CopySrc;
|
descriptor.usage = dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
// Create a fake copy destination buffer
|
// Create a fake copy destination buffer
|
||||||
descriptor.usage = dawn::BufferUsageBit::CopyDst;
|
descriptor.usage = dawn::BufferUsage::CopyDst;
|
||||||
dawn::Buffer targetBuffer = device.CreateBuffer(&descriptor);
|
dawn::Buffer targetBuffer = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
// Create a command buffer that reads from the mappable buffer.
|
// Create a command buffer that reads from the mappable buffer.
|
||||||
|
|
|
@ -69,21 +69,21 @@ namespace {
|
||||||
|
|
||||||
float data[4];
|
float data[4];
|
||||||
dawn::Buffer buffer = utils::CreateBufferFromData(device, data, 4 * sizeof(float),
|
dawn::Buffer buffer = utils::CreateBufferFromData(device, data, 4 * sizeof(float),
|
||||||
dawn::BufferUsageBit::Uniform);
|
dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
constexpr static float kVertices[] = {-1.f, 1.f, 1.f, -1.f, -1.f, 1.f};
|
constexpr static float kVertices[] = {-1.f, 1.f, 1.f, -1.f, -1.f, 1.f};
|
||||||
|
|
||||||
vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
|
vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
|
||||||
dawn::BufferUsageBit::Vertex);
|
dawn::BufferUsage::Vertex);
|
||||||
|
|
||||||
// Dummy storage buffer.
|
// Dummy storage buffer.
|
||||||
dawn::Buffer storageBuffer = utils::CreateBufferFromData(
|
dawn::Buffer storageBuffer = utils::CreateBufferFromData(
|
||||||
device, kVertices, sizeof(kVertices), dawn::BufferUsageBit::Storage);
|
device, kVertices, sizeof(kVertices), dawn::BufferUsage::Storage);
|
||||||
|
|
||||||
// Vertex buffer with storage usage for testing read+write error usage.
|
// Vertex buffer with storage usage for testing read+write error usage.
|
||||||
vertexStorageBuffer = utils::CreateBufferFromData(
|
vertexStorageBuffer =
|
||||||
device, kVertices, sizeof(kVertices),
|
utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
|
||||||
dawn::BufferUsageBit::Vertex | dawn::BufferUsageBit::Storage);
|
dawn::BufferUsage::Vertex | dawn::BufferUsage::Storage);
|
||||||
|
|
||||||
bg0 = utils::MakeBindGroup(device, bgls[0], {{0, buffer, 0, 4 * sizeof(float)}});
|
bg0 = utils::MakeBindGroup(device, bgls[0], {{0, buffer, 0, 4 * sizeof(float)}});
|
||||||
bg1 = utils::MakeBindGroup(
|
bg1 = utils::MakeBindGroup(
|
||||||
|
@ -843,7 +843,7 @@ TEST_F(RenderBundleValidationTest, RenderPassColorFormatMismatch) {
|
||||||
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish();
|
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish();
|
||||||
|
|
||||||
dawn::TextureDescriptor textureDesc = {};
|
dawn::TextureDescriptor textureDesc = {};
|
||||||
textureDesc.usage = dawn::TextureUsageBit::OutputAttachment;
|
textureDesc.usage = dawn::TextureUsage::OutputAttachment;
|
||||||
textureDesc.size = dawn::Extent3D({400, 400, 1});
|
textureDesc.size = dawn::Extent3D({400, 400, 1});
|
||||||
|
|
||||||
textureDesc.format = dawn::TextureFormat::RGBA8Unorm;
|
textureDesc.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
|
@ -914,7 +914,7 @@ TEST_F(RenderBundleValidationTest, RenderPassDepthStencilFormatMismatch) {
|
||||||
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish();
|
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish();
|
||||||
|
|
||||||
dawn::TextureDescriptor textureDesc = {};
|
dawn::TextureDescriptor textureDesc = {};
|
||||||
textureDesc.usage = dawn::TextureUsageBit::OutputAttachment;
|
textureDesc.usage = dawn::TextureUsage::OutputAttachment;
|
||||||
textureDesc.size = dawn::Extent3D({400, 400, 1});
|
textureDesc.size = dawn::Extent3D({400, 400, 1});
|
||||||
|
|
||||||
textureDesc.format = dawn::TextureFormat::RGBA8Unorm;
|
textureDesc.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
|
@ -973,7 +973,7 @@ TEST_F(RenderBundleValidationTest, RenderPassSampleCountMismatch) {
|
||||||
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish();
|
dawn::RenderBundle renderBundle = renderBundleEncoder.Finish();
|
||||||
|
|
||||||
dawn::TextureDescriptor textureDesc = {};
|
dawn::TextureDescriptor textureDesc = {};
|
||||||
textureDesc.usage = dawn::TextureUsageBit::OutputAttachment;
|
textureDesc.usage = dawn::TextureUsage::OutputAttachment;
|
||||||
textureDesc.size = dawn::Extent3D({400, 400, 1});
|
textureDesc.size = dawn::Extent3D({400, 400, 1});
|
||||||
|
|
||||||
textureDesc.format = dawn::TextureFormat::RGBA8Unorm;
|
textureDesc.format = dawn::TextureFormat::RGBA8Unorm;
|
||||||
|
|
|
@ -48,7 +48,7 @@ dawn::Texture CreateTexture(dawn::Device& device,
|
||||||
uint32_t arrayLayerCount,
|
uint32_t arrayLayerCount,
|
||||||
uint32_t mipLevelCount,
|
uint32_t mipLevelCount,
|
||||||
uint32_t sampleCount = 1,
|
uint32_t sampleCount = 1,
|
||||||
dawn::TextureUsageBit usage = dawn::TextureUsageBit::OutputAttachment) {
|
dawn::TextureUsage usage = dawn::TextureUsage::OutputAttachment) {
|
||||||
dawn::TextureDescriptor descriptor;
|
dawn::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dimension;
|
descriptor.dimension = dimension;
|
||||||
descriptor.size.width = width;
|
descriptor.size.width = width;
|
||||||
|
@ -488,10 +488,9 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetMipmapLevelM
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is not allowed to use a resolve target which is created from a texture whose usage does not
|
// It is not allowed to use a resolve target which is created from a texture whose usage does not
|
||||||
// include dawn::TextureUsageBit::OutputAttachment.
|
// include dawn::TextureUsage::OutputAttachment.
|
||||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutputAttachment) {
|
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutputAttachment) {
|
||||||
constexpr dawn::TextureUsageBit kUsage =
|
constexpr dawn::TextureUsage kUsage = dawn::TextureUsage::CopyDst | dawn::TextureUsage::CopySrc;
|
||||||
dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::CopySrc;
|
|
||||||
dawn::Texture nonColorUsageResolveTexture = CreateTexture(
|
dawn::Texture nonColorUsageResolveTexture = CreateTexture(
|
||||||
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers,
|
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers,
|
||||||
kLevelCount, 1, kUsage);
|
kLevelCount, 1, kUsage);
|
||||||
|
|
|
@ -66,8 +66,8 @@ void main() {
|
||||||
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
|
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
|
||||||
|
|
||||||
float data[4];
|
float data[4];
|
||||||
dawn::Buffer buffer = utils::CreateBufferFromData(device, data, 4 * sizeof(float),
|
dawn::Buffer buffer =
|
||||||
dawn::BufferUsageBit::Uniform);
|
utils::CreateBufferFromData(device, data, 4 * sizeof(float), dawn::BufferUsage::Uniform);
|
||||||
|
|
||||||
dawn::BindGroup bg1 =
|
dawn::BindGroup bg1 =
|
||||||
utils::MakeBindGroup(device, bgls[0], {{0, buffer, 0, 4 * sizeof(float)}});
|
utils::MakeBindGroup(device, bgls[0], {{0, buffer, 0, 4 * sizeof(float)}});
|
||||||
|
|
|
@ -130,7 +130,7 @@ TEST_F(RenderPipelineValidationTest, SampleCountCompatibilityWithRenderPass) {
|
||||||
baseTextureDescriptor.arrayLayerCount = 1;
|
baseTextureDescriptor.arrayLayerCount = 1;
|
||||||
baseTextureDescriptor.mipLevelCount = 1;
|
baseTextureDescriptor.mipLevelCount = 1;
|
||||||
baseTextureDescriptor.dimension = dawn::TextureDimension::e2D;
|
baseTextureDescriptor.dimension = dawn::TextureDimension::e2D;
|
||||||
baseTextureDescriptor.usage = dawn::TextureUsageBit::OutputAttachment;
|
baseTextureDescriptor.usage = dawn::TextureUsage::OutputAttachment;
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor nonMultisampledPipelineDescriptor(device);
|
utils::ComboRenderPipelineDescriptor nonMultisampledPipelineDescriptor(device);
|
||||||
nonMultisampledPipelineDescriptor.sampleCount = 1;
|
nonMultisampledPipelineDescriptor.sampleCount = 1;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue