mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[hud] Greatly simplify frame time graph rendering
This commit is contained in:
parent
0709c5f5c7
commit
49e5357a87
@ -226,8 +226,7 @@ namespace dxvk::hud {
|
|||||||
HudPos HudFrameTimeItem::render(
|
HudPos HudFrameTimeItem::render(
|
||||||
HudRenderer& renderer,
|
HudRenderer& renderer,
|
||||||
HudPos position) {
|
HudPos position) {
|
||||||
std::array<HudLineVertex, NumDataPoints * 2> vData;
|
std::array<HudGraphPoint, NumDataPoints> points;
|
||||||
position.y += 40.0f;
|
|
||||||
|
|
||||||
// 60 FPS = optimal, 10 FPS = worst
|
// 60 FPS = optimal, 10 FPS = worst
|
||||||
const float targetUs = 16'666.6f;
|
const float targetUs = 16'666.6f;
|
||||||
@ -255,21 +254,18 @@ namespace dxvk::hud {
|
|||||||
uint8_t(255.0f * (g / l)),
|
uint8_t(255.0f * (g / l)),
|
||||||
uint8_t(0), uint8_t(255) };
|
uint8_t(0), uint8_t(255) };
|
||||||
|
|
||||||
float x = position.x + float(i);
|
|
||||||
float y = position.y;
|
|
||||||
|
|
||||||
float hVal = std::log2(std::max((us - minUs) / targetUs + 1.0f, 1.0f))
|
float hVal = std::log2(std::max((us - minUs) / targetUs + 1.0f, 1.0f))
|
||||||
/ std::log2((maxUs - minUs) / targetUs);
|
/ std::log2((maxUs - minUs) / targetUs);
|
||||||
float h = std::min(std::max(40.0f * hVal, 2.0f), 40.0f);
|
|
||||||
|
|
||||||
vData[2 * i + 0] = HudLineVertex { { x, y }, color };
|
points[i].value = std::max(hVal, 1.0f / 40.0f);
|
||||||
vData[2 * i + 1] = HudLineVertex { { x, y - h }, color };
|
points[i].color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.drawLines(vData.size(), vData.data());
|
renderer.drawGraph(position,
|
||||||
|
HudPos { float(NumDataPoints), 40.0f },
|
||||||
|
points.size(), points.data());
|
||||||
|
|
||||||
// Paint min/max frame times in the entire window
|
position.y += 58.0f;
|
||||||
position.y += 18.0f;
|
|
||||||
|
|
||||||
renderer.drawText(12.0f,
|
renderer.drawText(12.0f,
|
||||||
{ position.x, position.y },
|
{ position.x, position.y },
|
||||||
|
@ -213,7 +213,7 @@ namespace dxvk::hud {
|
|||||||
* \brief HUD item to display the frame rate
|
* \brief HUD item to display the frame rate
|
||||||
*/
|
*/
|
||||||
class HudFrameTimeItem : public HudItem {
|
class HudFrameTimeItem : public HudItem {
|
||||||
constexpr static size_t NumDataPoints = 300;
|
constexpr static size_t NumDataPoints = 304;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HudFrameTimeItem();
|
HudFrameTimeItem();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "dxvk_hud_renderer.h"
|
#include "dxvk_hud_renderer.h"
|
||||||
|
|
||||||
#include <hud_line_frag.h>
|
#include <hud_graph_frag.h>
|
||||||
#include <hud_line_vert.h>
|
#include <hud_graph_vert.h>
|
||||||
|
|
||||||
#include <hud_text_frag.h>
|
#include <hud_text_frag.h>
|
||||||
#include <hud_text_vert.h>
|
#include <hud_text_vert.h>
|
||||||
@ -14,15 +14,14 @@ namespace dxvk::hud {
|
|||||||
m_surfaceSize { 0, 0 },
|
m_surfaceSize { 0, 0 },
|
||||||
m_device (device),
|
m_device (device),
|
||||||
m_textShaders (createTextShaders()),
|
m_textShaders (createTextShaders()),
|
||||||
m_lineShaders (createLineShaders()),
|
m_graphShaders (createGraphShaders()),
|
||||||
m_dataBuffer (createDataBuffer()),
|
m_dataBuffer (createDataBuffer()),
|
||||||
m_dataView (createDataView()),
|
m_dataView (createDataView()),
|
||||||
m_dataOffset (0ull),
|
m_dataOffset (0ull),
|
||||||
m_fontBuffer (createFontBuffer()),
|
m_fontBuffer (createFontBuffer()),
|
||||||
m_fontImage (createFontImage()),
|
m_fontImage (createFontImage()),
|
||||||
m_fontView (createFontView()),
|
m_fontView (createFontView()),
|
||||||
m_fontSampler (createFontSampler()),
|
m_fontSampler (createFontSampler()) {
|
||||||
m_vertexBuffer (createVertexBuffer()) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,8 +39,6 @@ namespace dxvk::hud {
|
|||||||
m_scale = scale;
|
m_scale = scale;
|
||||||
m_surfaceSize = surfaceSize;
|
m_surfaceSize = surfaceSize;
|
||||||
m_context = context;
|
m_context = context;
|
||||||
|
|
||||||
allocVertexBufferSlice();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,42 +76,30 @@ namespace dxvk::hud {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HudRenderer::drawLines(
|
void HudRenderer::drawGraph(
|
||||||
size_t vertexCount,
|
HudPos pos,
|
||||||
const HudLineVertex* vertexData) {
|
HudPos size,
|
||||||
beginLineRendering();
|
size_t pointCount,
|
||||||
|
const HudGraphPoint* pointData) {
|
||||||
|
beginGraphRendering();
|
||||||
|
|
||||||
const float xscale = m_scale / std::max(float(m_surfaceSize.width), 1.0f);
|
VkDeviceSize dataSize = pointCount * sizeof(*pointData);
|
||||||
const float yscale = m_scale / std::max(float(m_surfaceSize.height), 1.0f);
|
VkDeviceSize offset = allocDataBuffer(dataSize);
|
||||||
|
std::memcpy(m_dataBuffer->mapPtr(offset), pointData, dataSize);
|
||||||
|
|
||||||
if (m_currLineVertex + vertexCount > MaxLineVertexCount)
|
HudGraphPushConstants pushData;
|
||||||
allocVertexBufferSlice();
|
pushData.offset = offset / sizeof(*pointData);
|
||||||
|
pushData.count = pointCount;
|
||||||
|
pushData.pos = pos;
|
||||||
|
pushData.size = size;
|
||||||
|
pushData.scale.x = m_scale / std::max(float(m_surfaceSize.width), 1.0f);
|
||||||
|
pushData.scale.y = m_scale / std::max(float(m_surfaceSize.height), 1.0f);
|
||||||
|
|
||||||
m_context->draw(vertexCount, 1, m_currLineVertex, 0);
|
m_context->pushConstants(0, sizeof(pushData), &pushData);
|
||||||
|
m_context->draw(4, 1, 0, 0);
|
||||||
for (size_t i = 0; i < vertexCount; i++) {
|
|
||||||
uint32_t idx = m_currLineVertex + i;
|
|
||||||
|
|
||||||
m_vertexData->lineVertices[idx].position = {
|
|
||||||
xscale * vertexData[i].position.x,
|
|
||||||
yscale * vertexData[i].position.y };
|
|
||||||
m_vertexData->lineVertices[idx].color = vertexData[i].color;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_currLineVertex += vertexCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HudRenderer::allocVertexBufferSlice() {
|
|
||||||
auto vertexSlice = m_vertexBuffer->allocSlice();
|
|
||||||
m_context->invalidateBuffer(m_vertexBuffer, vertexSlice);
|
|
||||||
|
|
||||||
m_currLineVertex = 0;
|
|
||||||
|
|
||||||
m_vertexData = reinterpret_cast<VertexBufferData*>(vertexSlice.mapPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HudRenderer::beginTextRendering() {
|
void HudRenderer::beginTextRendering() {
|
||||||
if (m_mode != Mode::RenderText) {
|
if (m_mode != Mode::RenderText) {
|
||||||
m_mode = Mode::RenderText;
|
m_mode = Mode::RenderText;
|
||||||
@ -137,34 +122,21 @@ namespace dxvk::hud {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HudRenderer::beginLineRendering() {
|
void HudRenderer::beginGraphRendering() {
|
||||||
if (m_mode != Mode::RenderLines) {
|
if (m_mode != Mode::RenderGraph) {
|
||||||
m_mode = Mode::RenderLines;
|
m_mode = Mode::RenderGraph;
|
||||||
|
|
||||||
m_context->bindVertexBuffer(0, DxvkBufferSlice(m_vertexBuffer, offsetof(VertexBufferData, lineVertices), sizeof(HudLineVertex) * MaxLineVertexCount), sizeof(HudLineVertex));
|
m_context->bindShader(VK_SHADER_STAGE_VERTEX_BIT, m_graphShaders.vert);
|
||||||
|
m_context->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, m_graphShaders.frag);
|
||||||
m_context->bindShader(VK_SHADER_STAGE_VERTEX_BIT, m_lineShaders.vert);
|
|
||||||
m_context->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, m_lineShaders.frag);
|
|
||||||
|
|
||||||
|
m_context->bindResourceBuffer(0, DxvkBufferSlice(m_dataBuffer));
|
||||||
|
|
||||||
static const DxvkInputAssemblyState iaState = {
|
static const DxvkInputAssemblyState iaState = {
|
||||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
|
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
|
||||||
VK_FALSE, 0 };
|
VK_FALSE, 0 };
|
||||||
|
|
||||||
static const std::array<DxvkVertexAttribute, 2> ilAttributes = {{
|
|
||||||
{ 0, 0, VK_FORMAT_R32G32_SFLOAT, offsetof(HudLineVertex, position) },
|
|
||||||
{ 1, 0, VK_FORMAT_R8G8B8A8_UNORM, offsetof(HudLineVertex, color) },
|
|
||||||
}};
|
|
||||||
|
|
||||||
static const std::array<DxvkVertexBinding, 1> ilBindings = {{
|
|
||||||
{ 0, 0, VK_VERTEX_INPUT_RATE_VERTEX },
|
|
||||||
}};
|
|
||||||
|
|
||||||
m_context->setInputAssemblyState(iaState);
|
m_context->setInputAssemblyState(iaState);
|
||||||
m_context->setInputLayout(
|
m_context->setInputLayout(0, nullptr, 0, nullptr);
|
||||||
ilAttributes.size(),
|
|
||||||
ilAttributes.data(),
|
|
||||||
ilBindings.size(),
|
|
||||||
ilBindings.data());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,19 +186,27 @@ namespace dxvk::hud {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HudRenderer::ShaderPair HudRenderer::createLineShaders() {
|
HudRenderer::ShaderPair HudRenderer::createGraphShaders() {
|
||||||
ShaderPair result;
|
ShaderPair result;
|
||||||
|
|
||||||
const SpirvCodeBuffer vsCode(hud_line_vert);
|
const SpirvCodeBuffer vsCode(hud_graph_vert);
|
||||||
const SpirvCodeBuffer fsCode(hud_line_frag);
|
const SpirvCodeBuffer fsCode(hud_graph_frag);
|
||||||
|
|
||||||
|
const std::array<DxvkResourceSlot, 1> fsResources = {{
|
||||||
|
{ 0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_IMAGE_VIEW_TYPE_MAX_ENUM },
|
||||||
|
}};
|
||||||
|
|
||||||
result.vert = m_device->createShader(
|
result.vert = m_device->createShader(
|
||||||
VK_SHADER_STAGE_VERTEX_BIT,
|
VK_SHADER_STAGE_VERTEX_BIT, 0, nullptr,
|
||||||
0, nullptr, { 0x3, 0x1 }, vsCode);
|
{ 0x3, 0x1, 0, sizeof(HudGraphPushConstants) },
|
||||||
|
vsCode);
|
||||||
|
|
||||||
result.frag = m_device->createShader(
|
result.frag = m_device->createShader(
|
||||||
VK_SHADER_STAGE_FRAGMENT_BIT,
|
VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||||
0, nullptr, { 0x1, 0x1 }, fsCode);
|
fsResources.size(),
|
||||||
|
fsResources.data(),
|
||||||
|
{ 0x1, 0x1, 0, sizeof(HudGraphPushConstants) },
|
||||||
|
fsCode);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -331,20 +311,6 @@ namespace dxvk::hud {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Rc<DxvkBuffer> HudRenderer::createVertexBuffer() {
|
|
||||||
DxvkBufferCreateInfo info;
|
|
||||||
info.size = sizeof(VertexBufferData);
|
|
||||||
info.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
|
|
||||||
info.stages = VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
|
|
||||||
info.access = VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
|
|
||||||
|
|
||||||
return m_device->createBuffer(info,
|
|
||||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
|
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
|
|
||||||
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HudRenderer::initFontTexture(
|
void HudRenderer::initFontTexture(
|
||||||
const Rc<DxvkContext>& context) {
|
const Rc<DxvkContext>& context) {
|
||||||
HudFontGpuData gpuData = { };
|
HudFontGpuData gpuData = { };
|
||||||
|
@ -32,20 +32,21 @@ namespace dxvk::hud {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Normalized color
|
* \brief Normalized color
|
||||||
|
*
|
||||||
* SRGB color with alpha channel.
|
* SRGB color with alpha channel.
|
||||||
*/
|
*/
|
||||||
struct HudNormColor {
|
struct HudNormColor {
|
||||||
uint8_t r;
|
|
||||||
uint8_t g;
|
|
||||||
uint8_t b;
|
|
||||||
uint8_t a;
|
uint8_t a;
|
||||||
|
uint8_t b;
|
||||||
|
uint8_t g;
|
||||||
|
uint8_t r;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Line vertex and color
|
* \brief Graph point with color
|
||||||
*/
|
*/
|
||||||
struct HudLineVertex {
|
struct HudGraphPoint {
|
||||||
HudPos position;
|
float value;
|
||||||
HudNormColor color;
|
HudNormColor color;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,6 +61,14 @@ namespace dxvk::hud {
|
|||||||
HudPos scale;
|
HudPos scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct HudGraphPushConstants {
|
||||||
|
uint32_t offset;
|
||||||
|
uint32_t count;
|
||||||
|
HudPos pos;
|
||||||
|
HudPos size;
|
||||||
|
HudPos scale;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Glyph data
|
* \brief Glyph data
|
||||||
*/
|
*/
|
||||||
@ -87,11 +96,6 @@ namespace dxvk::hud {
|
|||||||
*/
|
*/
|
||||||
class HudRenderer {
|
class HudRenderer {
|
||||||
constexpr static VkDeviceSize DataBufferSize = 16384;
|
constexpr static VkDeviceSize DataBufferSize = 16384;
|
||||||
constexpr static uint32_t MaxLineVertexCount = 1024;
|
|
||||||
|
|
||||||
struct VertexBufferData {
|
|
||||||
HudLineVertex lineVertices[MaxLineVertexCount];
|
|
||||||
};
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HudRenderer(
|
HudRenderer(
|
||||||
@ -110,9 +114,11 @@ namespace dxvk::hud {
|
|||||||
HudColor color,
|
HudColor color,
|
||||||
const std::string& text);
|
const std::string& text);
|
||||||
|
|
||||||
void drawLines(
|
void drawGraph(
|
||||||
size_t vertexCount,
|
HudPos pos,
|
||||||
const HudLineVertex* vertexData);
|
HudPos size,
|
||||||
|
size_t pointCount,
|
||||||
|
const HudGraphPoint* pointData);
|
||||||
|
|
||||||
VkExtent2D surfaceSize() const {
|
VkExtent2D surfaceSize() const {
|
||||||
return m_surfaceSize;
|
return m_surfaceSize;
|
||||||
@ -127,7 +133,7 @@ namespace dxvk::hud {
|
|||||||
enum class Mode {
|
enum class Mode {
|
||||||
RenderNone,
|
RenderNone,
|
||||||
RenderText,
|
RenderText,
|
||||||
RenderLines,
|
RenderGraph,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ShaderPair {
|
struct ShaderPair {
|
||||||
@ -143,7 +149,7 @@ namespace dxvk::hud {
|
|||||||
Rc<DxvkContext> m_context;
|
Rc<DxvkContext> m_context;
|
||||||
|
|
||||||
ShaderPair m_textShaders;
|
ShaderPair m_textShaders;
|
||||||
ShaderPair m_lineShaders;
|
ShaderPair m_graphShaders;
|
||||||
|
|
||||||
Rc<DxvkBuffer> m_dataBuffer;
|
Rc<DxvkBuffer> m_dataBuffer;
|
||||||
Rc<DxvkBufferView> m_dataView;
|
Rc<DxvkBufferView> m_dataView;
|
||||||
@ -153,24 +159,17 @@ namespace dxvk::hud {
|
|||||||
Rc<DxvkImage> m_fontImage;
|
Rc<DxvkImage> m_fontImage;
|
||||||
Rc<DxvkImageView> m_fontView;
|
Rc<DxvkImageView> m_fontView;
|
||||||
Rc<DxvkSampler> m_fontSampler;
|
Rc<DxvkSampler> m_fontSampler;
|
||||||
|
|
||||||
Rc<DxvkBuffer> m_vertexBuffer;
|
|
||||||
VertexBufferData* m_vertexData = nullptr;
|
|
||||||
|
|
||||||
uint32_t m_currLineVertex = 0;
|
|
||||||
|
|
||||||
bool m_initialized = false;
|
bool m_initialized = false;
|
||||||
|
|
||||||
void allocVertexBufferSlice();
|
|
||||||
|
|
||||||
void beginTextRendering();
|
void beginTextRendering();
|
||||||
|
|
||||||
void beginLineRendering();
|
void beginGraphRendering();
|
||||||
|
|
||||||
VkDeviceSize allocDataBuffer(VkDeviceSize size);
|
VkDeviceSize allocDataBuffer(VkDeviceSize size);
|
||||||
|
|
||||||
ShaderPair createTextShaders();
|
ShaderPair createTextShaders();
|
||||||
ShaderPair createLineShaders();
|
ShaderPair createGraphShaders();
|
||||||
|
|
||||||
Rc<DxvkBuffer> createDataBuffer();
|
Rc<DxvkBuffer> createDataBuffer();
|
||||||
Rc<DxvkBufferView> createDataView();
|
Rc<DxvkBufferView> createDataView();
|
||||||
@ -179,8 +178,6 @@ namespace dxvk::hud {
|
|||||||
Rc<DxvkImage> createFontImage();
|
Rc<DxvkImage> createFontImage();
|
||||||
Rc<DxvkImageView> createFontView();
|
Rc<DxvkImageView> createFontView();
|
||||||
Rc<DxvkSampler> createFontSampler();
|
Rc<DxvkSampler> createFontSampler();
|
||||||
|
|
||||||
Rc<DxvkBuffer> createVertexBuffer();
|
|
||||||
|
|
||||||
void initFontTexture(
|
void initFontTexture(
|
||||||
const Rc<DxvkContext>& context);
|
const Rc<DxvkContext>& context);
|
||||||
|
61
src/dxvk/hud/shaders/hud_graph_frag.frag
Normal file
61
src/dxvk/hud/shaders/hud_graph_frag.frag
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#version 450
|
||||||
|
|
||||||
|
layout(constant_id = 1225) const bool srgbSwapchain = false;
|
||||||
|
|
||||||
|
layout(location = 0) in vec2 v_coord;
|
||||||
|
layout(location = 0) out vec4 o_color;
|
||||||
|
|
||||||
|
struct line_point_t {
|
||||||
|
float value;
|
||||||
|
uint color;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(binding = 0, std430)
|
||||||
|
readonly buffer line_data_t {
|
||||||
|
line_point_t points[];
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(push_constant)
|
||||||
|
uniform push_data_t {
|
||||||
|
uint offset;
|
||||||
|
uint count;
|
||||||
|
vec2 pos;
|
||||||
|
vec2 size;
|
||||||
|
vec2 scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
vec3 linearToSrgb(vec3 color) {
|
||||||
|
bvec3 isLo = lessThanEqual(color, vec3(0.0031308f));
|
||||||
|
|
||||||
|
vec3 loPart = color * 12.92f;
|
||||||
|
vec3 hiPart = pow(color, vec3(5.0f / 12.0f)) * 1.055f - 0.055f;
|
||||||
|
return mix(hiPart, loPart, isLo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
float cx = v_coord.x * float(count);
|
||||||
|
float fx = fract(cx);
|
||||||
|
|
||||||
|
// We need to roll our own linear interpolation here
|
||||||
|
uint p0_idx = min(uint(floor(cx)), count - 1) + offset;
|
||||||
|
uint p1_idx = min(uint(ceil(cx)), count - 1) + offset;
|
||||||
|
|
||||||
|
line_point_t p0 = points[p0_idx];
|
||||||
|
line_point_t p1 = points[p1_idx];
|
||||||
|
|
||||||
|
float value = mix(p0.value, p1.value, fx);
|
||||||
|
float alpha = value + v_coord.y - 1.0f;
|
||||||
|
alpha = min(alpha / dFdy(v_coord.y), 1.0f);
|
||||||
|
|
||||||
|
if (alpha <= 0.0f)
|
||||||
|
discard;
|
||||||
|
|
||||||
|
o_color = mix(
|
||||||
|
unpackUnorm4x8(p0.color),
|
||||||
|
unpackUnorm4x8(p1.color), fx);
|
||||||
|
|
||||||
|
if (!srgbSwapchain)
|
||||||
|
o_color.rgb = linearToSrgb(o_color.rgb);
|
||||||
|
|
||||||
|
o_color *= alpha;
|
||||||
|
}
|
23
src/dxvk/hud/shaders/hud_graph_vert.vert
Normal file
23
src/dxvk/hud/shaders/hud_graph_vert.vert
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#version 450
|
||||||
|
|
||||||
|
layout(location = 0) out vec2 o_coord;
|
||||||
|
|
||||||
|
layout(push_constant)
|
||||||
|
uniform push_data_t {
|
||||||
|
uint offset;
|
||||||
|
uint count;
|
||||||
|
vec2 pos;
|
||||||
|
vec2 size;
|
||||||
|
vec2 scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec2 coord = vec2(
|
||||||
|
float(gl_VertexIndex & 1),
|
||||||
|
float(gl_VertexIndex >> 1));
|
||||||
|
o_coord = coord;
|
||||||
|
|
||||||
|
vec2 pixel_pos = pos + size * coord;
|
||||||
|
vec2 scaled_pos = 2.0f * scale * pixel_pos - 1.0f;
|
||||||
|
gl_Position = vec4(scaled_pos, 0.0f, 1.0f);
|
||||||
|
}
|
@ -1,23 +0,0 @@
|
|||||||
#version 450
|
|
||||||
|
|
||||||
layout(constant_id = 1225) const bool srgbSwapchain = false;
|
|
||||||
|
|
||||||
layout(location = 0) in vec4 v_color;
|
|
||||||
layout(location = 0) out vec4 o_color;
|
|
||||||
|
|
||||||
vec3 linearToSrgb(vec3 color) {
|
|
||||||
bvec3 isLo = lessThanEqual(color, vec3(0.0031308f));
|
|
||||||
|
|
||||||
vec3 loPart = color * 12.92f;
|
|
||||||
vec3 hiPart = pow(color, vec3(5.0f / 12.0f)) * 1.055f - 0.055f;
|
|
||||||
return mix(hiPart, loPart, isLo);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
o_color = vec4(
|
|
||||||
v_color.rgb * v_color.a,
|
|
||||||
v_color.a);
|
|
||||||
|
|
||||||
if (!srgbSwapchain)
|
|
||||||
o_color.rgb = linearToSrgb(o_color.rgb);
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
#version 450
|
|
||||||
|
|
||||||
layout(location = 0) in vec2 v_position;
|
|
||||||
layout(location = 1) in vec4 v_color;
|
|
||||||
|
|
||||||
layout(location = 0) out vec4 o_color;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
o_color = v_color;
|
|
||||||
|
|
||||||
vec2 pos = 2.0f * v_position - 1.0f;
|
|
||||||
gl_Position = vec4(pos, 0.0f, 1.0f);
|
|
||||||
}
|
|
@ -51,8 +51,8 @@ dxvk_shaders = files([
|
|||||||
'shaders/dxvk_unpack_d24s8.comp',
|
'shaders/dxvk_unpack_d24s8.comp',
|
||||||
'shaders/dxvk_unpack_d32s8.comp',
|
'shaders/dxvk_unpack_d32s8.comp',
|
||||||
|
|
||||||
'hud/shaders/hud_line_frag.frag',
|
'hud/shaders/hud_graph_frag.frag',
|
||||||
'hud/shaders/hud_line_vert.vert',
|
'hud/shaders/hud_graph_vert.vert',
|
||||||
|
|
||||||
'hud/shaders/hud_text_frag.frag',
|
'hud/shaders/hud_text_frag.frag',
|
||||||
'hud/shaders/hud_text_vert.vert',
|
'hud/shaders/hud_text_vert.vert',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user