mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +00:00
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:
committed by
Commit Bot service account
parent
e25a3aede0
commit
9e9e29f7a6
@@ -52,8 +52,8 @@ void init() {
|
||||
|
||||
queue = device.CreateQueue();
|
||||
swapchain = GetSwapChain(device);
|
||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(),
|
||||
dawn::TextureUsageBit::OutputAttachment, 640, 480);
|
||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
||||
640, 480);
|
||||
|
||||
dawn::ShaderModule vsModule = utils::CreateShaderModule(device, utils::ShaderStage::Vertex, R"(
|
||||
#version 450
|
||||
@@ -134,7 +134,7 @@ void init() {
|
||||
|
||||
dawn::BufferDescriptor bufferDesc;
|
||||
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);
|
||||
|
||||
bindGroup =
|
||||
|
||||
@@ -35,8 +35,8 @@ void init() {
|
||||
swapchain = dawnDeviceCreateSwapChain(device, &descriptor);
|
||||
}
|
||||
swapChainFormat = static_cast<DawnTextureFormat>(GetPreferredSwapChainTextureFormat());
|
||||
dawnSwapChainConfigure(swapchain, swapChainFormat, DAWN_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT, 640,
|
||||
480);
|
||||
dawnSwapChainConfigure(swapchain, swapChainFormat, DAWN_TEXTURE_USAGE_OUTPUT_ATTACHMENT, 640,
|
||||
480);
|
||||
|
||||
const char* vs =
|
||||
"#version 450\n"
|
||||
|
||||
@@ -64,10 +64,12 @@ void initBuffers() {
|
||||
{0.01, -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 };
|
||||
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);
|
||||
{
|
||||
@@ -83,8 +85,8 @@ void initBuffers() {
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
dawn::BufferDescriptor descriptor;
|
||||
descriptor.size = sizeof(Particle) * kNumParticles;
|
||||
descriptor.usage = dawn::BufferUsageBit::CopyDst | dawn::BufferUsageBit::Vertex |
|
||||
dawn::BufferUsageBit::Storage;
|
||||
descriptor.usage =
|
||||
dawn::BufferUsage::CopyDst | dawn::BufferUsage::Vertex | dawn::BufferUsage::Storage;
|
||||
particleBuffers[i] = device.CreateBuffer(&descriptor);
|
||||
|
||||
particleBuffers[i].SetSubData(0,
|
||||
@@ -293,8 +295,8 @@ void init() {
|
||||
|
||||
queue = device.CreateQueue();
|
||||
swapchain = GetSwapChain(device);
|
||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(),
|
||||
dawn::TextureUsageBit::OutputAttachment, 640, 480);
|
||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
||||
640, 480);
|
||||
|
||||
initBuffers();
|
||||
initRender();
|
||||
|
||||
@@ -38,14 +38,16 @@ void initBuffers() {
|
||||
static const uint32_t indexData[3] = {
|
||||
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] = {
|
||||
0.0f, 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() {
|
||||
@@ -58,7 +60,7 @@ void initTextures() {
|
||||
descriptor.sampleCount = 1;
|
||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
||||
descriptor.mipLevelCount = 1;
|
||||
descriptor.usage = dawn::TextureUsageBit::CopyDst | dawn::TextureUsageBit::Sampled;
|
||||
descriptor.usage = dawn::TextureUsage::CopyDst | dawn::TextureUsage::Sampled;
|
||||
texture = device.CreateTexture(&descriptor);
|
||||
|
||||
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
|
||||
@@ -71,7 +73,7 @@ void initTextures() {
|
||||
}
|
||||
|
||||
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::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||
dawn::Extent3D copySize = {1024, 1024, 1};
|
||||
@@ -88,8 +90,8 @@ void init() {
|
||||
|
||||
queue = device.CreateQueue();
|
||||
swapchain = GetSwapChain(device);
|
||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(),
|
||||
dawn::TextureUsageBit::OutputAttachment, 640, 480);
|
||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
||||
640, 480);
|
||||
|
||||
initBuffers();
|
||||
initTextures();
|
||||
|
||||
@@ -62,7 +62,8 @@ void initBuffers() {
|
||||
20, 21, 22,
|
||||
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] = {
|
||||
-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
|
||||
};
|
||||
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] = {
|
||||
-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,
|
||||
};
|
||||
planeBuffer = utils::CreateBufferFromData(device, planeData, sizeof(planeData), dawn::BufferUsageBit::Vertex);
|
||||
planeBuffer = utils::CreateBufferFromData(device, planeData, sizeof(planeData),
|
||||
dawn::BufferUsage::Vertex);
|
||||
}
|
||||
|
||||
struct CameraData {
|
||||
@@ -116,8 +119,8 @@ void init() {
|
||||
|
||||
queue = device.CreateQueue();
|
||||
swapchain = GetSwapChain(device);
|
||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(),
|
||||
dawn::TextureUsageBit::OutputAttachment, 640, 480);
|
||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
||||
640, 480);
|
||||
|
||||
initBuffers();
|
||||
|
||||
@@ -176,14 +179,16 @@ void init() {
|
||||
|
||||
dawn::BufferDescriptor cameraBufDesc;
|
||||
cameraBufDesc.size = sizeof(CameraData);
|
||||
cameraBufDesc.usage = dawn::BufferUsageBit::CopyDst | dawn::BufferUsageBit::Uniform;
|
||||
cameraBufDesc.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::Uniform;
|
||||
cameraBuffer = device.CreateBuffer(&cameraBufDesc);
|
||||
|
||||
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));
|
||||
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, {
|
||||
{0, cameraBuffer, 0, sizeof(CameraData)},
|
||||
|
||||
@@ -173,7 +173,7 @@ dawn::TextureView CreateDefaultDepthStencilView(const dawn::Device& device) {
|
||||
descriptor.sampleCount = 1;
|
||||
descriptor.format = dawn::TextureFormat::Depth24PlusStencil8;
|
||||
descriptor.mipLevelCount = 1;
|
||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
|
||||
descriptor.usage = dawn::TextureUsage::OutputAttachment;
|
||||
auto depthStencilTexture = device.CreateTexture(&descriptor);
|
||||
return depthStencilTexture.CreateDefaultView();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user