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({
|
godRaysTexture = graph.AddAttachment({
|
||||||
"God rays texture",
|
"God rays texture",
|
||||||
Nz::PixelFormat::RGBA16F,
|
Nz::PixelFormat::RGBA16F,
|
||||||
|
Nz::FramePassAttachmentSize::SwapchainFactor,
|
||||||
50'000,
|
50'000,
|
||||||
50'000
|
50'000
|
||||||
});
|
});
|
||||||
|
|
@ -729,6 +730,7 @@ int main()
|
||||||
bloomBrightOutput = graph.AddAttachment({
|
bloomBrightOutput = graph.AddAttachment({
|
||||||
"Bloom bright output",
|
"Bloom bright output",
|
||||||
Nz::PixelFormat::RGBA16F,
|
Nz::PixelFormat::RGBA16F,
|
||||||
|
Nz::FramePassAttachmentSize::SwapchainFactor,
|
||||||
bloomSize,
|
bloomSize,
|
||||||
bloomSize
|
bloomSize
|
||||||
});
|
});
|
||||||
|
|
@ -738,6 +740,7 @@ int main()
|
||||||
bloomTextures[i * 2 + 0] = graph.AddAttachment({
|
bloomTextures[i * 2 + 0] = graph.AddAttachment({
|
||||||
"Bloom texture #" + std::to_string(i),
|
"Bloom texture #" + std::to_string(i),
|
||||||
Nz::PixelFormat::RGBA16F,
|
Nz::PixelFormat::RGBA16F,
|
||||||
|
Nz::FramePassAttachmentSize::SwapchainFactor,
|
||||||
bloomSize,
|
bloomSize,
|
||||||
bloomSize
|
bloomSize
|
||||||
});
|
});
|
||||||
|
|
@ -746,6 +749,7 @@ int main()
|
||||||
bloomTextures[i * 2 + 1] = graph.AddAttachment({
|
bloomTextures[i * 2 + 1] = graph.AddAttachment({
|
||||||
"Bloom texture #" + std::to_string(i),
|
"Bloom texture #" + std::to_string(i),
|
||||||
Nz::PixelFormat::RGBA16F,
|
Nz::PixelFormat::RGBA16F,
|
||||||
|
Nz::FramePassAttachmentSize::SwapchainFactor,
|
||||||
bloomSize,
|
bloomSize,
|
||||||
bloomSize
|
bloomSize
|
||||||
});
|
});
|
||||||
|
|
@ -756,6 +760,7 @@ int main()
|
||||||
toneMappingOutput = graph.AddAttachment({
|
toneMappingOutput = graph.AddAttachment({
|
||||||
"Tone mapping",
|
"Tone mapping",
|
||||||
Nz::PixelFormat::RGBA8,
|
Nz::PixelFormat::RGBA8,
|
||||||
|
Nz::FramePassAttachmentSize::SwapchainFactor,
|
||||||
100'000,
|
100'000,
|
||||||
100'000
|
100'000
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -85,11 +85,11 @@ namespace Nz
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
std::shared_ptr<Texture> texture;
|
std::shared_ptr<Texture> texture;
|
||||||
|
FramePassAttachmentSize size;
|
||||||
PixelFormat format;
|
PixelFormat format;
|
||||||
TextureUsageFlags usage;
|
TextureUsageFlags usage;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
bool hasFixedSize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::shared_ptr<CommandPool> m_commandPool;
|
std::shared_ptr<CommandPool> m_commandPool;
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,10 @@ namespace Nz
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
PixelFormat format;
|
PixelFormat format;
|
||||||
|
FramePassAttachmentSize size;
|
||||||
TextureUsageFlags usage;
|
TextureUsageFlags usage;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
bool hasFixedSize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WorkData
|
struct WorkData
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,19 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
enum class FramePassAttachmentSize
|
||||||
|
{
|
||||||
|
Fixed,
|
||||||
|
SwapchainFactor
|
||||||
|
};
|
||||||
|
|
||||||
struct FramePassAttachment
|
struct FramePassAttachment
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
PixelFormat format;
|
PixelFormat format;
|
||||||
|
FramePassAttachmentSize size = FramePassAttachmentSize::SwapchainFactor;
|
||||||
unsigned int width = 100'000;
|
unsigned int width = 100'000;
|
||||||
unsigned int height = 100'000;
|
unsigned int height = 100'000;
|
||||||
bool hasFixedSize = false;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,15 +153,20 @@ namespace Nz
|
||||||
textureCreationParams.type = ImageType::E2D;
|
textureCreationParams.type = ImageType::E2D;
|
||||||
textureCreationParams.usageFlags = textureData.usage;
|
textureCreationParams.usageFlags = textureData.usage;
|
||||||
textureCreationParams.pixelFormat = textureData.format;
|
textureCreationParams.pixelFormat = textureData.format;
|
||||||
if (textureData.hasFixedSize)
|
|
||||||
|
textureCreationParams.width = 1;
|
||||||
|
textureCreationParams.height = 1;
|
||||||
|
switch (textureData.size)
|
||||||
{
|
{
|
||||||
textureCreationParams.width = textureData.width;
|
case FramePassAttachmentSize::Fixed:
|
||||||
textureCreationParams.height = textureData.height;
|
textureCreationParams.width = textureData.width;
|
||||||
}
|
textureCreationParams.height = textureData.height;
|
||||||
else
|
break;
|
||||||
{
|
|
||||||
textureCreationParams.width = textureData.width * frameWidth / 100'000;
|
case FramePassAttachmentSize::SwapchainFactor:
|
||||||
textureCreationParams.height = textureData.height * frameHeight / 100'000;
|
textureCreationParams.width = frameWidth * textureData.width / 100'000;
|
||||||
|
textureCreationParams.height = frameHeight * textureData.height / 100'000;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
textureData.texture = renderDevice->InstantiateTexture(textureCreationParams);
|
textureData.texture = renderDevice->InstantiateTexture(textureCreationParams);
|
||||||
|
|
@ -181,17 +186,19 @@ namespace Nz
|
||||||
auto& textureData = m_textures[textureId];
|
auto& textureData = m_textures[textureId];
|
||||||
textures.push_back(textureData.texture);
|
textures.push_back(textureData.texture);
|
||||||
|
|
||||||
unsigned int width;
|
unsigned int width = 1;
|
||||||
unsigned int height;
|
unsigned int height = 1;
|
||||||
if (textureData.hasFixedSize)
|
switch (textureData.size)
|
||||||
{
|
{
|
||||||
width = textureData.width;
|
case FramePassAttachmentSize::Fixed:
|
||||||
height = textureData.height;
|
width = textureData.width;
|
||||||
}
|
height = textureData.height;
|
||||||
else
|
break;
|
||||||
{
|
|
||||||
width = frameWidth * textureData.width / 100'000;
|
case FramePassAttachmentSize::SwapchainFactor:
|
||||||
height = frameHeight * textureData.height / 100'000;
|
width = frameWidth * textureData.width / 100'000;
|
||||||
|
height = frameHeight * textureData.height / 100'000;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
framebufferWidth = std::min(framebufferWidth, width);
|
framebufferWidth = std::min(framebufferWidth, width);
|
||||||
|
|
|
||||||
|
|
@ -581,8 +581,8 @@ namespace Nz
|
||||||
lightData->shadowMapAttachmentIndex = frameGraph.AddAttachment({
|
lightData->shadowMapAttachmentIndex = frameGraph.AddAttachment({
|
||||||
"Shadowmap",
|
"Shadowmap",
|
||||||
shadowMapFormat,
|
shadowMapFormat,
|
||||||
|
FramePassAttachmentSize::Fixed,
|
||||||
shadowMapSize, shadowMapSize,
|
shadowMapSize, shadowMapSize,
|
||||||
true // fixed size
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!lightData->camera)
|
if (!lightData->camera)
|
||||||
|
|
|
||||||
|
|
@ -115,10 +115,10 @@ namespace Nz
|
||||||
auto& bakedTexture = bakedTextures.emplace_back();
|
auto& bakedTexture = bakedTextures.emplace_back();
|
||||||
bakedTexture.name = std::move(texture.name);
|
bakedTexture.name = std::move(texture.name);
|
||||||
bakedTexture.format = texture.format;
|
bakedTexture.format = texture.format;
|
||||||
bakedTexture.hasFixedSize = texture.hasFixedSize;
|
|
||||||
bakedTexture.height = texture.height;
|
bakedTexture.height = texture.height;
|
||||||
bakedTexture.usage = texture.usage;
|
bakedTexture.size = texture.size;
|
||||||
bakedTexture.width = texture.width;
|
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));
|
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 ||
|
if (data.format != attachmentData.format ||
|
||||||
data.width != attachmentData.width ||
|
data.width != attachmentData.width ||
|
||||||
data.height != attachmentData.height ||
|
data.height != attachmentData.height ||
|
||||||
data.hasFixedSize != attachmentData.hasFixedSize)
|
data.size != attachmentData.size)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
m_pending.texturePool.erase(it);
|
m_pending.texturePool.erase(it);
|
||||||
|
|
@ -974,7 +974,7 @@ namespace Nz
|
||||||
data.format = attachmentData.format;
|
data.format = attachmentData.format;
|
||||||
data.width = attachmentData.width;
|
data.width = attachmentData.width;
|
||||||
data.height = attachmentData.height;
|
data.height = attachmentData.height;
|
||||||
data.hasFixedSize = attachmentData.hasFixedSize;
|
data.size = attachmentData.size;
|
||||||
|
|
||||||
return textureId;
|
return textureId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -198,15 +198,15 @@ namespace Nz
|
||||||
std::size_t offset = indices->first + indices->count;
|
std::size_t offset = indices->first + indices->count;
|
||||||
offset *= 4;
|
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
|
// Set the position, color and UV of our vertices
|
||||||
// Remember that indices->count is a counter here, not a count value
|
// Remember that indices->count is a counter here, not a count value
|
||||||
m_vertices[offset].color = glyph.color;
|
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.y = bounds.height - m_vertices[offset].position.y;
|
||||||
m_vertices[offset].position *= scale;
|
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++;
|
offset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue