Skip to main content
The RESC (Resolution Scaling) library provides hardware-accelerated resolution conversion and scaling for PlayStation 3 applications. It enables rendering at one resolution and outputting at another, supporting multiple display modes with minimal performance impact.

Overview

RESC allows you to:
  • Render at lower resolutions (e.g., 720p) and upscale to higher resolutions (1080p)
  • Support multiple display modes simultaneously (480p, 720p, 1080i, 1080p)
  • Apply convolution filters for improved image quality
  • Handle PAL temporal conversion modes
  • Manage aspect ratio conversion (letterbox, pan-scan)

Initialization

rescInit

Initialize the RESC library.
s32 rescInit(const rescInitConfig* const initConfig);
initConfig
const rescInitConfig*
required
Pointer to initialization configuration structure
return
s32
Returns 0 on success, error code on failure
typedef struct _resc_init_config {
    u32 size;              // Size of this structure
    u32 resourcePolicy;    // RESC_CONSTANT_VRAM or RESC_MINIMUM_VRAM
    u32 supportModes;      // OR'd combination of RESC_720x480, RESC_720x576, etc.
    u32 ratioMode;         // RESC_FULLSCREEN, RESC_LETTERBOX, or RESC_PANSCAN
    u32 palTemporalMode;   // PAL temporal conversion mode
    u32 interlaceMode;     // Interlace mode
    u32 flipMode;          // RESC_DISPLAY_VSYNC or RESC_DISPLAY_HSYNC
} rescInitConfig;
Example
rescInitConfig config;
config.size = sizeof(rescInitConfig);
config.resourcePolicy = RESC_MINIMUM_VRAM;
config.supportModes = RESC_720x480 | RESC_1280x720 | RESC_1920x1080;
config.ratioMode = RESC_FULLSCREEN;
config.palTemporalMode = RESC_PAL_50;
config.interlaceMode = RESC_INTERLACE_FILTER;
config.flipMode = RESC_DISPLAY_VSYNC;

if (rescInit(&config) != 0) {
    // Handle initialization error
}

rescExit

Shutdown and cleanup the RESC library.
void rescExit();
Call this before exiting your application to free RESC resources.

Configuration

rescSetDsts

Set destination buffer configuration.
s32 rescSetDsts(u32 dstsMode, rescDsts *dsts);
dstsMode
u32
required
Destination mode: RESC_720x480, RESC_720x576, RESC_1280x720, or RESC_1920x1080
dsts
rescDsts*
required
Pointer to destination configuration structure
return
s32
Returns 0 on success, error code on failure
typedef struct _resc_dsts {
    u32 format;        // RESC_SURFACE_A8R8G8B8 or RESC_SURFACE_F_W16Z16Y16X16
    u32 pitch;         // Pitch in bytes
    u32 heightAlign;   // Height alignment
} rescDsts;
Example
rescDsts dsts;
dsts.format = RESC_SURFACE_A8R8G8B8;
dsts.pitch = 1920 * 4;  // 1920 pixels * 4 bytes per pixel
dsts.heightAlign = 1;
rescSetDsts(RESC_1920x1080, &dsts);

rescSetDisplayMode

Set the current display mode.
s32 rescSetDisplayMode(u32 bufferMode);
bufferMode
u32
required
Display mode: RESC_720x480, RESC_720x576, RESC_1280x720, or RESC_1920x1080
return
s32
Returns 0 on success, error code on failure

rescSetSrc

Set source buffer for rendering.
s32 rescSetSrc(s32 idx, rescSrc *src);
idx
s32
required
Source buffer index
src
rescSrc*
required
Pointer to source configuration structure
return
s32
Returns 0 on success, error code on failure
typedef struct _resc_src {
    u32 format;   // Surface format
    u32 pitch;    // Pitch in bytes
    u16 width;    // Width in pixels
    u16 height;   // Height in pixels
    u32 offset;   // Buffer offset
} rescSrc;
Example
// Set 720p source buffer
rescSrc src;
src.format = GCM_SURFACE_A8R8G8B8;
src.pitch = 1280 * 4;
src.width = 1280;
src.height = 720;
rsxAddressToOffset(render_buffer, &src.offset);
rescSetSrc(0, &src);

Buffer Management

rescGetNumColorBuffers

Get the number of color buffers required.
s32 rescGetNumColorBuffers(u32 dstsMode, u32 palTemporalMode, u32 reserved);
dstsMode
u32
required
Destination mode
palTemporalMode
u32
required
PAL temporal mode
reserved
u32
required
Reserved (set to 0)
return
s32
Number of color buffers required, or negative error code

rescGetBufferSize

