1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-21 13:54:18 +01:00

[hud] Don't create uniform buffer

No longer used.
This commit is contained in:
Philip Rebohle 2019-12-15 23:17:23 +01:00
parent 9c6ff95bb6
commit 13d2479ecf
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 9 additions and 62 deletions

View File

@ -7,7 +7,6 @@ namespace dxvk::hud {
Hud::Hud( Hud::Hud(
const Rc<DxvkDevice>& device) const Rc<DxvkDevice>& device)
: m_device (device), : m_device (device),
m_uniformBuffer (createUniformBuffer()),
m_renderer (device) { m_renderer (device) {
// Set up constant state // Set up constant state
m_rsState.polygonMode = VK_POLYGON_MODE_FILL; m_rsState.polygonMode = VK_POLYGON_MODE_FILL;
@ -57,11 +56,7 @@ namespace dxvk::hud {
const Rc<DxvkContext>& ctx, const Rc<DxvkContext>& ctx,
VkSurfaceFormatKHR surfaceFormat, VkSurfaceFormatKHR surfaceFormat,
VkExtent2D surfaceSize) { VkExtent2D surfaceSize) {
m_uniformData.surfaceSize = surfaceSize; this->setupRendererState(ctx, surfaceFormat, surfaceSize);
this->updateUniformBuffer(ctx, m_uniformData);
this->setupRendererState(ctx, surfaceFormat);
this->renderHudElements(ctx); this->renderHudElements(ctx);
this->resetRendererState(ctx); this->resetRendererState(ctx);
} }
@ -74,17 +69,15 @@ namespace dxvk::hud {
void Hud::setupRendererState( void Hud::setupRendererState(
const Rc<DxvkContext>& ctx, const Rc<DxvkContext>& ctx,
VkSurfaceFormatKHR surfaceFormat) { VkSurfaceFormatKHR surfaceFormat,
VkExtent2D surfaceSize) {
bool isSrgb = imageFormatInfo(surfaceFormat.format)->flags.test(DxvkFormatFlag::ColorSpaceSrgb); bool isSrgb = imageFormatInfo(surfaceFormat.format)->flags.test(DxvkFormatFlag::ColorSpaceSrgb);
ctx->setRasterizerState(m_rsState); ctx->setRasterizerState(m_rsState);
ctx->setBlendMode(0, m_blendMode); ctx->setBlendMode(0, m_blendMode);
ctx->bindResourceBuffer(0,
DxvkBufferSlice(m_uniformBuffer));
ctx->setSpecConstant(VK_PIPELINE_BIND_POINT_GRAPHICS, 0, isSrgb); ctx->setSpecConstant(VK_PIPELINE_BIND_POINT_GRAPHICS, 0, isSrgb);
m_renderer.beginFrame(ctx, m_uniformData.surfaceSize); m_renderer.beginFrame(ctx, surfaceSize);
} }
@ -97,26 +90,4 @@ namespace dxvk::hud {
m_hudItems.render(m_renderer); m_hudItems.render(m_renderer);
} }
void Hud::updateUniformBuffer(const Rc<DxvkContext>& ctx, const HudUniformData& data) {
auto slice = m_uniformBuffer->allocSlice();
std::memcpy(slice.mapPtr, &data, sizeof(data));
ctx->invalidateBuffer(m_uniformBuffer, slice);
}
Rc<DxvkBuffer> Hud::createUniformBuffer() {
DxvkBufferCreateInfo info;
info.size = sizeof(HudUniformData);
info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
info.stages = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
| VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
info.access = VK_ACCESS_UNIFORM_READ_BIT;
return m_device->createBuffer(info,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
}
} }

View File

@ -76,8 +76,6 @@ namespace dxvk::hud {
const Rc<DxvkDevice> m_device; const Rc<DxvkDevice> m_device;
Rc<DxvkBuffer> m_uniformBuffer;
DxvkRasterizerState m_rsState; DxvkRasterizerState m_rsState;
DxvkBlendMode m_blendMode; DxvkBlendMode m_blendMode;
@ -87,19 +85,14 @@ namespace dxvk::hud {
void setupRendererState( void setupRendererState(
const Rc<DxvkContext>& ctx, const Rc<DxvkContext>& ctx,
VkSurfaceFormatKHR surfaceFormat); VkSurfaceFormatKHR surfaceFormat,
VkExtent2D surfaceSize);
void resetRendererState( void resetRendererState(
const Rc<DxvkContext>& ctx); const Rc<DxvkContext>& ctx);
void renderHudElements( void renderHudElements(
const Rc<DxvkContext>& ctx); const Rc<DxvkContext>& ctx);
void updateUniformBuffer(
const Rc<DxvkContext>& ctx,
const HudUniformData& data);
Rc<DxvkBuffer> createUniformBuffer();
}; };

View File

@ -208,11 +208,6 @@ namespace dxvk::hud {
const SpirvCodeBuffer vsCode(hud_text_vert); const SpirvCodeBuffer vsCode(hud_text_vert);
const SpirvCodeBuffer fsCode(hud_text_frag); const SpirvCodeBuffer fsCode(hud_text_frag);
// One shader resource: Global HUD uniform buffer
const std::array<DxvkResourceSlot, 1> vsResources = {{
{ 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_IMAGE_VIEW_TYPE_MAX_ENUM },
}};
// Two shader resources: Font texture and sampler // Two shader resources: Font texture and sampler
const std::array<DxvkResourceSlot, 1> fsResources = {{ const std::array<DxvkResourceSlot, 1> fsResources = {{
{ 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_IMAGE_VIEW_TYPE_2D }, { 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_IMAGE_VIEW_TYPE_2D },
@ -220,10 +215,7 @@ namespace dxvk::hud {
result.vert = device->createShader( result.vert = device->createShader(
VK_SHADER_STAGE_VERTEX_BIT, VK_SHADER_STAGE_VERTEX_BIT,
vsResources.size(), 0, nullptr, { 0x3, 0x1 }, vsCode);
vsResources.data(),
{ 0x3, 0x1 },
vsCode);
result.frag = device->createShader( result.frag = device->createShader(
VK_SHADER_STAGE_FRAGMENT_BIT, VK_SHADER_STAGE_FRAGMENT_BIT,
@ -242,22 +234,13 @@ namespace dxvk::hud {
const SpirvCodeBuffer vsCode(hud_line_vert); const SpirvCodeBuffer vsCode(hud_line_vert);
const SpirvCodeBuffer fsCode(hud_line_frag); const SpirvCodeBuffer fsCode(hud_line_frag);
// One shader resource: Global HUD uniform buffer
const std::array<DxvkResourceSlot, 1> vsResources = {{
{ 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_IMAGE_VIEW_TYPE_MAX_ENUM },
}};
result.vert = device->createShader( result.vert = device->createShader(
VK_SHADER_STAGE_VERTEX_BIT, VK_SHADER_STAGE_VERTEX_BIT,
vsResources.size(), 0, nullptr, { 0x3, 0x1 }, vsCode);
vsResources.data(),
{ 0x3, 0x1 },
vsCode);
result.frag = device->createShader( result.frag = device->createShader(
VK_SHADER_STAGE_FRAGMENT_BIT, VK_SHADER_STAGE_FRAGMENT_BIT,
0, nullptr, { 0x1, 0x1 }, 0, nullptr, { 0x1, 0x1 }, fsCode);
fsCode);
return result; return result;
} }