mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add SalCRT Sharp
This commit is contained in:
parent
aff5cc05ac
commit
0072170b2e
8 changed files with 70 additions and 3 deletions
|
|
@ -431,7 +431,7 @@ consvar_t cv_scr_depth = Player("scr_depth", "16 bits").values({{8, "8 bits"}, {
|
|||
//added : 03-02-98: default screen mode, as loaded/saved in config
|
||||
consvar_t cv_scr_width = Player("scr_width", "640").values(CV_Unsigned);
|
||||
consvar_t cv_scr_height = Player("scr_height", "400").values(CV_Unsigned);
|
||||
consvar_t cv_scr_effect = Player("scr_effect", "Sharp Bilinear").values({{0, "Nearest"}, {1, "Sharp Bilinear"}, {2, "SalCRT"}}).save();
|
||||
consvar_t cv_scr_effect = Player("scr_effect", "Sharp Bilinear").values({{0, "Nearest"}, {1, "Sharp Bilinear"}, {2, "SalCRT"}, {3, "SalCRT Sharp"}}).save();
|
||||
|
||||
consvar_t cv_scr_scale = Player("scr_scale", "1.0").floating_point();
|
||||
consvar_t cv_scr_x = Player("scr_x", "0.0").floating_point();
|
||||
|
|
|
|||
|
|
@ -79,6 +79,20 @@ static const PipelineDesc kCrtPipelineDescription = {
|
|||
FaceWinding::kCounterClockwise,
|
||||
{0.f, 0.f, 0.f, 1.f}};
|
||||
|
||||
/// @brief Pipeline used for CRT special blit (sharp)
|
||||
static const PipelineDesc kCrtSharpPipelineDescription = {
|
||||
PipelineProgram::kCrtSharp,
|
||||
{{{sizeof(BlitVertex)}}, {{VertexAttributeName::kPosition, 0, 0}, {VertexAttributeName::kTexCoord0, 0, 12}}},
|
||||
{{{UniformName::kProjection}, {{UniformName::kModelView, UniformName::kTexCoord0Transform, UniformName::kSampler0Size}}}},
|
||||
{{// RGB/A texture
|
||||
SamplerName::kSampler0, SamplerName::kSampler1}},
|
||||
std::nullopt,
|
||||
{std::nullopt, {true, true, true, true}},
|
||||
PrimitiveType::kTriangles,
|
||||
CullMode::kNone,
|
||||
FaceWinding::kCounterClockwise,
|
||||
{0.f, 0.f, 0.f, 1.f}};
|
||||
|
||||
BlitRectPass::BlitRectPass() : BlitRectPass(BlitRectPass::BlitMode::kNearest) {}
|
||||
BlitRectPass::BlitRectPass(BlitRectPass::BlitMode blit_mode) : blit_mode_(blit_mode) {}
|
||||
BlitRectPass::~BlitRectPass() = default;
|
||||
|
|
@ -105,6 +119,9 @@ void BlitRectPass::prepass(Rhi& rhi)
|
|||
case BlitRectPass::BlitMode::kCrt:
|
||||
pipeline_ = rhi.create_pipeline(kCrtPipelineDescription);
|
||||
break;
|
||||
case BlitRectPass::BlitMode::kCrtSharp:
|
||||
pipeline_ = rhi.create_pipeline(kCrtSharpPipelineDescription);
|
||||
break;
|
||||
default:
|
||||
std::terminate();
|
||||
}
|
||||
|
|
@ -123,7 +140,7 @@ void BlitRectPass::prepass(Rhi& rhi)
|
|||
quad_ibo_needs_upload_ = true;
|
||||
}
|
||||
|
||||
if (blit_mode_ == BlitRectPass::BlitMode::kCrt && !dot_pattern_)
|
||||
if ((blit_mode_ == BlitRectPass::BlitMode::kCrt || blit_mode_ == BlitRectPass::BlitMode::kCrtSharp) && !dot_pattern_)
|
||||
{
|
||||
dot_pattern_ = rhi.create_texture({
|
||||
rhi::TextureFormat::kRGBA,
|
||||
|
|
@ -260,6 +277,30 @@ void BlitRectPass::transfer(Rhi& rhi, Handle<GraphicsContext> ctx)
|
|||
binding_set_ = rhi.create_binding_set(ctx, pipeline_, {vbs, tbs});
|
||||
break;
|
||||
}
|
||||
case BlitRectPass::BlitMode::kCrtSharp:
|
||||
{
|
||||
std::array<rhi::UniformVariant, 3> g2_uniforms = {
|
||||
// ModelView
|
||||
glm::scale(
|
||||
glm::identity<glm::mat4>(),
|
||||
glm::vec3(taller ? 2.f : 2.f * aspect, taller ? 2.f * (1.f / aspect) : 2.f, 1.f)
|
||||
),
|
||||
// Texcoord0 Transform
|
||||
glm::mat3(
|
||||
glm::vec3(1.f, 0.f, 0.f),
|
||||
glm::vec3(0.f, output_flip_ ? -1.f : 1.f, 0.f),
|
||||
glm::vec3(0.f, output_flip_ ? 1.f : 0.f, 1.f)
|
||||
),
|
||||
// Sampler 0 Size
|
||||
glm::vec2(texture_details.width, texture_details.height)
|
||||
};
|
||||
uniform_sets_[1] = rhi.create_uniform_set(ctx, {g2_uniforms});
|
||||
|
||||
std::array<rhi::VertexAttributeBufferBinding, 1> vbs = {{{0, quad_vbo_}}};
|
||||
std::array<rhi::TextureBinding, 2> tbs = {{{rhi::SamplerName::kSampler0, texture_}, {rhi::SamplerName::kSampler1, dot_pattern_}}};
|
||||
binding_set_ = rhi.create_binding_set(ctx, pipeline_, {vbs, tbs});
|
||||
break;
|
||||
}
|
||||
case BlitRectPass::BlitMode::kSharpBilinear:
|
||||
{
|
||||
std::array<rhi::UniformVariant, 3> g2_uniforms = {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public:
|
|||
kNearest,
|
||||
kSharpBilinear,
|
||||
kCrt,
|
||||
kCrtSharp
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ struct HardwareState
|
|||
std::unique_ptr<BlitRectPass> blit_rect;
|
||||
std::unique_ptr<BlitRectPass> sharp_bilinear_blit_rect;
|
||||
std::unique_ptr<BlitRectPass> crt_blit_rect;
|
||||
std::unique_ptr<BlitRectPass> crtsharp_blit_rect;
|
||||
std::unique_ptr<ScreenshotPass> screen_capture;
|
||||
std::unique_ptr<UpscaleBackbuffer> backbuffer;
|
||||
WipeFrames wipe_frames;
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ static void reset_hardware_state(Rhi* rhi)
|
|||
g_hw_state.blit_rect = std::make_unique<BlitRectPass>(BlitRectPass::BlitMode::kNearest);
|
||||
g_hw_state.sharp_bilinear_blit_rect = std::make_unique<BlitRectPass>(BlitRectPass::BlitMode::kSharpBilinear);
|
||||
g_hw_state.crt_blit_rect = std::make_unique<BlitRectPass>(BlitRectPass::BlitMode::kCrt);
|
||||
g_hw_state.crtsharp_blit_rect = std::make_unique<BlitRectPass>(BlitRectPass::BlitMode::kCrtSharp);
|
||||
g_hw_state.screen_capture = std::make_unique<ScreenshotPass>();
|
||||
g_hw_state.backbuffer = std::make_unique<UpscaleBackbuffer>();
|
||||
g_hw_state.wipe_frames = {};
|
||||
|
|
@ -298,16 +299,19 @@ void I_FinishUpdate(void)
|
|||
g_hw_state.blit_rect->set_output(x, y, w, h, true, true);
|
||||
g_hw_state.sharp_bilinear_blit_rect->set_output(x, y, w, h, true, true);
|
||||
g_hw_state.crt_blit_rect->set_output(x, y, w, h, true, true);
|
||||
g_hw_state.crtsharp_blit_rect->set_output(x, y, w, h, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_hw_state.blit_rect->set_output(0, 0, vid.realwidth, vid.realheight, true, true);
|
||||
g_hw_state.sharp_bilinear_blit_rect->set_output(0, 0, vid.realwidth, vid.realheight, true, true);
|
||||
g_hw_state.crt_blit_rect->set_output(0, 0, vid.realwidth, vid.realheight, true, true);
|
||||
g_hw_state.crtsharp_blit_rect->set_output(0, 0, vid.realwidth, vid.realheight, true, true);
|
||||
}
|
||||
g_hw_state.blit_rect->set_texture(g_hw_state.backbuffer->color(), static_cast<uint32_t>(vid.width), static_cast<uint32_t>(vid.height));
|
||||
g_hw_state.sharp_bilinear_blit_rect->set_texture(g_hw_state.backbuffer->color(), static_cast<uint32_t>(vid.width), static_cast<uint32_t>(vid.height));
|
||||
g_hw_state.crt_blit_rect->set_texture(g_hw_state.backbuffer->color(), static_cast<uint32_t>(vid.width), static_cast<uint32_t>(vid.height));
|
||||
g_hw_state.crtsharp_blit_rect->set_texture(g_hw_state.backbuffer->color(), static_cast<uint32_t>(vid.width), static_cast<uint32_t>(vid.height));
|
||||
|
||||
switch (cv_scr_effect.value)
|
||||
{
|
||||
|
|
@ -319,6 +323,10 @@ void I_FinishUpdate(void)
|
|||
rhi->update_texture_settings(ctx, g_hw_state.backbuffer->color(), TextureWrapMode::kClamp, TextureWrapMode::kClamp, TextureFilterMode::kLinear, TextureFilterMode::kLinear);
|
||||
g_hw_state.crt_blit_rect->draw(*rhi, ctx);
|
||||
break;
|
||||
case 3:
|
||||
rhi->update_texture_settings(ctx, g_hw_state.backbuffer->color(), TextureWrapMode::kClamp, TextureWrapMode::kClamp, TextureFilterMode::kLinear, TextureFilterMode::kLinear);
|
||||
g_hw_state.crtsharp_blit_rect->draw(*rhi, ctx);
|
||||
break;
|
||||
default:
|
||||
rhi->update_texture_settings(ctx, g_hw_state.backbuffer->color(), TextureWrapMode::kClamp, TextureWrapMode::kClamp, TextureFilterMode::kNearest, TextureFilterMode::kNearest);
|
||||
g_hw_state.blit_rect->draw(*rhi, ctx);
|
||||
|
|
|
|||
|
|
@ -87,6 +87,16 @@ const ProgramRequirements srb2::rhi::kProgramRequirementsCrt = {
|
|||
{{{UniformName::kModelView, true}, {UniformName::kTexCoord0Transform, true}, {UniformName::kSampler0Size, true}}}}},
|
||||
ProgramSamplerRequirements {{{SamplerName::kSampler0, true}, {SamplerName::kSampler1, true}}}};
|
||||
|
||||
const ProgramRequirements srb2::rhi::kProgramRequirementsCrtSharp = {
|
||||
ProgramVertexInputRequirements {
|
||||
{ProgramVertexInput {VertexAttributeName::kPosition, VertexAttributeFormat::kFloat3, true},
|
||||
ProgramVertexInput {VertexAttributeName::kTexCoord0, VertexAttributeFormat::kFloat2, false},
|
||||
ProgramVertexInput {VertexAttributeName::kColor, VertexAttributeFormat::kFloat4, false}}},
|
||||
ProgramUniformRequirements {
|
||||
{{{{UniformName::kProjection, true}}},
|
||||
{{{UniformName::kModelView, true}, {UniformName::kTexCoord0Transform, true}, {UniformName::kSampler0Size, true}}}}},
|
||||
ProgramSamplerRequirements {{{SamplerName::kSampler0, true}, {SamplerName::kSampler1, true}}}};
|
||||
|
||||
const ProgramRequirements& rhi::program_requirements_for_program(PipelineProgram program) noexcept
|
||||
{
|
||||
switch (program)
|
||||
|
|
@ -103,6 +113,8 @@ const ProgramRequirements& rhi::program_requirements_for_program(PipelineProgram
|
|||
return kProgramRequirementsSharpBilinear;
|
||||
case PipelineProgram::kCrt:
|
||||
return kProgramRequirementsCrt;
|
||||
case PipelineProgram::kCrtSharp:
|
||||
return kProgramRequirementsCrtSharp;
|
||||
default:
|
||||
std::terminate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,7 +174,8 @@ enum class PipelineProgram
|
|||
kPostprocessWipe,
|
||||
kPostimg,
|
||||
kSharpBilinear,
|
||||
kCrt
|
||||
kCrt,
|
||||
kCrtSharp
|
||||
};
|
||||
|
||||
enum class BufferType
|
||||
|
|
@ -289,6 +290,7 @@ extern const ProgramRequirements kProgramRequirementsPostprocessWipe;
|
|||
extern const ProgramRequirements kProgramRequirementsPostimg;
|
||||
extern const ProgramRequirements kProgramRequirementsSharpBilinear;
|
||||
extern const ProgramRequirements kProgramRequirementsCrt;
|
||||
extern const ProgramRequirements kProgramRequirementsCrtSharp;
|
||||
|
||||
const ProgramRequirements& program_requirements_for_program(PipelineProgram program) noexcept;
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ static constexpr const char* pipeline_lump_slug(rhi::PipelineProgram program)
|
|||
return "sharpbilinear";
|
||||
case rhi::PipelineProgram::kCrt:
|
||||
return "crt";
|
||||
case rhi::PipelineProgram::kCrtSharp:
|
||||
return "crtsharp";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue