Graphics/FrameGraph: Add FramePassAttachmentSize enum instead of boolean
This commit is contained in:
committed by
Jérôme Leclercq
parent
d6b9b4327a
commit
d7eab778fb
@@ -153,15 +153,20 @@ namespace Nz
|
||||
textureCreationParams.type = ImageType::E2D;
|
||||
textureCreationParams.usageFlags = textureData.usage;
|
||||
textureCreationParams.pixelFormat = textureData.format;
|
||||
if (textureData.hasFixedSize)
|
||||
|
||||
textureCreationParams.width = 1;
|
||||
textureCreationParams.height = 1;
|
||||
switch (textureData.size)
|
||||
{
|
||||
textureCreationParams.width = textureData.width;
|
||||
textureCreationParams.height = textureData.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
textureCreationParams.width = textureData.width * frameWidth / 100'000;
|
||||
textureCreationParams.height = textureData.height * frameHeight / 100'000;
|
||||
case FramePassAttachmentSize::Fixed:
|
||||
textureCreationParams.width = textureData.width;
|
||||
textureCreationParams.height = textureData.height;
|
||||
break;
|
||||
|
||||
case FramePassAttachmentSize::SwapchainFactor:
|
||||
textureCreationParams.width = frameWidth * textureData.width / 100'000;
|
||||
textureCreationParams.height = frameHeight * textureData.height / 100'000;
|
||||
break;
|
||||
}
|
||||
|
||||
textureData.texture = renderDevice->InstantiateTexture(textureCreationParams);
|
||||
@@ -181,17 +186,19 @@ namespace Nz
|
||||
auto& textureData = m_textures[textureId];
|
||||
textures.push_back(textureData.texture);
|
||||
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
if (textureData.hasFixedSize)
|
||||
unsigned int width = 1;
|
||||
unsigned int height = 1;
|
||||
switch (textureData.size)
|
||||
{
|
||||
width = textureData.width;
|
||||
height = textureData.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = frameWidth * textureData.width / 100'000;
|
||||
height = frameHeight * textureData.height / 100'000;
|
||||
case FramePassAttachmentSize::Fixed:
|
||||
width = textureData.width;
|
||||
height = textureData.height;
|
||||
break;
|
||||
|
||||
case FramePassAttachmentSize::SwapchainFactor:
|
||||
width = frameWidth * textureData.width / 100'000;
|
||||
height = frameHeight * textureData.height / 100'000;
|
||||
break;
|
||||
}
|
||||
|
||||
framebufferWidth = std::min(framebufferWidth, width);
|
||||
|
||||
@@ -581,8 +581,8 @@ namespace Nz
|
||||
lightData->shadowMapAttachmentIndex = frameGraph.AddAttachment({
|
||||
"Shadowmap",
|
||||
shadowMapFormat,
|
||||
FramePassAttachmentSize::Fixed,
|
||||
shadowMapSize, shadowMapSize,
|
||||
true // fixed size
|
||||
});
|
||||
|
||||
if (!lightData->camera)
|
||||
|
||||
@@ -115,10 +115,10 @@ namespace Nz
|
||||
auto& bakedTexture = bakedTextures.emplace_back();
|
||||
bakedTexture.name = std::move(texture.name);
|
||||
bakedTexture.format = texture.format;
|
||||
bakedTexture.hasFixedSize = texture.hasFixedSize;
|
||||
bakedTexture.height = texture.height;
|
||||
bakedTexture.usage = texture.usage;
|
||||
bakedTexture.width = texture.width;
|
||||
bakedTexture.size = texture.size;
|
||||
bakedTexture.usage = texture.usage;
|
||||
bakedTexture.width = texture.width;
|
||||
}
|
||||
|
||||
return BakedFrameGraph(std::move(bakedPasses), std::move(bakedTextures), std::move(m_pending.attachmentToTextures), std::move(m_pending.passIdToPhysicalPassIndex));
|
||||
@@ -954,7 +954,7 @@ namespace Nz
|
||||
if (data.format != attachmentData.format ||
|
||||
data.width != attachmentData.width ||
|
||||
data.height != attachmentData.height ||
|
||||
data.hasFixedSize != attachmentData.hasFixedSize)
|
||||
data.size != attachmentData.size)
|
||||
continue;
|
||||
|
||||
m_pending.texturePool.erase(it);
|
||||
@@ -974,7 +974,7 @@ namespace Nz
|
||||
data.format = attachmentData.format;
|
||||
data.width = attachmentData.width;
|
||||
data.height = attachmentData.height;
|
||||
data.hasFixedSize = attachmentData.hasFixedSize;
|
||||
data.size = attachmentData.size;
|
||||
|
||||
return textureId;
|
||||
}
|
||||
|
||||
@@ -198,15 +198,15 @@ namespace Nz
|
||||
std::size_t offset = indices->first + indices->count;
|
||||
offset *= 4;
|
||||
|
||||
for (std::size_t index : { 0, 2, 1, 3 })
|
||||
for (std::size_t cornerIndex : { 0, 2, 1, 3 })
|
||||
{
|
||||
// Set the position, color and UV of our vertices
|
||||
// Remember that indices->count is a counter here, not a count value
|
||||
m_vertices[offset].color = glyph.color;
|
||||
m_vertices[offset].position = glyph.corners[index];
|
||||
m_vertices[offset].position = glyph.corners[cornerIndex];
|
||||
m_vertices[offset].position.y = bounds.height - m_vertices[offset].position.y;
|
||||
m_vertices[offset].position *= scale;
|
||||
m_vertices[offset].uv.Set(uvRect.GetCorner((glyph.flipped) ? flippedCorners[index] : normalCorners[index]));
|
||||
m_vertices[offset].uv.Set(uvRect.GetCorner((glyph.flipped) ? flippedCorners[cornerIndex] : normalCorners[cornerIndex]));
|
||||
offset++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user