Graphics/FrameGraph: Add FramePassAttachmentSize enum instead of boolean
This commit is contained in:
parent
d6b9b4327a
commit
d7eab778fb
|
|
@ -719,6 +719,7 @@ int main()
|
|||
godRaysTexture = graph.AddAttachment({
|
||||
"God rays texture",
|
||||
Nz::PixelFormat::RGBA16F,
|
||||
Nz::FramePassAttachmentSize::SwapchainFactor,
|
||||
50'000,
|
||||
50'000
|
||||
});
|
||||
|
|
@ -729,6 +730,7 @@ int main()
|
|||
bloomBrightOutput = graph.AddAttachment({
|
||||
"Bloom bright output",
|
||||
Nz::PixelFormat::RGBA16F,
|
||||
Nz::FramePassAttachmentSize::SwapchainFactor,
|
||||
bloomSize,
|
||||
bloomSize
|
||||
});
|
||||
|
|
@ -738,6 +740,7 @@ int main()
|
|||
bloomTextures[i * 2 + 0] = graph.AddAttachment({
|
||||
"Bloom texture #" + std::to_string(i),
|
||||
Nz::PixelFormat::RGBA16F,
|
||||
Nz::FramePassAttachmentSize::SwapchainFactor,
|
||||
bloomSize,
|
||||
bloomSize
|
||||
});
|
||||
|
|
@ -746,6 +749,7 @@ int main()
|
|||
bloomTextures[i * 2 + 1] = graph.AddAttachment({
|
||||
"Bloom texture #" + std::to_string(i),
|
||||
Nz::PixelFormat::RGBA16F,
|
||||
Nz::FramePassAttachmentSize::SwapchainFactor,
|
||||
bloomSize,
|
||||
bloomSize
|
||||
});
|
||||
|
|
@ -756,6 +760,7 @@ int main()
|
|||
toneMappingOutput = graph.AddAttachment({
|
||||
"Tone mapping",
|
||||
Nz::PixelFormat::RGBA8,
|
||||
Nz::FramePassAttachmentSize::SwapchainFactor,
|
||||
100'000,
|
||||
100'000
|
||||
});
|
||||
|
|
|
|||
|
|
@ -85,11 +85,11 @@ namespace Nz
|
|||
{
|
||||
std::string name;
|
||||
std::shared_ptr<Texture> texture;
|
||||
FramePassAttachmentSize size;
|
||||
PixelFormat format;
|
||||
TextureUsageFlags usage;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
bool hasFixedSize;
|
||||
};
|
||||
|
||||
std::shared_ptr<CommandPool> m_commandPool;
|
||||
|
|
|
|||
|
|
@ -88,10 +88,10 @@ namespace Nz
|
|||
{
|
||||
std::string name;
|
||||
PixelFormat format;
|
||||
FramePassAttachmentSize size;
|
||||
TextureUsageFlags usage;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
bool hasFixedSize;
|
||||
};
|
||||
|
||||
struct WorkData
|
||||
|
|
|
|||
|
|
@ -14,13 +14,19 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
enum class FramePassAttachmentSize
|
||||
{
|
||||
Fixed,
|
||||
SwapchainFactor
|
||||
};
|
||||
|
||||
struct FramePassAttachment
|
||||
{
|
||||
std::string name;
|
||||
PixelFormat format;
|
||||
FramePassAttachmentSize size = FramePassAttachmentSize::SwapchainFactor;
|
||||
unsigned int width = 100'000;
|
||||
unsigned int height = 100'000;
|
||||
bool hasFixedSize = false;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue