Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
641e78bc
There was an error fetching the commit references. Please try again later.
Commit
641e78bc
authored
9 years ago
by
Emmanuel Gil Peyrot
Browse files
Options
Downloads
Patches
Plain Diff
GPU: Implement blended downscaling for display transfers.
parent
8ee814ec
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/hw/gpu.cpp
+40
-27
40 additions, 27 deletions
src/core/hw/gpu.cpp
with
40 additions
and
27 deletions
src/core/hw/gpu.cpp
+
40
−
27
View file @
641e78bc
...
@@ -53,6 +53,29 @@ inline void Read(T &var, const u32 raw_addr) {
...
@@ -53,6 +53,29 @@ inline void Read(T &var, const u32 raw_addr) {
var
=
g_regs
[
addr
/
4
];
var
=
g_regs
[
addr
/
4
];
}
}
static
Math
::
Vec4
<
u8
>
DecodePixel
(
Regs
::
PixelFormat
input_format
,
const
u8
*
src_pixel
)
{
switch
(
input_format
)
{
case
Regs
::
PixelFormat
::
RGBA8
:
return
Color
::
DecodeRGBA8
(
src_pixel
);
case
Regs
::
PixelFormat
::
RGB8
:
return
Color
::
DecodeRGB8
(
src_pixel
);
case
Regs
::
PixelFormat
::
RGB565
:
return
Color
::
DecodeRGB565
(
src_pixel
);
case
Regs
::
PixelFormat
::
RGB5A1
:
return
Color
::
DecodeRGB5A1
(
src_pixel
);
case
Regs
::
PixelFormat
::
RGBA4
:
return
Color
::
DecodeRGBA4
(
src_pixel
);
default:
LOG_ERROR
(
HW_GPU
,
"Unknown source framebuffer format %x"
,
input_format
);
return
{
0
,
0
,
0
,
0
};
}
}
template
<
typename
T
>
template
<
typename
T
>
inline
void
Write
(
u32
addr
,
const
T
data
)
{
inline
void
Write
(
u32
addr
,
const
T
data
)
{
addr
-=
HW
::
VADDR_GPU
;
addr
-=
HW
::
VADDR_GPU
;
...
@@ -125,6 +148,13 @@ inline void Write(u32 addr, const T data) {
...
@@ -125,6 +148,13 @@ inline void Write(u32 addr, const T data) {
break
;
break
;
}
}
if
(
config
.
output_tiled
&&
(
config
.
scaling
==
config
.
ScaleXY
||
config
.
scaling
==
config
.
ScaleX
))
{
LOG_CRITICAL
(
HW_GPU
,
"Scaling is only implemented on tiled input"
);
UNIMPLEMENTED
();
break
;
}
bool
horizontal_scale
=
config
.
scaling
!=
config
.
NoScale
;
bool
horizontal_scale
=
config
.
scaling
!=
config
.
NoScale
;
bool
vertical_scale
=
config
.
scaling
==
config
.
ScaleXY
;
bool
vertical_scale
=
config
.
scaling
==
config
.
ScaleXY
;
...
@@ -153,11 +183,9 @@ inline void Write(u32 addr, const T data) {
...
@@ -153,11 +183,9 @@ inline void Write(u32 addr, const T data) {
break
;
break
;
}
}
// TODO(Subv): Implement the box filter when scaling is enabled
// right now we're just skipping the extra pixels.
for
(
u32
y
=
0
;
y
<
output_height
;
++
y
)
{
for
(
u32
y
=
0
;
y
<
output_height
;
++
y
)
{
for
(
u32
x
=
0
;
x
<
output_width
;
++
x
)
{
for
(
u32
x
=
0
;
x
<
output_width
;
++
x
)
{
Math
::
Vec4
<
u8
>
src_color
=
{
0
,
0
,
0
,
0
}
;
Math
::
Vec4
<
u8
>
src_color
;
// Calculate the [x,y] position of the input image
// Calculate the [x,y] position of the input image
// based on the current output position and the scale
// based on the current output position and the scale
...
@@ -193,30 +221,15 @@ inline void Write(u32 addr, const T data) {
...
@@ -193,30 +221,15 @@ inline void Write(u32 addr, const T data) {
}
}
const
u8
*
src_pixel
=
src_pointer
+
src_offset
;
const
u8
*
src_pixel
=
src_pointer
+
src_offset
;
switch
(
config
.
input_format
)
{
src_color
=
DecodePixel
(
config
.
input_format
,
src_pixel
);
case
Regs
::
PixelFormat
::
RGBA8
:
if
(
config
.
scaling
==
config
.
ScaleX
)
{
src_color
=
Color
::
DecodeRGBA8
(
src_pixel
);
Math
::
Vec4
<
u8
>
pixel
=
DecodePixel
(
config
.
input_format
,
src_pixel
+
src_bytes_per_pixel
);
break
;
src_color
=
((
src_color
+
pixel
)
/
2
).
Cast
<
u8
>
();
}
else
if
(
config
.
scaling
==
config
.
ScaleXY
)
{
case
Regs
::
PixelFormat
::
RGB8
:
Math
::
Vec4
<
u8
>
pixel1
=
DecodePixel
(
config
.
input_format
,
src_pixel
+
1
*
src_bytes_per_pixel
);
src_color
=
Color
::
DecodeRGB8
(
src_pixel
);
Math
::
Vec4
<
u8
>
pixel2
=
DecodePixel
(
config
.
input_format
,
src_pixel
+
2
*
src_bytes_per_pixel
);
break
;
Math
::
Vec4
<
u8
>
pixel3
=
DecodePixel
(
config
.
input_format
,
src_pixel
+
3
*
src_bytes_per_pixel
);
src_color
=
(((
src_color
+
pixel1
)
+
(
pixel2
+
pixel3
))
/
4
).
Cast
<
u8
>
();
case
Regs
::
PixelFormat
::
RGB565
:
src_color
=
Color
::
DecodeRGB565
(
src_pixel
);
break
;
case
Regs
::
PixelFormat
::
RGB5A1
:
src_color
=
Color
::
DecodeRGB5A1
(
src_pixel
);
break
;
case
Regs
::
PixelFormat
::
RGBA4
:
src_color
=
Color
::
DecodeRGBA4
(
src_pixel
);
break
;
default:
LOG_ERROR
(
HW_GPU
,
"Unknown source framebuffer format %x"
,
config
.
input_format
.
Value
());
break
;
}
}
u8
*
dst_pixel
=
dst_pointer
+
dst_offset
;
u8
*
dst_pixel
=
dst_pointer
+
dst_offset
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment