afegits tots els valors d'escala que dona sdl3
This commit is contained in:
@@ -814,7 +814,7 @@ namespace Rendering {
|
||||
|
||||
// ---- Upscale pass: scene_texture_ → scaled_texture_ ----
|
||||
// Si 4:3 actiu, l'estirament s'aplica ací directament (320x200 → W*factor × H*factor*1.2)
|
||||
// El filtre per al 4:3 és configurable (stretch_filter_linear_).
|
||||
// El filtre s'aplica sempre (texture_filter_linear_), independent de 4:3.
|
||||
// L'effective_scene/height reflecteix la textura real que veuen els shaders.
|
||||
// Sense SS ni stretch: scene_texture_ a game_height_.
|
||||
// Amb SS o stretch: scaled_texture_ a l'alçada escalada (amb o sense 4:3).
|
||||
@@ -827,9 +827,8 @@ namespace Rendering {
|
||||
upscale_target.load_op = SDL_GPU_LOADOP_DONT_CARE;
|
||||
upscale_target.store_op = SDL_GPU_STOREOP_STORE;
|
||||
|
||||
// Triar filtre: si 4:3 actiu, usar el filtre configurable per a l'estirament.
|
||||
// Si no, usar el filtre d'upscale normal (linear_upscale_).
|
||||
bool use_linear = stretch_4_3_ ? stretch_filter_linear_ : linear_upscale_;
|
||||
// Filtre global: s'aplica sempre (ja no depèn de 4:3).
|
||||
bool use_linear = texture_filter_linear_;
|
||||
|
||||
SDL_GPURenderPass* upass = SDL_BeginGPURenderPass(cmd, &upscale_target, 1, nullptr);
|
||||
if (upass != nullptr) {
|
||||
@@ -872,16 +871,38 @@ namespace Rendering {
|
||||
float vy = 0.0F;
|
||||
float vw = 0.0F;
|
||||
float vh = 0.0F;
|
||||
if (integer_scale_) {
|
||||
const int SCALE = std::max(1, std::min(static_cast<int>(sw) / static_cast<int>(logical_w), static_cast<int>(sh) / static_cast<int>(logical_h)));
|
||||
vw = logical_w * static_cast<float>(SCALE);
|
||||
vh = logical_h * static_cast<float>(SCALE);
|
||||
} else {
|
||||
const float SCALE = std::min(
|
||||
static_cast<float>(sw) / logical_w,
|
||||
static_cast<float>(sh) / logical_h);
|
||||
vw = logical_w * SCALE;
|
||||
vh = logical_h * SCALE;
|
||||
switch (scaling_mode_) {
|
||||
case Options::ScalingMode::DISABLED:
|
||||
// 1:1, sense escala (pot ser diminut en finestres grans)
|
||||
vw = logical_w;
|
||||
vh = logical_h;
|
||||
break;
|
||||
case Options::ScalingMode::STRETCH:
|
||||
// Omple tota la finestra, escala no uniforme
|
||||
vw = static_cast<float>(sw);
|
||||
vh = static_cast<float>(sh);
|
||||
break;
|
||||
case Options::ScalingMode::LETTERBOX: {
|
||||
const float SCALE = std::min(static_cast<float>(sw) / logical_w,
|
||||
static_cast<float>(sh) / logical_h);
|
||||
vw = logical_w * SCALE;
|
||||
vh = logical_h * SCALE;
|
||||
break;
|
||||
}
|
||||
case Options::ScalingMode::OVERSCAN: {
|
||||
const float SCALE = std::max(static_cast<float>(sw) / logical_w,
|
||||
static_cast<float>(sh) / logical_h);
|
||||
vw = logical_w * SCALE;
|
||||
vh = logical_h * SCALE;
|
||||
break;
|
||||
}
|
||||
case Options::ScalingMode::INTEGER: {
|
||||
const int SCALE = std::max(1, std::min(static_cast<int>(sw) / static_cast<int>(logical_w),
|
||||
static_cast<int>(sh) / static_cast<int>(logical_h)));
|
||||
vw = logical_w * static_cast<float>(SCALE);
|
||||
vh = logical_h * static_cast<float>(SCALE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
vx = std::floor((static_cast<float>(sw) - vw) * 0.5F);
|
||||
vy = std::floor((static_cast<float>(sh) - vh) * 0.5F);
|
||||
@@ -1193,8 +1214,8 @@ namespace Rendering {
|
||||
}
|
||||
}
|
||||
|
||||
void SDL3GPUShader::setScaleMode(bool integer_scale) {
|
||||
integer_scale_ = integer_scale;
|
||||
void SDL3GPUShader::setScalingMode(Options::ScalingMode mode) {
|
||||
scaling_mode_ = mode;
|
||||
}
|
||||
|
||||
void SDL3GPUShader::setStretch4_3(bool enabled) {
|
||||
@@ -1221,10 +1242,6 @@ namespace Rendering {
|
||||
}
|
||||
}
|
||||
|
||||
void SDL3GPUShader::setLinearUpscale(bool linear) {
|
||||
linear_upscale_ = linear;
|
||||
}
|
||||
|
||||
void SDL3GPUShader::setDownscaleAlgo(int algo) {
|
||||
downscale_algo_ = std::max(0, std::min(algo, 2));
|
||||
}
|
||||
|
||||
@@ -96,15 +96,12 @@ namespace Rendering {
|
||||
// Activa/desactiva VSync en el swapchain
|
||||
void setVSync(bool vsync) override;
|
||||
|
||||
// Activa/desactiva escalado entero (integer scale)
|
||||
void setScaleMode(bool integer_scale) override;
|
||||
// Selecciona el mode de presentació lògica (DISABLED/STRETCH/LETTERBOX/OVERSCAN/INTEGER)
|
||||
void setScalingMode(Options::ScalingMode mode) override;
|
||||
|
||||
// Establece factor de supersampling (1 = off, 3 = 3×SS)
|
||||
void setOversample(int factor) override;
|
||||
|
||||
// Activa/desactiva interpolación LINEAR en el upscale (false = NEAREST)
|
||||
void setLinearUpscale(bool linear) override;
|
||||
|
||||
// Selecciona algoritmo de downscale: 0=bilinear legacy, 1=Lanczos2, 2=Lanczos3
|
||||
void setDownscaleAlgo(int algo) override;
|
||||
|
||||
@@ -123,7 +120,11 @@ namespace Rendering {
|
||||
// Estirament vertical 4:3 (fusionat amb l'upscale pass)
|
||||
void setStretch4_3(bool enabled) override;
|
||||
[[nodiscard]] auto isStretch4_3() const -> bool override { return stretch_4_3_; }
|
||||
void setStretchFilter(bool linear) override { stretch_filter_linear_ = linear; }
|
||||
|
||||
// Filtre de textura global (sempre aplicat, independent de 4:3)
|
||||
void setTextureFilter(Options::TextureFilter filter) override {
|
||||
texture_filter_linear_ = (filter == Options::TextureFilter::LINEAR);
|
||||
}
|
||||
|
||||
private:
|
||||
static auto createShaderMSL(SDL_GPUDevice* device,
|
||||
@@ -176,10 +177,9 @@ namespace Rendering {
|
||||
std::string preferred_driver_; // Driver preferido; vacío = auto (SDL elige)
|
||||
bool is_initialized_ = false;
|
||||
bool vsync_ = true;
|
||||
bool integer_scale_ = false;
|
||||
bool linear_upscale_ = false; // Upscale NEAREST (false) o LINEAR (true)
|
||||
bool stretch_4_3_ = false; // Estirament vertical 4:3
|
||||
bool stretch_filter_linear_ = false; // Filtre per a l'estirament 4:3 (false=NEAREST, true=LINEAR)
|
||||
Options::ScalingMode scaling_mode_ = Options::ScalingMode::INTEGER;
|
||||
bool stretch_4_3_ = false; // Estirament vertical 4:3
|
||||
bool texture_filter_linear_ = false; // Filtre global (false=NEAREST, true=LINEAR)
|
||||
};
|
||||
|
||||
} // namespace Rendering
|
||||
|
||||
Reference in New Issue
Block a user