Get required buffer sizes.
s32 rescGetBufferSize(int *colorBuffers, int *vertexArray, int *fragmentShader);
colorBuffers
int*
required
Pointer to receive color buffer size
vertexArray
int*
required
Pointer to receive vertex array size
fragmentShader
int*
required
Pointer to receive fragment shader size
return
s32
Returns 0 on success, error code on failure
Example
int color_size, vertex_size, fragment_size;
rescGetBufferSize(&color_size, &vertex_size, &fragment_size);

void *color_buffer = rsxMemalign(64, color_size);
void *vertex_buffer = rsxMemalign(64, vertex_size);
void *fragment_buffer = rsxMemalign(64, fragment_size);

rescSetBufferAddress

Set buffer addresses for RESC.
s32 rescSetBufferAddress(void *colorBuffers, void *vertexArray, void *fragmentShader);
colorBuffers
void*
required
Pointer to color buffer memory
vertexArray
void*
required
Pointer to vertex array memory
fragmentShader
void*
required
Pointer to fragment shader memory
return
s32
Returns 0 on success, error code on failure

Rendering and Display

rescSetConvertAndFlip

Perform resolution conversion and flip the display.
s32 rescSetConvertAndFlip(gcmContextData *context, s32 idx);
context
gcmContextData*
required
Pointer to GCM context
idx
s32
required
Source buffer index
return
s32
Returns 0 on success, error code on failure
This function scales the source buffer to the destination resolution and flips the display.
Example
// Render to 720p buffer
render_frame_720p();

// Scale to 1080p and flip
rescSetConvertAndFlip(context, current_buffer);

rescSetWaitFlip

Wait for flip to complete.
void rescSetWaitFlip(gcmContextData *context);
context
gcmContextData*
required
Pointer to GCM context
Equivalent to gcmSetWaitFlip() but used with RESC.

rescGetFlipStatus

Get the current flip status.
u32 rescGetFlipStatus();
return
u32
Returns flip status
Equivalent to gcmGetFlipStatus().

rescResetFlipStatus

Reset the flip status.
void rescResetFlipStatus();
Equivalent to gcmResetFlipStatus().

rescGetLastFlipTime

Get timestamp of last flip.
s64 rescGetLastFlipTime();
return
s64
Timestamp of last flip
Equivalent to gcmGetLastFlipTime().

Event Handlers

rescSetVBlankHandler

Register a VBlank callback handler.
void rescSetVBlankHandler(void (*handler)(u32 head));
handler
void (*)(u32 head)
required
Callback function (NULL to cancel)
Equivalent to gcmSetVBlankHandler().

rescSetFlipHandler

Register a flip callback handler.
void rescSetFlipHandler(void (*handler)(u32 head));
handler
void (*)(u32 head)
required
Callback function (NULL to cancel)
Equivalent to gcmSetFlipHandler().

Advanced Configuration

rescAdjustAspectRatio

Adjust aspect ratio for output.
s32 rescAdjustAspectRatio(float horizontal, float vertical);
horizontal
float
required
Horizontal scale factor
vertical
float
required
Vertical scale factor
return
s32
Returns 0 on success, error code on failure
Example
// Adjust for 16:9 to 4:3 conversion
rescAdjustAspectRatio(0.75f, 1.0f);

rescSetPalInterpolateDropFlexRatio

Set PAL interpolation drop flex ratio.
s32 rescSetPalInterpolateDropFlexRatio(float ratio);
ratio
float
required
Flex ratio value
return
s32
Returns 0 on success, error code on failure

rescCreateInterlaceTable

Create an interlace conversion table.
s32 rescCreateInterlaceTable(void *ea, float srcH, s32 depth, int length);
ea
void*
required
Effective address for table
srcH
float
required
Source height
depth
s32
required
Depth value
length
int
required
Table length
return
s32
Returns 0 on success, error code on failure

rescGetRegisterCount

Get the current register count.
s32 rescGetRegisterCount();
return
s32
Current register count

rescSetRegisterCount

Set the register count.
void rescSetRegisterCount(s32 count);
count
s32
required
Register count to set

Utility Functions

rescGcmSurface2RescSrc

Convert a GCM surface to RESC source format.
s32 rescGcmSurface2RescSrc(gcmSurface *surface, rescSrc *src);
surface
gcmSurface*
required
Pointer to GCM surface structure
src
rescSrc*
required
Pointer to receive RESC source structure
return
s32
Returns 0 on success, error code on failure
This utility helps convert between GCM and RESC formats.

rescVideoResolution2RescBufferMode

Convert video resolution ID to RESC buffer mode.
s32 rescVideoResolution2RescBufferMode(u32 resolutionId, u32 *bufferMode);
resolutionId
u32
required
Video resolution ID
bufferMode
u32*
required
Pointer to receive RESC buffer mode
return
s32
Returns 0 on success, error code on failure

