WIP
This commit is contained in:
parent
0563350d04
commit
2c7752baea
|
@ -209,6 +209,7 @@ bool GPU_HW::Initialize()
|
||||||
m_wireframe_mode = g_settings.gpu_wireframe_mode;
|
m_wireframe_mode = g_settings.gpu_wireframe_mode;
|
||||||
m_disable_color_perspective = features.noperspective_interpolation && ShouldDisableColorPerspective();
|
m_disable_color_perspective = features.noperspective_interpolation && ShouldDisableColorPerspective();
|
||||||
m_pgxp_depth_buffer = g_settings.UsingPGXPDepthBuffer();
|
m_pgxp_depth_buffer = g_settings.UsingPGXPDepthBuffer();
|
||||||
|
m_allow_sprite_mode = true;
|
||||||
|
|
||||||
CheckSettings();
|
CheckSettings();
|
||||||
|
|
||||||
|
@ -793,7 +794,7 @@ bool GPU_HW::CompilePipelines()
|
||||||
m_disable_color_perspective, m_supports_dual_source_blend, m_supports_framebuffer_fetch,
|
m_disable_color_perspective, m_supports_dual_source_blend, m_supports_framebuffer_fetch,
|
||||||
m_debanding);
|
m_debanding);
|
||||||
|
|
||||||
constexpr u32 active_texture_modes = 4;
|
const u32 active_texture_modes = m_allow_sprite_mode ? 7 : 4;
|
||||||
const u32 total_pipelines =
|
const u32 total_pipelines =
|
||||||
2 + // vertex shaders
|
2 + // vertex shaders
|
||||||
(active_texture_modes * 5 * 9 * 2 * 2 * 2) + // fragment shaders
|
(active_texture_modes * 5 * 9 * 2 * 2 * 2) + // fragment shaders
|
||||||
|
@ -865,11 +866,14 @@ bool GPU_HW::CompilePipelines()
|
||||||
{
|
{
|
||||||
for (u8 interlacing = 0; interlacing < 2; interlacing++)
|
for (u8 interlacing = 0; interlacing < 2; interlacing++)
|
||||||
{
|
{
|
||||||
|
const bool sprite = (static_cast<BatchTextureMode>(texture_mode) >= BatchTextureMode::SpriteStart);
|
||||||
|
const BatchTextureMode shader_texmode = static_cast<BatchTextureMode>(
|
||||||
|
texture_mode - (sprite ? static_cast<u8>(BatchTextureMode::SpriteStart) : 0));
|
||||||
const std::string fs = shadergen.GenerateBatchFragmentShader(
|
const std::string fs = shadergen.GenerateBatchFragmentShader(
|
||||||
static_cast<BatchRenderMode>(render_mode), static_cast<GPUTransparencyMode>(transparency_mode),
|
static_cast<BatchRenderMode>(render_mode), static_cast<GPUTransparencyMode>(transparency_mode),
|
||||||
static_cast<BatchTextureMode>(texture_mode), m_texture_filtering, m_force_round_texcoords,
|
shader_texmode, sprite ? GPUTextureFilter::Nearest : m_texture_filtering,
|
||||||
ConvertToBoolUnchecked(dithering), ConvertToBoolUnchecked(interlacing),
|
sprite && m_force_round_texcoords, ConvertToBoolUnchecked(dithering),
|
||||||
ConvertToBoolUnchecked(check_mask));
|
ConvertToBoolUnchecked(interlacing), ConvertToBoolUnchecked(check_mask));
|
||||||
|
|
||||||
if (!(batch_fragment_shaders[render_mode][transparency_mode][texture_mode][check_mask][dithering]
|
if (!(batch_fragment_shaders[render_mode][transparency_mode][texture_mode][check_mask][dithering]
|
||||||
[interlacing] = g_gpu_device->CreateShader(GPUShaderStage::Fragment,
|
[interlacing] = g_gpu_device->CreateShader(GPUShaderStage::Fragment,
|
||||||
|
@ -1519,12 +1523,15 @@ ALWAYS_INLINE_RELEASE void GPU_HW::DrawBatchVertices(BatchRenderMode render_mode
|
||||||
u32 base_vertex)
|
u32 base_vertex)
|
||||||
{
|
{
|
||||||
// [depth_test][transparency_mode][render_mode][texture_mode][dithering][interlacing][check_mask]
|
// [depth_test][transparency_mode][render_mode][texture_mode][dithering][interlacing][check_mask]
|
||||||
|
const u8 texture_mode = static_cast<u8>(m_batch.texture_mode) +
|
||||||
|
((m_batch.texture_mode != BatchTextureMode::Disabled && m_batch.sprite_mode) ?
|
||||||
|
static_cast<u8>(BatchTextureMode::SpriteStart) :
|
||||||
|
0);
|
||||||
const u8 depth_test = BoolToUInt8(m_batch.use_depth_buffer);
|
const u8 depth_test = BoolToUInt8(m_batch.use_depth_buffer);
|
||||||
const u8 check_mask = BoolToUInt8(m_batch.check_mask_before_draw);
|
const u8 check_mask = BoolToUInt8(m_batch.check_mask_before_draw);
|
||||||
g_gpu_device->SetPipeline(m_batch_pipelines[depth_test][static_cast<u8>(m_batch.transparency_mode)][static_cast<u8>(
|
g_gpu_device->SetPipeline(m_batch_pipelines[depth_test][static_cast<u8>(m_batch.transparency_mode)][static_cast<u8>(
|
||||||
render_mode)][static_cast<u8>(m_batch.texture_mode)][BoolToUInt8(m_batch.dithering)]
|
render_mode)][texture_mode][BoolToUInt8(m_batch.dithering)][BoolToUInt8(m_batch.interlacing)][check_mask]
|
||||||
[BoolToUInt8(m_batch.interlacing)][check_mask]
|
.get());
|
||||||
.get());
|
|
||||||
|
|
||||||
if (render_mode != BatchRenderMode::ShaderBlend || m_supports_framebuffer_fetch)
|
if (render_mode != BatchRenderMode::ShaderBlend || m_supports_framebuffer_fetch)
|
||||||
g_gpu_device->DrawIndexed(num_indices, base_index, base_vertex);
|
g_gpu_device->DrawIndexed(num_indices, base_index, base_vertex);
|
||||||
|
@ -1844,6 +1851,23 @@ void GPU_HW::CheckForDepthClear(const BatchVertex* vertices, u32 num_vertices)
|
||||||
m_last_depth_z = average_z;
|
m_last_depth_z = average_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GPU_HW::SetBatchSpriteMode(bool enabled)
|
||||||
|
{
|
||||||
|
if (m_batch.sprite_mode == enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_batch_index_count > 0)
|
||||||
|
{
|
||||||
|
FlushRender();
|
||||||
|
EnsureVertexBufferSpaceForCurrentCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
WARNING_LOG("Sprite mode {}", enabled);
|
||||||
|
GL_INS_FMT("SPRITE MODE {}", enabled);
|
||||||
|
|
||||||
|
m_batch.sprite_mode = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
u32 GPU_HW::GetAdaptiveDownsamplingMipLevels() const
|
u32 GPU_HW::GetAdaptiveDownsamplingMipLevels() const
|
||||||
{
|
{
|
||||||
u32 levels = 0;
|
u32 levels = 0;
|
||||||
|
@ -2000,6 +2024,7 @@ void GPU_HW::LoadVertices()
|
||||||
}
|
}
|
||||||
if (pgxp)
|
if (pgxp)
|
||||||
{
|
{
|
||||||
|
SetBatchSpriteMode(m_allow_sprite_mode && !valid_w);
|
||||||
if (!valid_w)
|
if (!valid_w)
|
||||||
{
|
{
|
||||||
SetBatchDepthBuffer(false);
|
SetBatchDepthBuffer(false);
|
||||||
|
@ -2180,6 +2205,7 @@ void GPU_HW::LoadVertices()
|
||||||
|
|
||||||
// we can split the rectangle up into potentially 8 quads
|
// we can split the rectangle up into potentially 8 quads
|
||||||
SetBatchDepthBuffer(false);
|
SetBatchDepthBuffer(false);
|
||||||
|
SetBatchSpriteMode(m_allow_sprite_mode);
|
||||||
DebugAssert(m_batch_vertex_space >= MAX_VERTICES_FOR_RECTANGLE &&
|
DebugAssert(m_batch_vertex_space >= MAX_VERTICES_FOR_RECTANGLE &&
|
||||||
m_batch_index_space >= MAX_VERTICES_FOR_RECTANGLE);
|
m_batch_index_space >= MAX_VERTICES_FOR_RECTANGLE);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,13 @@ public:
|
||||||
Direct16Bit,
|
Direct16Bit,
|
||||||
Disabled,
|
Disabled,
|
||||||
|
|
||||||
|
SpritePalette4Bit,
|
||||||
|
SpritePalette8Bit,
|
||||||
|
SpriteDirect16Bit,
|
||||||
|
|
||||||
MaxCount,
|
MaxCount,
|
||||||
|
|
||||||
|
SpriteStart = SpritePalette4Bit,
|
||||||
};
|
};
|
||||||
static_assert(static_cast<u8>(BatchTextureMode::Palette4Bit) == static_cast<u8>(GPUTextureMode::Palette4Bit) &&
|
static_assert(static_cast<u8>(BatchTextureMode::Palette4Bit) == static_cast<u8>(GPUTextureMode::Palette4Bit) &&
|
||||||
static_cast<u8>(BatchTextureMode::Palette8Bit) == static_cast<u8>(GPUTextureMode::Palette8Bit) &&
|
static_cast<u8>(BatchTextureMode::Palette8Bit) == static_cast<u8>(GPUTextureMode::Palette8Bit) &&
|
||||||
|
@ -108,6 +114,7 @@ private:
|
||||||
bool set_mask_while_drawing = false;
|
bool set_mask_while_drawing = false;
|
||||||
bool check_mask_before_draw = false;
|
bool check_mask_before_draw = false;
|
||||||
bool use_depth_buffer = false;
|
bool use_depth_buffer = false;
|
||||||
|
bool sprite_mode = false;
|
||||||
|
|
||||||
// Returns the render mode for this batch.
|
// Returns the render mode for this batch.
|
||||||
BatchRenderMode GetRenderMode() const;
|
BatchRenderMode GetRenderMode() const;
|
||||||
|
@ -209,6 +216,7 @@ private:
|
||||||
/// Sets the depth test flag for PGXP depth buffering.
|
/// Sets the depth test flag for PGXP depth buffering.
|
||||||
void SetBatchDepthBuffer(bool enabled);
|
void SetBatchDepthBuffer(bool enabled);
|
||||||
void CheckForDepthClear(const BatchVertex* vertices, u32 num_vertices);
|
void CheckForDepthClear(const BatchVertex* vertices, u32 num_vertices);
|
||||||
|
void SetBatchSpriteMode(bool enabled);
|
||||||
|
|
||||||
/// Returns the number of mipmap levels used for adaptive smoothing.
|
/// Returns the number of mipmap levels used for adaptive smoothing.
|
||||||
u32 GetAdaptiveDownsamplingMipLevels() const;
|
u32 GetAdaptiveDownsamplingMipLevels() const;
|
||||||
|
@ -259,6 +267,7 @@ private:
|
||||||
bool m_clamp_uvs : 1 = false;
|
bool m_clamp_uvs : 1 = false;
|
||||||
bool m_compute_uv_range : 1 = false;
|
bool m_compute_uv_range : 1 = false;
|
||||||
bool m_pgxp_depth_buffer : 1 = false;
|
bool m_pgxp_depth_buffer : 1 = false;
|
||||||
|
bool m_allow_sprite_mode : 1 = false;
|
||||||
bool m_allow_shader_blend : 1 = false;
|
bool m_allow_shader_blend : 1 = false;
|
||||||
bool m_prefer_shader_blend : 1 = false;
|
bool m_prefer_shader_blend : 1 = false;
|
||||||
u8 m_texpage_dirty = 0;
|
u8 m_texpage_dirty = 0;
|
||||||
|
|
Loading…
Reference in New Issue