mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
Typeify ColorAttachmentIndex
Also moves BindingNumber, BindGroupIndex, and BindingIndex to IntegerTypes.h. Future TypedIntegers should be declared here. Bug: dawn:442 Change-Id: I5ba8de3412fb48b7957b67e7c413a5097f8ec00f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/27880 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
22e5e179fa
commit
7b7e098b11
@@ -370,7 +370,7 @@ namespace dawn_native { namespace opengl {
|
||||
GLuint readFbo = 0;
|
||||
GLuint writeFbo = 0;
|
||||
|
||||
for (uint32_t i :
|
||||
for (ColorAttachmentIndex i :
|
||||
IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
||||
if (renderPass->colorAttachments[i].resolveTarget.Get() != nullptr) {
|
||||
if (readFbo == 0) {
|
||||
@@ -854,30 +854,33 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
// Mapping from attachmentSlot to GL framebuffer attachment points. Defaults to zero
|
||||
// (GL_NONE).
|
||||
std::array<GLenum, kMaxColorAttachments> drawBuffers = {};
|
||||
ityp::array<ColorAttachmentIndex, GLenum, kMaxColorAttachments> drawBuffers = {};
|
||||
|
||||
// Construct GL framebuffer
|
||||
|
||||
unsigned int attachmentCount = 0;
|
||||
for (uint32_t i :
|
||||
ColorAttachmentIndex attachmentCount(uint8_t(0));
|
||||
for (ColorAttachmentIndex i :
|
||||
IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
||||
TextureViewBase* textureView = renderPass->colorAttachments[i].view.Get();
|
||||
GLuint texture = ToBackend(textureView->GetTexture())->GetHandle();
|
||||
|
||||
GLenum glAttachment = GL_COLOR_ATTACHMENT0 + static_cast<uint8_t>(i);
|
||||
|
||||
// Attach color buffers.
|
||||
if (textureView->GetTexture()->GetArrayLayers() == 1) {
|
||||
GLenum target = ToBackend(textureView->GetTexture())->GetGLTarget();
|
||||
gl.FramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, target,
|
||||
texture, textureView->GetBaseMipLevel());
|
||||
gl.FramebufferTexture2D(GL_DRAW_FRAMEBUFFER, glAttachment, target, texture,
|
||||
textureView->GetBaseMipLevel());
|
||||
} else {
|
||||
gl.FramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
|
||||
texture, textureView->GetBaseMipLevel(),
|
||||
gl.FramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, glAttachment, texture,
|
||||
textureView->GetBaseMipLevel(),
|
||||
textureView->GetBaseArrayLayer());
|
||||
}
|
||||
drawBuffers[i] = GL_COLOR_ATTACHMENT0 + i;
|
||||
attachmentCount = i + 1;
|
||||
drawBuffers[i] = glAttachment;
|
||||
attachmentCount = i;
|
||||
attachmentCount++;
|
||||
}
|
||||
gl.DrawBuffers(attachmentCount, drawBuffers.data());
|
||||
gl.DrawBuffers(static_cast<uint8_t>(attachmentCount), drawBuffers.data());
|
||||
|
||||
if (renderPass->attachmentState->HasDepthStencilAttachment()) {
|
||||
TextureViewBase* textureView = renderPass->depthStencilAttachment.view.Get();
|
||||
@@ -922,9 +925,10 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
// Clear framebuffer attachments as needed
|
||||
{
|
||||
for (uint32_t i :
|
||||
for (ColorAttachmentIndex index :
|
||||
IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
||||
auto* attachmentInfo = &renderPass->colorAttachments[i];
|
||||
uint8_t i = static_cast<uint8_t>(index);
|
||||
auto* attachmentInfo = &renderPass->colorAttachments[index];
|
||||
|
||||
// Load op - color
|
||||
if (attachmentInfo->loadOp == wgpu::LoadOp::Clear) {
|
||||
|
||||
@@ -109,21 +109,23 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
|
||||
void ApplyColorState(const OpenGLFunctions& gl,
|
||||
uint32_t attachment,
|
||||
ColorAttachmentIndex attachment,
|
||||
const ColorStateDescriptor* descriptor) {
|
||||
GLuint colorBuffer = static_cast<GLuint>(static_cast<uint8_t>(attachment));
|
||||
if (BlendEnabled(descriptor)) {
|
||||
gl.Enablei(GL_BLEND, attachment);
|
||||
gl.BlendEquationSeparatei(attachment, GLBlendMode(descriptor->colorBlend.operation),
|
||||
gl.Enablei(GL_BLEND, colorBuffer);
|
||||
gl.BlendEquationSeparatei(colorBuffer,
|
||||
GLBlendMode(descriptor->colorBlend.operation),
|
||||
GLBlendMode(descriptor->alphaBlend.operation));
|
||||
gl.BlendFuncSeparatei(attachment,
|
||||
gl.BlendFuncSeparatei(colorBuffer,
|
||||
GLBlendFactor(descriptor->colorBlend.srcFactor, false),
|
||||
GLBlendFactor(descriptor->colorBlend.dstFactor, false),
|
||||
GLBlendFactor(descriptor->alphaBlend.srcFactor, true),
|
||||
GLBlendFactor(descriptor->alphaBlend.dstFactor, true));
|
||||
} else {
|
||||
gl.Disablei(GL_BLEND, attachment);
|
||||
gl.Disablei(GL_BLEND, colorBuffer);
|
||||
}
|
||||
gl.ColorMaski(attachment, descriptor->writeMask & wgpu::ColorWriteMask::Red,
|
||||
gl.ColorMaski(colorBuffer, descriptor->writeMask & wgpu::ColorWriteMask::Red,
|
||||
descriptor->writeMask & wgpu::ColorWriteMask::Green,
|
||||
descriptor->writeMask & wgpu::ColorWriteMask::Blue,
|
||||
descriptor->writeMask & wgpu::ColorWriteMask::Alpha);
|
||||
@@ -265,7 +267,7 @@ namespace dawn_native { namespace opengl {
|
||||
gl.Disable(GL_SAMPLE_ALPHA_TO_COVERAGE);
|
||||
}
|
||||
|
||||
for (uint32_t attachmentSlot : IterateBitSet(GetColorAttachmentsMask())) {
|
||||
for (ColorAttachmentIndex attachmentSlot : IterateBitSet(GetColorAttachmentsMask())) {
|
||||
ApplyColorState(gl, attachmentSlot, GetColorStateDescriptor(attachmentSlot));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user