Constants

Resource Policies

  • RESC_CONSTANT_VRAM (0) - Use constant VRAM allocation
  • RESC_MINIMUM_VRAM (1) - Use minimum VRAM allocation
  • RESC_CONSTANT_GPU_LOAD (0) - Constant GPU load (deprecated)
  • RESC_MINIMUM_GPU_LOAD (2) - Minimum GPU load

Display Modes

  • RESC_720x480 (1) - 480p SD resolution
  • RESC_720x576 (2) - 576p PAL resolution
  • RESC_1280x720 (4) - 720p HD resolution
  • RESC_1920x1080 (8) - 1080p Full HD resolution

Ratio Modes

  • RESC_FULLSCREEN (0) - Stretch to fill screen
  • RESC_LETTERBOX (1) - Add black bars to maintain aspect ratio
  • RESC_PANSCAN (2) - Crop to fill screen

PAL Temporal Modes

  • RESC_PAL_50 (0) - 50Hz PAL
  • RESC_PAL_60_DROP (1) - 60Hz with frame dropping
  • RESC_PAL_60_INTERPOLATE (2) - 60Hz with interpolation
  • RESC_PAL_60_INTERPOLATE_30_DROP (3) - 60Hz interpolated with 30fps drop
  • RESC_PAL_60_INTERPOLATE_DROP_FLEXIBLE (4) - Flexible interpolation
  • RESC_PAL_60_FOR_HSYNC (5) - 60Hz for HSync

Convolution Filters

  • RESC_NORMAL_BILINEAR (0) - Standard bilinear filtering
  • RESC_INTERLACE_FILTER (1) - Interlace filtering
  • RESC_3X3_GAUSSIAN (2) - 3x3 Gaussian blur
  • RESC_2X3_QUINCUNX (3) - 2x3 quincunx filtering
  • RESC_2X3_QUINCUNX_ALT (4) - Alternative 2x3 quincunx

Surface Formats

  • RESC_SURFACE_A8R8G8B8 (8) - 32-bit ARGB
  • RESC_SURFACE_F_W16Z16Y16X16 (11) - 64-bit float

Error Codes

  • RESC_ERROR_NOT_INITIALIZED (0x80210301) - RESC not initialized
  • RESC_ERROR_REINITIALIZED (0x80210302) - Already initialized
  • RESC_ERROR_BAD_ALIGNMENT (0x80210303) - Bad memory alignment
  • RESC_ERROR_BAD_ARGUMENT (0x80210304) - Invalid argument
  • RESC_ERROR_LESS_MEMORY (0x80210305) - Insufficient memory
  • RESC_ERROR_GCM_FLIP_QUE_FULL (0x80210306) - Flip queue full
  • RESC_ERROR_BAD_COMBINATION (0x80210307) - Invalid combination

Complete Example

Full RESC Setup
#include <rsx/resc.h>

// Initialize RESC
rescInitConfig config;
config.size = sizeof(rescInitConfig);
config.resourcePolicy = RESC_MINIMUM_VRAM;
config.supportModes = RESC_1280x720 | RESC_1920x1080;
config.ratioMode = RESC_FULLSCREEN;
config.palTemporalMode = RESC_PAL_50;
config.interlaceMode = RESC_INTERLACE_FILTER;
config.flipMode = RESC_DISPLAY_VSYNC;
rescInit(&config);

// Configure destination (1080p output)
rescDsts dsts;
dsts.format = RESC_SURFACE_A8R8G8B8;
dsts.pitch = 1920 * 4;
dsts.heightAlign = 1;
rescSetDsts(RESC_1920x1080, &dsts);
rescSetDisplayMode(RESC_1920x1080);

// Allocate buffers
int color_size, vertex_size, fragment_size;
rescGetBufferSize(&color_size, &vertex_size, &fragment_size);

void *color_buffer = rsxMemalign(64, color_size);
void *vertex_buffer = rsxMemalign(64, vertex_size);
void *fragment_buffer = rsxMemalign(64, fragment_size);

rescSetBufferAddress(color_buffer, vertex_buffer, fragment_buffer);

// Set source (720p rendering)
rescSrc src;
src.format = GCM_SURFACE_A8R8G8B8;
src.pitch = 1280 * 4;
src.width = 1280;
src.height = 720;
rsxAddressToOffset(render_buffer, &src.offset);
rescSetSrc(0, &src);

// Main loop
while (running) {
    // Render to 720p buffer
    render_frame();
    
    // Scale to 1080p and flip
    rescSetConvertAndFlip(context, 0);
    rescSetWaitFlip(context);
}

// Cleanup
rescExit();

See Also

  • RSX - RSX initialization and management
  • GCM System - Low-level command buffer operations

Build docs developers (and LLMs) love