Drop the extra full-screen copy at render scale < 1
The SDL_GPU pipeline renders into its own view-sized colour target and already composites it over the whole render target, so routing it through gpu_scene_texture cost one extra same-size copy per frame. The scaled intermediate is now used only by the SDL geometry fallback; the hardware composite upscales with linear filtering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
b57f2fba99
commit
df87bc64eb
@@ -80,6 +80,19 @@ int main() {
|
||||
for(int i=0;i<100;++i)UI::DrawText(renderer,"NPC label",12,0,0,i%2 ? 0xffff0000 : 0xff00ff00);
|
||||
assert(SDL_RenderPresent(renderer));
|
||||
}
|
||||
{ // Render scale < 1: a smaller colour target is upscaled over the whole render target in the composite.
|
||||
ava2::HardwareScene scaled(device);
|
||||
std::vector<ava2::HardwareVertex> quad;
|
||||
for(auto p: {std::pair{-1.f,-1.f},std::pair{1.f,-1.f},std::pair{1.f,1.f},std::pair{-1.f,1.f}})
|
||||
quad.push_back({{p.first,p.second,.5f,1},{255,0,0,255},{0,0}});
|
||||
SDL_SetRenderDrawColor(renderer,0,255,0,255);SDL_RenderClear(renderer);
|
||||
assert(scaled.Render(renderer,32,32,quad,{0,1,2,0,2,3},{{0,6,nullptr,1,true,true,false,false,-1}}));
|
||||
auto* pixels=SDL_RenderReadPixels(renderer,nullptr);assert(pixels);
|
||||
auto redAt=[&](int x,int y){Uint32 v=0;std::memcpy(&v,static_cast<Uint8*>(pixels->pixels)+y*pixels->pitch+x*SDL_BYTESPERPIXEL(pixels->format),SDL_BYTESPERPIXEL(pixels->format));
|
||||
Uint8 r,g,b,a;SDL_GetRGBA(v,SDL_GetPixelFormatDetails(pixels->format),nullptr,&r,&g,&b,&a);return r>245&&g<5;};
|
||||
assert(redAt(1,1)&&redAt(62,62)&&redAt(62,1)&&redAt(1,62)&&redAt(32,32));
|
||||
SDL_DestroySurface(pixels);SDL_RenderPresent(renderer);
|
||||
}
|
||||
{
|
||||
ava2::Gr2SceneRenderer raster(64,64);
|
||||
raster.SetGPUDevice(device);
|
||||
|
||||
Reference in New Issue
Block a user