mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-18 07:35:46 -04:00
GPU/HW: Elide buffer copy in scanout and fix flipped display
This commit is contained in:
@ -130,7 +130,7 @@ void D3D11HostDisplay::UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y,
|
||||
}
|
||||
}
|
||||
|
||||
void D3D11HostDisplay::SetDisplayTexture(void* texture, u32 offset_x, u32 offset_y, u32 width, u32 height,
|
||||
void D3D11HostDisplay::SetDisplayTexture(void* texture, s32 offset_x, s32 offset_y, s32 width, s32 height,
|
||||
u32 texture_width, u32 texture_height, float aspect_ratio)
|
||||
{
|
||||
m_display_srv = static_cast<ID3D11ShaderResourceView*>(texture);
|
||||
@ -249,29 +249,29 @@ bool D3D11HostDisplay::CreateSwapChainRTV()
|
||||
bool D3D11HostDisplay::CreateD3DResources()
|
||||
{
|
||||
static constexpr char fullscreen_quad_vertex_shader[] = R"(
|
||||
void main(in uint vertex_id : SV_VertexID,
|
||||
out float2 v_tex0 : TEXCOORD0,
|
||||
out float4 o_pos : SV_Position)
|
||||
{
|
||||
v_tex0 = float2(float((vertex_id << 1) & 2u), float(vertex_id & 2u));
|
||||
o_pos = float4(v_tex0 * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
|
||||
}
|
||||
)";
|
||||
|
||||
static constexpr char display_pixel_shader[] = R"(
|
||||
cbuffer UBOBlock : register(b0)
|
||||
{
|
||||
float4 u_src_rect;
|
||||
};
|
||||
|
||||
void main(in uint vertex_id : SV_VertexID,
|
||||
out float2 v_tex0 : TEXCOORD0,
|
||||
out float4 o_pos : SV_Position)
|
||||
{
|
||||
float2 pos = float2(float((vertex_id << 1) & 2u), float(vertex_id & 2u));
|
||||
v_tex0 = u_src_rect.xy + pos * u_src_rect.zw;
|
||||
o_pos = float4(pos * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
|
||||
}
|
||||
)";
|
||||
|
||||
static constexpr char display_pixel_shader[] = R"(
|
||||
Texture2D samp0 : register(t0);
|
||||
SamplerState samp0_ss : register(s0);
|
||||
|
||||
void main(in float2 v_tex0 : TEXCOORD0,
|
||||
out float4 o_col0 : SV_Target)
|
||||
{
|
||||
float2 coords = u_src_rect.xy + v_tex0 * u_src_rect.zw;
|
||||
o_col0 = samp0.Sample(samp0_ss, coords);
|
||||
o_col0 = samp0.Sample(samp0_ss, v_tex0);
|
||||
}
|
||||
)";
|
||||
|
||||
@ -381,7 +381,7 @@ void D3D11HostDisplay::RenderDisplay()
|
||||
const auto map = m_display_uniform_buffer.Map(m_context.Get(), sizeof(uniforms), sizeof(uniforms));
|
||||
std::memcpy(map.pointer, uniforms, sizeof(uniforms));
|
||||
m_display_uniform_buffer.Unmap(m_context.Get(), sizeof(uniforms));
|
||||
m_context->PSSetConstantBuffers(0, 1, m_display_uniform_buffer.GetD3DBufferArray());
|
||||
m_context->VSSetConstantBuffers(0, 1, m_display_uniform_buffer.GetD3DBufferArray());
|
||||
|
||||
const CD3D11_VIEWPORT vp(static_cast<float>(vp_left), static_cast<float>(vp_top), static_cast<float>(vp_width),
|
||||
static_cast<float>(vp_height));
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
void UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data,
|
||||
u32 data_stride) override;
|
||||
|
||||
void SetDisplayTexture(void* texture, u32 offset_x, u32 offset_y, u32 width, u32 height, u32 texture_width,
|
||||
void SetDisplayTexture(void* texture, s32 offset_x, s32 offset_y, s32 width, s32 height, u32 texture_width,
|
||||
u32 texture_height, float aspect_ratio) override;
|
||||
void SetDisplayLinearFiltering(bool enabled) override;
|
||||
|
||||
@ -70,10 +70,10 @@ private:
|
||||
D3D11::StreamBuffer m_display_uniform_buffer;
|
||||
|
||||
ID3D11ShaderResourceView* m_display_srv = nullptr;
|
||||
u32 m_display_offset_x = 0;
|
||||
u32 m_display_offset_y = 0;
|
||||
u32 m_display_width = 0;
|
||||
u32 m_display_height = 0;
|
||||
s32 m_display_offset_x = 0;
|
||||
s32 m_display_offset_y = 0;
|
||||
s32 m_display_width = 0;
|
||||
s32 m_display_height = 0;
|
||||
u32 m_display_texture_width = 0;
|
||||
u32 m_display_texture_height = 0;
|
||||
float m_display_aspect_ratio = 1.0f;
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_texture_binding);
|
||||
|
||||
// TODO: Set pack width
|
||||
Assert(initial_data_stride == (width * sizeof(u32)));
|
||||
Assert(!initial_data || initial_data_stride == (width * sizeof(u32)));
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, initial_data);
|
||||
@ -109,7 +109,7 @@ void OpenGLHostDisplay::UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y,
|
||||
glBindTexture(GL_TEXTURE_2D, old_texture_binding);
|
||||
}
|
||||
|
||||
void OpenGLHostDisplay::SetDisplayTexture(void* texture, u32 offset_x, u32 offset_y, u32 width, u32 height,
|
||||
void OpenGLHostDisplay::SetDisplayTexture(void* texture, s32 offset_x, s32 offset_y, s32 width, s32 height,
|
||||
u32 texture_width, u32 texture_height, float aspect_ratio)
|
||||
{
|
||||
m_display_texture_id = static_cast<GLuint>(reinterpret_cast<uintptr_t>(texture));
|
||||
@ -210,13 +210,14 @@ bool OpenGLHostDisplay::CreateGLResources()
|
||||
static constexpr char fullscreen_quad_vertex_shader[] = R"(
|
||||
#version 330 core
|
||||
|
||||
uniform vec4 u_src_rect;
|
||||
out vec2 v_tex0;
|
||||
|
||||
void main()
|
||||
{
|
||||
v_tex0 = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));
|
||||
gl_Position = vec4(v_tex0 * vec2(2.0f, -2.0f) + vec2(-1.0f, 1.0f), 0.0f, 1.0f);
|
||||
gl_Position.y = -gl_Position.y;
|
||||
vec2 pos = vec2(float((gl_VertexID << 1) & 2), float(gl_VertexID & 2));
|
||||
v_tex0 = u_src_rect.xy + pos * u_src_rect.zw;
|
||||
gl_Position = vec4(pos * vec2(2.0f, -2.0f) + vec2(-1.0f, 1.0f), 0.0f, 1.0f);
|
||||
}
|
||||
)";
|
||||
|
||||
@ -224,15 +225,13 @@ void main()
|
||||
#version 330 core
|
||||
|
||||
uniform sampler2D samp0;
|
||||
uniform vec4 u_src_rect;
|
||||
|
||||
in vec2 v_tex0;
|
||||
out vec4 o_col0;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 coords = u_src_rect.xy + v_tex0 * u_src_rect.zw;
|
||||
o_col0 = texture(samp0, coords);
|
||||
o_col0 = texture(samp0, v_tex0);
|
||||
}
|
||||
)";
|
||||
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
void UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data,
|
||||
u32 data_stride) override;
|
||||
|
||||
void SetDisplayTexture(void* texture, u32 offset_x, u32 offset_y, u32 width, u32 height, u32 texture_width,
|
||||
void SetDisplayTexture(void* texture, s32 offset_x, s32 offset_y, s32 width, s32 height, u32 texture_width,
|
||||
u32 texture_height, float aspect_ratio) override;
|
||||
void SetDisplayLinearFiltering(bool enabled) override;
|
||||
|
||||
@ -49,10 +49,10 @@ private:
|
||||
GL::Program m_display_program;
|
||||
GLuint m_display_vao = 0;
|
||||
GLuint m_display_texture_id = 0;
|
||||
u32 m_display_offset_x = 0;
|
||||
u32 m_display_offset_y = 0;
|
||||
u32 m_display_width = 0;
|
||||
u32 m_display_height = 0;
|
||||
s32 m_display_offset_x = 0;
|
||||
s32 m_display_offset_y = 0;
|
||||
s32 m_display_width = 0;
|
||||
s32 m_display_height = 0;
|
||||
u32 m_display_texture_width = 0;
|
||||
u32 m_display_texture_height = 0;
|
||||
float m_display_aspect_ratio = 1.0f;
|
||||
|
Reference in New Issue
Block a user