Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.
This reverts commit a9be52c41a.
This commit is contained in:
@@ -353,7 +353,7 @@ static void gdraw_defragment_cache(GDrawHandleCache *c, GDrawStats *stats)
|
||||
|
||||
// synchronize
|
||||
compute_to_graphics_sync();
|
||||
gdraw->gfxc->setCsShader(nullptr);
|
||||
gdraw->gfxc->setCsShader(NULL);
|
||||
gdraw->gfxc->setShaderType(Gnm::kShaderTypeGraphics);
|
||||
|
||||
// don't need to wait till GPU is done since we never access GPU memory from the
|
||||
@@ -365,7 +365,7 @@ static void api_free_resource(GDrawHandle *r)
|
||||
if (!r->cache->is_vertex) {
|
||||
for (S32 i=0; i < MAX_SAMPLERS; i++)
|
||||
if (gdraw->active_tex[i] == (GDrawTexture *) r)
|
||||
gdraw->active_tex[i] = nullptr;
|
||||
gdraw->active_tex[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ static void track_staging_alloc_attempt(U32 size, U32 align)
|
||||
static void track_staging_alloc_failed()
|
||||
{
|
||||
if (gdraw->staging_stats.allocs_attempted == gdraw->staging_stats.allocs_succeeded + 1) { // warn the first time we run out of mem
|
||||
IggyGDrawSendWarning(nullptr, "GDraw out of staging memory");
|
||||
IggyGDrawSendWarning(NULL, "GDraw out of staging memory");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ static void gpu_compute_memset(void *ptr, U32 value, U32 size_in_bytes)
|
||||
// through the regular caches.
|
||||
gfxc->flushShaderCachesAndWait(Gnm::kCacheActionWriteBackL2Volatile, 0, Gnm::kStallCommandBufferParserDisable);
|
||||
gfxc->setShaderType(Gnm::kShaderTypeGraphics);
|
||||
gfxc->setCsShader(nullptr);
|
||||
gfxc->setCsShader(NULL);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -549,8 +549,8 @@ GDrawTexture * RADLINK gdraw_orbis_WrappedTextureCreate(Gnm::Texture *tex)
|
||||
{
|
||||
GDrawStats stats = {};
|
||||
GDrawHandle *p = gdraw_res_alloc_begin(gdraw->texturecache, 0, &stats);
|
||||
p->handle.tex.gnm_ptr = nullptr;
|
||||
gdraw_HandleCacheAllocateEnd(p, 0, nullptr, GDRAW_HANDLE_STATE_user_owned);
|
||||
p->handle.tex.gnm_ptr = NULL;
|
||||
gdraw_HandleCacheAllocateEnd(p, 0, NULL, GDRAW_HANDLE_STATE_user_owned);
|
||||
gdraw_orbis_WrappedTextureChange((GDrawTexture *) p, tex);
|
||||
return (GDrawTexture *) p;
|
||||
}
|
||||
@@ -583,13 +583,13 @@ static void RADLINK gdraw_SetTextureUniqueID(GDrawTexture *tex, void *old_id, vo
|
||||
static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height, gdraw_texture_format gformat, U32 flags, GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *stats)
|
||||
{
|
||||
S32 bytes_pixel = 4;
|
||||
GDrawHandle *t = nullptr;
|
||||
GDrawHandle *t = NULL;
|
||||
Gnm::Texture gt;
|
||||
Gnm::SizeAlign sa;
|
||||
|
||||
Gnm::DataFormat format = Gnm::kDataFormatR8G8B8A8Unorm;
|
||||
if (width > MAX_TEXTURE2D_DIM || height > MAX_TEXTURE2D_DIM) {
|
||||
IggyGDrawSendWarning(nullptr, "GDraw %d x %d texture not supported by hardware (dimension limit %d)", width, height, MAX_TEXTURE2D_DIM);
|
||||
IggyGDrawSendWarning(NULL, "GDraw %d x %d texture not supported by hardware (dimension limit %d)", width, height, MAX_TEXTURE2D_DIM);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -742,8 +742,8 @@ static void RADLINK gdraw_UpdateTextureEnd(GDrawTexture *t, void *unique_id, GDr
|
||||
static void RADLINK gdraw_FreeTexture(GDrawTexture *tt, void *unique_id, GDrawStats *stats)
|
||||
{
|
||||
GDrawHandle *t = (GDrawHandle *) tt;
|
||||
assert(t != nullptr);
|
||||
if (t->owner == unique_id || unique_id == nullptr) {
|
||||
assert(t != NULL);
|
||||
if (t->owner == unique_id || unique_id == NULL) {
|
||||
if (t->cache == &gdraw->rendertargets) {
|
||||
gdraw_HandleCacheUnlock(t);
|
||||
// cache it by simply not freeing it
|
||||
@@ -863,7 +863,7 @@ static rrbool RADLINK gdraw_TryLockVertexBuffer(GDrawVertexBuffer *vb, void *uni
|
||||
static void RADLINK gdraw_FreeVertexBuffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats)
|
||||
{
|
||||
GDrawHandle *h = (GDrawHandle *) vb;
|
||||
assert(h != nullptr); // @GDRAW_ASSERT
|
||||
assert(h != NULL); // @GDRAW_ASSERT
|
||||
if (h->owner == unique_id)
|
||||
gdraw_res_kill(h, stats);
|
||||
}
|
||||
@@ -891,19 +891,19 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats)
|
||||
|
||||
t = gdraw_HandleCacheAllocateBegin(&gdraw->rendertargets);
|
||||
if (!t) {
|
||||
IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: hit handle limit");
|
||||
IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: hit handle limit");
|
||||
return t;
|
||||
}
|
||||
|
||||
U8 *ptr = (U8 *)gdraw_arena_alloc(&gdraw->rt_arena, gdraw->rt_colorbuffer_sa.m_size, gdraw->rt_colorbuffer_sa.m_align);
|
||||
if (!ptr) {
|
||||
IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: out of rendertarget texture memory");
|
||||
IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: out of rendertarget texture memory");
|
||||
gdraw_HandleCacheAllocateFail(t);
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
t->fence = get_next_fence();
|
||||
t->raw_ptr = nullptr;
|
||||
t->raw_ptr = NULL;
|
||||
|
||||
t->handle.tex.gnm_ptr = ptr;
|
||||
t->handle.tex.gnm->initFromRenderTarget(&gdraw->rt_colorbuffer, false);
|
||||
@@ -1065,7 +1065,7 @@ static void set_common_renderstate()
|
||||
|
||||
// clear our state caching
|
||||
memset(gdraw->active_tex, 0, sizeof(gdraw->active_tex));
|
||||
gdraw->cur_ps = nullptr;
|
||||
gdraw->cur_ps = NULL;
|
||||
gdraw->scissor_state = ~0u;
|
||||
gdraw->blend_mode = -1;
|
||||
|
||||
@@ -1230,7 +1230,7 @@ static void eliminate_fast_clear()
|
||||
}
|
||||
|
||||
gfxc->setCbControl(Gnm::kCbModeEliminateFastClear, Gnm::kRasterOpSrcCopy);
|
||||
gfxc->setPsShader(nullptr);
|
||||
gfxc->setPsShader(NULL);
|
||||
set_viewport_raw(r.x0, r.y0, r.x1 - r.x0, r.y1 - r.y0);
|
||||
set_projection_raw(r.x0, r.x1, r.y1, r.y0);
|
||||
GDrawStats stats = {}; // we already counted these clears once, so don't add to main stats
|
||||
@@ -1245,7 +1245,7 @@ static void eliminate_fast_clear()
|
||||
set_viewport();
|
||||
set_projection();
|
||||
|
||||
gdraw->cur_ps = nullptr;
|
||||
gdraw->cur_ps = NULL;
|
||||
gdraw->cur->needs_clear_eliminate = false;
|
||||
}
|
||||
|
||||
@@ -1276,7 +1276,7 @@ static inline U32 pack_color_8888(F32 x, F32 y, F32 z, F32 w)
|
||||
|
||||
void gdraw_orbis_ClearWholeRenderTarget(const F32 clear_color_rgba[4])
|
||||
{
|
||||
assert(gdraw->gfxc != nullptr); // call after gdraw_orbis_Begin
|
||||
assert(gdraw->gfxc != NULL); // call after gdraw_orbis_Begin
|
||||
|
||||
gdraw->cur = gdraw->frame;
|
||||
set_common_renderstate();
|
||||
@@ -1336,16 +1336,16 @@ static void RADLINK gdraw_SetViewSizeAndWorldScale(S32 w, S32 h, F32 scalex, F32
|
||||
// must include anything necessary for texture creation/update
|
||||
static void RADLINK gdraw_RenderingBegin(void)
|
||||
{
|
||||
assert(gdraw->gfxc != nullptr); // call after gdraw_orbis_Begin
|
||||
assert(gdraw->gfxc != NULL); // call after gdraw_orbis_Begin
|
||||
|
||||
// unbind all shaders
|
||||
Gnmx::GfxContext *gfxc = gdraw->gfxc;
|
||||
gfxc->setVsShader(nullptr, 0, (void*)0);
|
||||
gfxc->setPsShader(nullptr);
|
||||
gfxc->setCsShader(nullptr);
|
||||
gfxc->setLsHsShaders(nullptr, 0, (void*)0, nullptr, 0);
|
||||
gfxc->setEsShader(nullptr, 0, (void *) 0);
|
||||
gfxc->setGsVsShaders(nullptr);
|
||||
gfxc->setVsShader(NULL, 0, (void*)0);
|
||||
gfxc->setPsShader(NULL);
|
||||
gfxc->setCsShader(NULL);
|
||||
gfxc->setLsHsShaders(NULL, 0, (void*)0, NULL, 0);
|
||||
gfxc->setEsShader(NULL, 0, (void *) 0);
|
||||
gfxc->setGsVsShaders(NULL);
|
||||
|
||||
set_common_renderstate();
|
||||
}
|
||||
@@ -1406,7 +1406,7 @@ GDRAW_MAYBE_UNUSED static bool mem_is_direct_and_write_combined_or_cached(const
|
||||
|
||||
void gdraw_orbis_Begin(sce::Gnmx::GfxContext *context, void *staging_buffer, U32 staging_buf_bytes)
|
||||
{
|
||||
assert(gdraw->gfxc == nullptr); // may not nest Begin calls
|
||||
assert(gdraw->gfxc == NULL); // may not nest Begin calls
|
||||
|
||||
// make sure that the memory setup is sensible.
|
||||
// if any of these asserts fire, please relocate your command buffers
|
||||
@@ -1426,13 +1426,13 @@ void gdraw_orbis_Begin(sce::Gnmx::GfxContext *context, void *staging_buffer, U32
|
||||
|
||||
void gdraw_orbis_End(gdraw_orbis_staging_stats *stats)
|
||||
{
|
||||
assert(gdraw->gfxc != nullptr); // please keep Begin / End pairs properly matched
|
||||
assert(gdraw->gfxc != NULL); // please keep Begin / End pairs properly matched
|
||||
|
||||
gdraw_HandleCacheTick(gdraw->texturecache, gdraw->tile_end_fence);
|
||||
gdraw_HandleCacheTick(gdraw->vbufcache, gdraw->tile_end_fence);
|
||||
|
||||
gdraw_arena_init(&gdraw->staging, nullptr, 0);
|
||||
gdraw->gfxc = nullptr;
|
||||
gdraw_arena_init(&gdraw->staging, NULL, 0);
|
||||
gdraw->gfxc = NULL;
|
||||
|
||||
if (stats)
|
||||
*stats = gdraw->staging_stats;
|
||||
@@ -1440,7 +1440,7 @@ void gdraw_orbis_End(gdraw_orbis_staging_stats *stats)
|
||||
|
||||
void gdraw_orbis_EliminateFastClears(void)
|
||||
{
|
||||
assert(gdraw->gfxc != nullptr); // call between gdraw_orbis_Begin and gdraw_orbis_End
|
||||
assert(gdraw->gfxc != NULL); // call between gdraw_orbis_Begin and gdraw_orbis_End
|
||||
|
||||
eliminate_fast_clear();
|
||||
}
|
||||
@@ -1469,18 +1469,18 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex
|
||||
GDrawFramebufferState *n = gdraw->cur+1;
|
||||
GDrawHandle *t;
|
||||
if (gdraw->tw == 0 || gdraw->th == 0) {
|
||||
IggyGDrawSendWarning(nullptr, "GDraw warning: w=0,h=0 rendertarget");
|
||||
IggyGDrawSendWarning(NULL, "GDraw warning: w=0,h=0 rendertarget");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (n >= &gdraw->frame[MAX_RENDER_STACK_DEPTH]) {
|
||||
IggyGDrawSendWarning(nullptr, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH");
|
||||
IggyGDrawSendWarning(NULL, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (owner) {
|
||||
// @TODO implement
|
||||
t = nullptr;
|
||||
t = NULL;
|
||||
assert(0); // nyi
|
||||
} else {
|
||||
t = get_color_rendertarget(stats);
|
||||
@@ -1489,9 +1489,9 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex
|
||||
}
|
||||
|
||||
n->color_buffer = t;
|
||||
assert(n->color_buffer != nullptr); // @GDRAW_ASSERT
|
||||
assert(n->color_buffer != NULL); // @GDRAW_ASSERT
|
||||
|
||||
n->cached = owner != nullptr;
|
||||
n->cached = owner != NULL;
|
||||
if (owner) {
|
||||
n->base_x = region->x0;
|
||||
n->base_y = region->y0;
|
||||
@@ -1571,9 +1571,9 @@ static GDrawTexture *RADLINK gdraw_TextureDrawBufferEnd(GDrawStats *stats)
|
||||
assert(m >= gdraw->frame); // bug in Iggy -- unbalanced
|
||||
|
||||
if (m != gdraw->frame) {
|
||||
assert(m->color_buffer != nullptr); // @GDRAW_ASSERT
|
||||
assert(m->color_buffer != NULL); // @GDRAW_ASSERT
|
||||
}
|
||||
assert(n->color_buffer != nullptr); // @GDRAW_ASSERT
|
||||
assert(n->color_buffer != NULL); // @GDRAW_ASSERT
|
||||
|
||||
// sync on draw completion for this render target
|
||||
rtt_sync(n->color_buffer->handle.tex.gnm_ptr, gdraw->rt_colorbuffer_sa.m_size >> 8);
|
||||
@@ -1615,7 +1615,7 @@ static void RADLINK gdraw_ClearID(void)
|
||||
static RADINLINE void set_texture(U32 texunit, GDrawTexture *tex)
|
||||
{
|
||||
assert(texunit < MAX_SAMPLERS);
|
||||
assert(tex != nullptr);
|
||||
assert(tex != NULL);
|
||||
|
||||
if (gdraw->active_tex[texunit] != tex) {
|
||||
gdraw->active_tex[texunit] = tex;
|
||||
@@ -1791,7 +1791,7 @@ static void set_vertex_buffer(const GDraw::VFormatDesc *fmtdesc, void *ptr, U32
|
||||
gdraw->gfxc->setBuffers(Gnm::kShaderStageVs, 0, fmtdesc->num_attribs, bufs);
|
||||
}
|
||||
|
||||
static RADINLINE void fence_resources(void *r1, void *r2=nullptr, void *r3=nullptr, void *r4=nullptr)
|
||||
static RADINLINE void fence_resources(void *r1, void *r2=NULL, void *r3=NULL, void *r4=NULL)
|
||||
{
|
||||
GDrawFence fence = get_next_fence();
|
||||
if (r1) ((GDrawHandle *) r1)->fence = fence;
|
||||
@@ -1937,7 +1937,7 @@ static void set_clamp_constant(F32 *constant, GDrawTexture *tex)
|
||||
|
||||
static void gdraw_Filter(GDrawRenderState *r, gswf_recti *s, float *tc, int isbevel, GDrawStats *stats)
|
||||
{
|
||||
if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, nullptr, stats))
|
||||
if (!gdraw_TextureDrawBufferBegin(s, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, NULL, stats))
|
||||
return;
|
||||
|
||||
set_texture(0, r->tex[0]);
|
||||
@@ -2236,7 +2236,7 @@ static GDrawHandleCache *make_handle_cache(gdraw_orbis_resourcetype type, U32 al
|
||||
cache->alloc = gfxalloc_create(gdraw_limits[type].ptr, num_bytes, align, num_handles);
|
||||
if (!cache->alloc) {
|
||||
IggyGDrawFree(cache);
|
||||
cache = nullptr;
|
||||
cache = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2302,12 +2302,12 @@ int gdraw_orbis_SetResourceMemory(gdraw_orbis_resourcetype type, S32 num_handles
|
||||
case GDRAW_ORBIS_RESOURCE_texture:
|
||||
free_handle_cache(gdraw->texturecache);
|
||||
gdraw->texturecache = make_handle_cache(GDRAW_ORBIS_RESOURCE_texture, GDRAW_ORBIS_TEXTURE_ALIGNMENT);
|
||||
return gdraw->texturecache != nullptr;
|
||||
return gdraw->texturecache != NULL;
|
||||
|
||||
case GDRAW_ORBIS_RESOURCE_vertexbuffer:
|
||||
free_handle_cache(gdraw->vbufcache);
|
||||
gdraw->vbufcache = make_handle_cache(GDRAW_ORBIS_RESOURCE_vertexbuffer, GDRAW_ORBIS_VERTEXBUFFER_ALIGNMENT);
|
||||
return gdraw->vbufcache != nullptr;
|
||||
return gdraw->vbufcache != NULL;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
@@ -2316,9 +2316,9 @@ int gdraw_orbis_SetResourceMemory(gdraw_orbis_resourcetype type, S32 num_handles
|
||||
|
||||
void gdraw_orbis_ResetAllResourceMemory()
|
||||
{
|
||||
gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_rendertarget, 0, nullptr, 0);
|
||||
gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_texture, 0, nullptr, 0);
|
||||
gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_vertexbuffer, 0, nullptr, 0);
|
||||
gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_rendertarget, 0, NULL, 0);
|
||||
gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_texture, 0, NULL, 0);
|
||||
gdraw_orbis_SetResourceMemory(GDRAW_ORBIS_RESOURCE_vertexbuffer, 0, NULL, 0);
|
||||
}
|
||||
|
||||
GDrawFunctions *gdraw_orbis_CreateContext(S32 w, S32 h, void *context_shared_mem)
|
||||
@@ -2326,7 +2326,7 @@ GDrawFunctions *gdraw_orbis_CreateContext(S32 w, S32 h, void *context_shared_mem
|
||||
U32 cpram_shadow_size = Gnmx::ConstantUpdateEngine::computeCpRamShadowSize();
|
||||
|
||||
gdraw = (GDraw *) IggyGDrawMalloc(sizeof(*gdraw) + cpram_shadow_size);
|
||||
if (!gdraw) return nullptr;
|
||||
if (!gdraw) return NULL;
|
||||
|
||||
memset(gdraw, 0, sizeof(*gdraw));
|
||||
|
||||
@@ -2349,7 +2349,7 @@ GDrawFunctions *gdraw_orbis_CreateContext(S32 w, S32 h, void *context_shared_mem
|
||||
Gnm::DataFormat rtFormat = Gnm::kDataFormatR8G8B8A8Unorm;
|
||||
Gnm::TileMode tileMode;
|
||||
GpuAddress::computeSurfaceTileMode(&tileMode, GpuAddress::kSurfaceTypeRwTextureFlat, rtFormat, 1);
|
||||
gdraw->rt_colorbuffer_sa = gdraw->rt_colorbuffer.init(gdraw->frametex_width, gdraw->frametex_height, 1, rtFormat, tileMode, Gnm::kNumSamples1, Gnm::kNumFragments1, nullptr, nullptr);
|
||||
gdraw->rt_colorbuffer_sa = gdraw->rt_colorbuffer.init(gdraw->frametex_width, gdraw->frametex_height, 1, rtFormat, tileMode, Gnm::kNumSamples1, Gnm::kNumFragments1, NULL, NULL);
|
||||
gdraw->rt_colorbuffer.setCmaskFastClearEnable(false);
|
||||
|
||||
// shaders and state
|
||||
@@ -2418,7 +2418,7 @@ void gdraw_orbis_DestroyContext(void)
|
||||
free_handle_cache(gdraw->texturecache);
|
||||
free_handle_cache(gdraw->vbufcache);
|
||||
IggyGDrawFree(gdraw);
|
||||
gdraw = nullptr;
|
||||
gdraw = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ IDOC extern int gdraw_orbis_SetResourceMemory(gdraw_orbis_resourcetype type, S32
|
||||
currently hold.
|
||||
|
||||
SetResourceMemory takes a void* argument for the address of the resource pool.
|
||||
Pass in nullptr and zero bytes to reset a specific pool.
|
||||
Pass in NULL and zero bytes to reset a specific pool.
|
||||
|
||||
Resource pool memory has certain alignment requirements - see the #defines
|
||||
above. If you pass in an unaligned pointer, GDraw will automatically clip off
|
||||
@@ -86,7 +86,7 @@ IDOC extern GDrawFunctions * gdraw_orbis_CreateContext(S32 w, S32 h, void *conte
|
||||
There can only be one GDraw context active at any one time.
|
||||
|
||||
If initialization fails for some reason (the main reason would be an out of memory condition),
|
||||
nullptr is returned. Otherwise, you can pass the return value to IggySetGDraw. */
|
||||
NULL is returned. Otherwise, you can pass the return value to IggySetGDraw. */
|
||||
|
||||
IDOC extern void gdraw_orbis_DestroyContext(void);
|
||||
/* Destroys the current GDraw context, if any.
|
||||
@@ -126,7 +126,7 @@ IDOC extern void gdraw_orbis_End(gdraw_orbis_staging_stats *staging_stats);
|
||||
|
||||
staging_stats will be filled with stats for the staging buffer, denoting how much memory
|
||||
was actually used and which allocations were attempted. If you're not interested, just
|
||||
pass nullptr. */
|
||||
pass NULL. */
|
||||
|
||||
IDOC extern void gdraw_orbis_SetTileOrigin(sce::Gnm::RenderTarget *color, sce::Gnm::DepthRenderTarget *depth, S32 x, S32 y);
|
||||
/* This sets the main color and depth buffers that GDraw should render to and the
|
||||
|
||||
@@ -517,24 +517,24 @@ static unsigned char pshader_basic_17[412] = {
|
||||
};
|
||||
|
||||
static ShaderCode pshader_basic_arr[18] = {
|
||||
{ pshader_basic_0, { nullptr } },
|
||||
{ pshader_basic_1, { nullptr } },
|
||||
{ pshader_basic_2, { nullptr } },
|
||||
{ pshader_basic_3, { nullptr } },
|
||||
{ pshader_basic_4, { nullptr } },
|
||||
{ pshader_basic_5, { nullptr } },
|
||||
{ pshader_basic_6, { nullptr } },
|
||||
{ pshader_basic_7, { nullptr } },
|
||||
{ pshader_basic_8, { nullptr } },
|
||||
{ pshader_basic_9, { nullptr } },
|
||||
{ pshader_basic_10, { nullptr } },
|
||||
{ pshader_basic_11, { nullptr } },
|
||||
{ pshader_basic_12, { nullptr } },
|
||||
{ pshader_basic_13, { nullptr } },
|
||||
{ pshader_basic_14, { nullptr } },
|
||||
{ pshader_basic_15, { nullptr } },
|
||||
{ pshader_basic_16, { nullptr } },
|
||||
{ pshader_basic_17, { nullptr } },
|
||||
{ pshader_basic_0, { NULL } },
|
||||
{ pshader_basic_1, { NULL } },
|
||||
{ pshader_basic_2, { NULL } },
|
||||
{ pshader_basic_3, { NULL } },
|
||||
{ pshader_basic_4, { NULL } },
|
||||
{ pshader_basic_5, { NULL } },
|
||||
{ pshader_basic_6, { NULL } },
|
||||
{ pshader_basic_7, { NULL } },
|
||||
{ pshader_basic_8, { NULL } },
|
||||
{ pshader_basic_9, { NULL } },
|
||||
{ pshader_basic_10, { NULL } },
|
||||
{ pshader_basic_11, { NULL } },
|
||||
{ pshader_basic_12, { NULL } },
|
||||
{ pshader_basic_13, { NULL } },
|
||||
{ pshader_basic_14, { NULL } },
|
||||
{ pshader_basic_15, { NULL } },
|
||||
{ pshader_basic_16, { NULL } },
|
||||
{ pshader_basic_17, { NULL } },
|
||||
};
|
||||
|
||||
static unsigned char pshader_exceptional_blend_1[440] = {
|
||||
@@ -917,19 +917,19 @@ static unsigned char pshader_exceptional_blend_12[336] = {
|
||||
};
|
||||
|
||||
static ShaderCode pshader_exceptional_blend_arr[13] = {
|
||||
{ nullptr, { nullptr } },
|
||||
{ pshader_exceptional_blend_1, { nullptr } },
|
||||
{ pshader_exceptional_blend_2, { nullptr } },
|
||||
{ pshader_exceptional_blend_3, { nullptr } },
|
||||
{ pshader_exceptional_blend_4, { nullptr } },
|
||||
{ pshader_exceptional_blend_5, { nullptr } },
|
||||
{ pshader_exceptional_blend_6, { nullptr } },
|
||||
{ pshader_exceptional_blend_7, { nullptr } },
|
||||
{ pshader_exceptional_blend_8, { nullptr } },
|
||||
{ pshader_exceptional_blend_9, { nullptr } },
|
||||
{ pshader_exceptional_blend_10, { nullptr } },
|
||||
{ pshader_exceptional_blend_11, { nullptr } },
|
||||
{ pshader_exceptional_blend_12, { nullptr } },
|
||||
{ NULL, { NULL } },
|
||||
{ pshader_exceptional_blend_1, { NULL } },
|
||||
{ pshader_exceptional_blend_2, { NULL } },
|
||||
{ pshader_exceptional_blend_3, { NULL } },
|
||||
{ pshader_exceptional_blend_4, { NULL } },
|
||||
{ pshader_exceptional_blend_5, { NULL } },
|
||||
{ pshader_exceptional_blend_6, { NULL } },
|
||||
{ pshader_exceptional_blend_7, { NULL } },
|
||||
{ pshader_exceptional_blend_8, { NULL } },
|
||||
{ pshader_exceptional_blend_9, { NULL } },
|
||||
{ pshader_exceptional_blend_10, { NULL } },
|
||||
{ pshader_exceptional_blend_11, { NULL } },
|
||||
{ pshader_exceptional_blend_12, { NULL } },
|
||||
};
|
||||
|
||||
static unsigned char pshader_filter_0[420] = {
|
||||
@@ -1685,38 +1685,38 @@ static unsigned char pshader_filter_27[412] = {
|
||||
};
|
||||
|
||||
static ShaderCode pshader_filter_arr[32] = {
|
||||
{ pshader_filter_0, { nullptr } },
|
||||
{ pshader_filter_1, { nullptr } },
|
||||
{ pshader_filter_2, { nullptr } },
|
||||
{ pshader_filter_3, { nullptr } },
|
||||
{ pshader_filter_4, { nullptr } },
|
||||
{ pshader_filter_5, { nullptr } },
|
||||
{ pshader_filter_6, { nullptr } },
|
||||
{ pshader_filter_7, { nullptr } },
|
||||
{ pshader_filter_8, { nullptr } },
|
||||
{ pshader_filter_9, { nullptr } },
|
||||
{ pshader_filter_10, { nullptr } },
|
||||
{ pshader_filter_11, { nullptr } },
|
||||
{ nullptr, { nullptr } },
|
||||
{ nullptr, { nullptr } },
|
||||
{ nullptr, { nullptr } },
|
||||
{ nullptr, { nullptr } },
|
||||
{ pshader_filter_16, { nullptr } },
|
||||
{ pshader_filter_17, { nullptr } },
|
||||
{ pshader_filter_18, { nullptr } },
|
||||
{ pshader_filter_19, { nullptr } },
|
||||
{ pshader_filter_20, { nullptr } },
|
||||
{ pshader_filter_21, { nullptr } },
|
||||
{ pshader_filter_22, { nullptr } },
|
||||
{ pshader_filter_23, { nullptr } },
|
||||
{ pshader_filter_24, { nullptr } },
|
||||
{ pshader_filter_25, { nullptr } },
|
||||
{ pshader_filter_26, { nullptr } },
|
||||
{ pshader_filter_27, { nullptr } },
|
||||
{ nullptr, { nullptr } },
|
||||
{ nullptr, { nullptr } },
|
||||
{ nullptr, { nullptr } },
|
||||
{ nullptr, { nullptr } },
|
||||
{ pshader_filter_0, { NULL } },
|
||||
{ pshader_filter_1, { NULL } },
|
||||
{ pshader_filter_2, { NULL } },
|
||||
{ pshader_filter_3, { NULL } },
|
||||
{ pshader_filter_4, { NULL } },
|
||||
{ pshader_filter_5, { NULL } },
|
||||
{ pshader_filter_6, { NULL } },
|
||||
{ pshader_filter_7, { NULL } },
|
||||
{ pshader_filter_8, { NULL } },
|
||||
{ pshader_filter_9, { NULL } },
|
||||
{ pshader_filter_10, { NULL } },
|
||||
{ pshader_filter_11, { NULL } },
|
||||
{ NULL, { NULL } },
|
||||
{ NULL, { NULL } },
|
||||
{ NULL, { NULL } },
|
||||
{ NULL, { NULL } },
|
||||
{ pshader_filter_16, { NULL } },
|
||||
{ pshader_filter_17, { NULL } },
|
||||
{ pshader_filter_18, { NULL } },
|
||||
{ pshader_filter_19, { NULL } },
|
||||
{ pshader_filter_20, { NULL } },
|
||||
{ pshader_filter_21, { NULL } },
|
||||
{ pshader_filter_22, { NULL } },
|
||||
{ pshader_filter_23, { NULL } },
|
||||
{ pshader_filter_24, { NULL } },
|
||||
{ pshader_filter_25, { NULL } },
|
||||
{ pshader_filter_26, { NULL } },
|
||||
{ pshader_filter_27, { NULL } },
|
||||
{ NULL, { NULL } },
|
||||
{ NULL, { NULL } },
|
||||
{ NULL, { NULL } },
|
||||
{ NULL, { NULL } },
|
||||
};
|
||||
|
||||
static unsigned char pshader_blur_2[356] = {
|
||||
@@ -2024,16 +2024,16 @@ static unsigned char pshader_blur_9[748] = {
|
||||
};
|
||||
|
||||
static ShaderCode pshader_blur_arr[10] = {
|
||||
{ nullptr, { nullptr } },
|
||||
{ nullptr, { nullptr } },
|
||||
{ pshader_blur_2, { nullptr } },
|
||||
{ pshader_blur_3, { nullptr } },
|
||||
{ pshader_blur_4, { nullptr } },
|
||||
{ pshader_blur_5, { nullptr } },
|
||||
{ pshader_blur_6, { nullptr } },
|
||||
{ pshader_blur_7, { nullptr } },
|
||||
{ pshader_blur_8, { nullptr } },
|
||||
{ pshader_blur_9, { nullptr } },
|
||||
{ NULL, { NULL } },
|
||||
{ NULL, { NULL } },
|
||||
{ pshader_blur_2, { NULL } },
|
||||
{ pshader_blur_3, { NULL } },
|
||||
{ pshader_blur_4, { NULL } },
|
||||
{ pshader_blur_5, { NULL } },
|
||||
{ pshader_blur_6, { NULL } },
|
||||
{ pshader_blur_7, { NULL } },
|
||||
{ pshader_blur_8, { NULL } },
|
||||
{ pshader_blur_9, { NULL } },
|
||||
};
|
||||
|
||||
static unsigned char pshader_color_matrix_0[348] = {
|
||||
@@ -2062,7 +2062,7 @@ static unsigned char pshader_color_matrix_0[348] = {
|
||||
};
|
||||
|
||||
static ShaderCode pshader_color_matrix_arr[1] = {
|
||||
{ pshader_color_matrix_0, { nullptr } },
|
||||
{ pshader_color_matrix_0, { NULL } },
|
||||
};
|
||||
|
||||
static unsigned char pshader_manual_clear_0[164] = {
|
||||
@@ -2080,7 +2080,7 @@ static unsigned char pshader_manual_clear_0[164] = {
|
||||
};
|
||||
|
||||
static ShaderCode pshader_manual_clear_arr[1] = {
|
||||
{ pshader_manual_clear_0, { nullptr } },
|
||||
{ pshader_manual_clear_0, { NULL } },
|
||||
};
|
||||
|
||||
static unsigned char vshader_vsps4_0[580] = {
|
||||
@@ -2124,7 +2124,7 @@ static unsigned char vshader_vsps4_0[580] = {
|
||||
};
|
||||
|
||||
static ShaderCode vshader_vsps4_arr[1] = {
|
||||
{ vshader_vsps4_0, { nullptr } },
|
||||
{ vshader_vsps4_0, { NULL } },
|
||||
};
|
||||
|
||||
static unsigned char cshader_tex_upload_0[212] = {
|
||||
@@ -2145,7 +2145,7 @@ static unsigned char cshader_tex_upload_0[212] = {
|
||||
};
|
||||
|
||||
static ShaderCode cshader_tex_upload_arr[1] = {
|
||||
{ cshader_tex_upload_0, { nullptr } },
|
||||
{ cshader_tex_upload_0, { NULL } },
|
||||
};
|
||||
|
||||
static unsigned char cshader_memset_0[196] = {
|
||||
@@ -2165,7 +2165,7 @@ static unsigned char cshader_memset_0[196] = {
|
||||
};
|
||||
|
||||
static ShaderCode cshader_memset_arr[1] = {
|
||||
{ cshader_memset_0, { nullptr } },
|
||||
{ cshader_memset_0, { NULL } },
|
||||
};
|
||||
|
||||
static unsigned char cshader_defragment_0[204] = {
|
||||
@@ -2185,7 +2185,7 @@ static unsigned char cshader_defragment_0[204] = {
|
||||
};
|
||||
|
||||
static ShaderCode cshader_defragment_arr[1] = {
|
||||
{ cshader_defragment_0, { nullptr } },
|
||||
{ cshader_defragment_0, { NULL } },
|
||||
};
|
||||
|
||||
static unsigned char cshader_mipgen_0[340] = {
|
||||
@@ -2214,6 +2214,6 @@ static unsigned char cshader_mipgen_0[340] = {
|
||||
};
|
||||
|
||||
static ShaderCode cshader_mipgen_arr[1] = {
|
||||
{ cshader_mipgen_0, { nullptr } },
|
||||
{ cshader_mipgen_0, { NULL } },
|
||||
};
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ static void debug_check_raw_values(GDrawHandleCache *c)
|
||||
s = s->next;
|
||||
}
|
||||
s = c->active;
|
||||
while (s != nullptr) {
|
||||
while (s != NULL) {
|
||||
assert(s->raw_ptr != t->raw_ptr);
|
||||
s = s->next;
|
||||
}
|
||||
@@ -368,7 +368,7 @@ static void gdraw_HandleTransitionInsertBefore(GDrawHandle *t, GDrawHandleState
|
||||
{
|
||||
check_lists(t->cache);
|
||||
assert(t->state != GDRAW_HANDLE_STATE_sentinel); // sentinels should never get here!
|
||||
assert(t->state != static_cast<U32>(new_state)); // code should never call "transition" if it's not transitioning!
|
||||
assert(t->state != (U32) new_state); // code should never call "transition" if it's not transitioning!
|
||||
// unlink from prev state
|
||||
t->prev->next = t->next;
|
||||
t->next->prev = t->prev;
|
||||
@@ -433,7 +433,7 @@ static rrbool gdraw_HandleCacheLockStats(GDrawHandle *t, void *owner, GDrawStats
|
||||
|
||||
static rrbool gdraw_HandleCacheLock(GDrawHandle *t, void *owner)
|
||||
{
|
||||
return gdraw_HandleCacheLockStats(t, owner, nullptr);
|
||||
return gdraw_HandleCacheLockStats(t, owner, NULL);
|
||||
}
|
||||
|
||||
static void gdraw_HandleCacheUnlock(GDrawHandle *t)
|
||||
@@ -461,11 +461,11 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte
|
||||
c->is_thrashing = false;
|
||||
c->did_defragment = false;
|
||||
for (i=0; i < GDRAW_HANDLE_STATE__count; i++) {
|
||||
c->state[i].owner = nullptr;
|
||||
c->state[i].cache = nullptr; // should never follow cache link from sentinels!
|
||||
c->state[i].owner = NULL;
|
||||
c->state[i].cache = NULL; // should never follow cache link from sentinels!
|
||||
c->state[i].next = c->state[i].prev = &c->state[i];
|
||||
#ifdef GDRAW_MANAGE_MEM
|
||||
c->state[i].raw_ptr = nullptr;
|
||||
c->state[i].raw_ptr = NULL;
|
||||
#endif
|
||||
c->state[i].fence.value = 0;
|
||||
c->state[i].bytes = 0;
|
||||
@@ -478,7 +478,7 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte
|
||||
c->handle[i].bytes = 0;
|
||||
c->handle[i].state = GDRAW_HANDLE_STATE_free;
|
||||
#ifdef GDRAW_MANAGE_MEM
|
||||
c->handle[i].raw_ptr = nullptr;
|
||||
c->handle[i].raw_ptr = NULL;
|
||||
#endif
|
||||
}
|
||||
c->state[GDRAW_HANDLE_STATE_free].next = &c->handle[0];
|
||||
@@ -486,10 +486,10 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte
|
||||
c->prev_frame_start.value = 0;
|
||||
c->prev_frame_end.value = 0;
|
||||
#ifdef GDRAW_MANAGE_MEM
|
||||
c->alloc = nullptr;
|
||||
c->alloc = NULL;
|
||||
#endif
|
||||
#ifdef GDRAW_MANAGE_MEM_TWOPOOL
|
||||
c->alloc_other = nullptr;
|
||||
c->alloc_other = NULL;
|
||||
#endif
|
||||
check_lists(c);
|
||||
}
|
||||
@@ -497,14 +497,14 @@ static void gdraw_HandleCacheInit(GDrawHandleCache *c, S32 num_handles, S32 byte
|
||||
static GDrawHandle *gdraw_HandleCacheAllocateBegin(GDrawHandleCache *c)
|
||||
{
|
||||
GDrawHandle *free_list = &c->state[GDRAW_HANDLE_STATE_free];
|
||||
GDrawHandle *t = nullptr;
|
||||
GDrawHandle *t = NULL;
|
||||
if (free_list->next != free_list) {
|
||||
t = free_list->next;
|
||||
gdraw_HandleTransitionTo(t, GDRAW_HANDLE_STATE_alloc);
|
||||
t->bytes = 0;
|
||||
t->owner = 0;
|
||||
#ifdef GDRAW_MANAGE_MEM
|
||||
t->raw_ptr = nullptr;
|
||||
t->raw_ptr = NULL;
|
||||
#endif
|
||||
#ifdef GDRAW_CORRUPTION_CHECK
|
||||
t->has_check_value = false;
|
||||
@@ -563,7 +563,7 @@ static GDrawHandle *gdraw_HandleCacheGetLRU(GDrawHandleCache *c)
|
||||
// at the front of the LRU list are the oldest ones, since in-use resources
|
||||
// will get appended on every transition from "locked" to "live".
|
||||
GDrawHandle *sentinel = &c->state[GDRAW_HANDLE_STATE_live];
|
||||
return (sentinel->next != sentinel) ? sentinel->next : nullptr;
|
||||
return (sentinel->next != sentinel) ? sentinel->next : NULL;
|
||||
}
|
||||
|
||||
static void gdraw_HandleCacheTick(GDrawHandleCache *c, GDrawFence now)
|
||||
@@ -778,7 +778,7 @@ static GDrawTexture *gdraw_BlurPass(GDrawFunctions *g, GDrawBlurInfo *c, GDrawRe
|
||||
if (!g->TextureDrawBufferBegin(draw_bounds, GDRAW_TEXTURE_FORMAT_rgba32, GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha, 0, gstats))
|
||||
return r->tex[0];
|
||||
|
||||
c->BlurPass(r, taps, data, draw_bounds, tc, static_cast<F32>(c->h) / c->frametex_height, clamp, gstats);
|
||||
c->BlurPass(r, taps, data, draw_bounds, tc, (F32) c->h / c->frametex_height, clamp, gstats);
|
||||
return g->TextureDrawBufferEnd(gstats);
|
||||
}
|
||||
|
||||
@@ -830,7 +830,7 @@ static GDrawTexture *gdraw_BlurPassDownsample(GDrawFunctions *g, GDrawBlurInfo *
|
||||
assert(clamp[0] <= clamp[2]);
|
||||
assert(clamp[1] <= clamp[3]);
|
||||
|
||||
c->BlurPass(r, taps, data, &z, tc, static_cast<F32>(c->h) / c->frametex_height, clamp, gstats);
|
||||
c->BlurPass(r, taps, data, &z, tc, (F32) c->h / c->frametex_height, clamp, gstats);
|
||||
return g->TextureDrawBufferEnd(gstats);
|
||||
}
|
||||
|
||||
@@ -842,7 +842,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR
|
||||
GDrawTexture *t;
|
||||
F32 data[MAX_TAPS][4];
|
||||
S32 off_axis = 1-axis;
|
||||
S32 w = static_cast<S32>(ceil((blur_width - 1) / 2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5
|
||||
S32 w = ((S32) ceil((blur_width-1)/2))*2+1; // 1.2 => 3, 2.8 => 3, 3.2 => 5
|
||||
F32 edge_weight = 1 - (w - blur_width)/2; // 3 => 0 => 1; 1.2 => 1.8 => 0.9 => 0.1
|
||||
F32 inverse_weight = 1.0f / blur_width;
|
||||
|
||||
@@ -949,7 +949,7 @@ static void gdraw_BlurAxis(S32 axis, GDrawFunctions *g, GDrawBlurInfo *c, GDrawR
|
||||
// max coverage is 25 samples, or a filter width of 13. with 7 taps, we sample
|
||||
// 13 samples in one pass, max coverage is 13*13 samples or (13*13-1)/2 width,
|
||||
// which is ((2T-1)*(2T-1)-1)/2 or (4T^2 - 4T + 1 -1)/2 or 2T^2 - 2T or 2T*(T-1)
|
||||
S32 w_mip = static_cast<S32>(ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS)));
|
||||
S32 w_mip = (S32) ceil(linear_remap(w, MAX_TAPS+1, MAX_TAPS*MAX_TAPS, 2, MAX_TAPS));
|
||||
S32 downsample = w_mip;
|
||||
F32 sample_spacing = texel;
|
||||
if (downsample < 2) downsample = 2;
|
||||
@@ -1095,7 +1095,7 @@ static void make_pool_aligned(void **start, S32 *num_bytes, U32 alignment)
|
||||
if (addr_aligned != addr_orig) {
|
||||
S32 diff = (S32) (addr_aligned - addr_orig);
|
||||
if (*num_bytes < diff) {
|
||||
*start = nullptr;
|
||||
*start = NULL;
|
||||
*num_bytes = 0;
|
||||
return;
|
||||
} else {
|
||||
@@ -1132,7 +1132,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align)
|
||||
UINTa remaining = arena->end - arena->current;
|
||||
UINTa total_size = (ptr - arena->current) + size;
|
||||
if (remaining < total_size) // doesn't fit
|
||||
return nullptr;
|
||||
return NULL;
|
||||
|
||||
arena->current = ptr + size;
|
||||
return ptr;
|
||||
@@ -1157,7 +1157,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align)
|
||||
// (i.e. block->next->prev == block->prev->next == block)
|
||||
// - All allocated blocks are also kept in a hash table, indexed by their
|
||||
// pointer (to allow free to locate the corresponding block_info quickly).
|
||||
// There's a single-linked, nullptr-terminated list of elements in each hash
|
||||
// There's a single-linked, NULL-terminated list of elements in each hash
|
||||
// bucket.
|
||||
// - The physical block list is ordered. It always contains all currently
|
||||
// active blocks and spans the whole managed memory range. There are no
|
||||
@@ -1166,7 +1166,7 @@ static void *gdraw_arena_alloc(GDrawArena *arena, U32 size, U32 align)
|
||||
// they are coalesced immediately.
|
||||
// - The maximum number of blocks that could ever be necessary is allocated
|
||||
// on initialization. All block_infos not currently in use are kept in a
|
||||
// single-linked, nullptr-terminated list of unused blocks. Every block is either
|
||||
// single-linked, NULL-terminated list of unused blocks. Every block is either
|
||||
// in the physical block list or the unused list, and the total number of
|
||||
// blocks is constant.
|
||||
// These invariants always hold before and after an allocation/free.
|
||||
@@ -1384,7 +1384,7 @@ static void gfxalloc_check2(gfx_allocator *alloc)
|
||||
|
||||
static gfx_block_info *gfxalloc_pop_unused(gfx_allocator *alloc)
|
||||
{
|
||||
GFXALLOC_ASSERT(alloc->unused_list != nullptr);
|
||||
GFXALLOC_ASSERT(alloc->unused_list != NULL);
|
||||
GFXALLOC_ASSERT(alloc->unused_list->is_unused);
|
||||
GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_unused);)
|
||||
|
||||
@@ -1457,7 +1457,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma
|
||||
U32 i, max_blocks, size;
|
||||
|
||||
if (!align || (align & (align - 1)) != 0) // align must be >0 and a power of 2
|
||||
return nullptr;
|
||||
return NULL;
|
||||
|
||||
// for <= max_allocs live allocs, there's <= 2*max_allocs+1 blocks. worst case:
|
||||
// [free][used][free] .... [free][used][free]
|
||||
@@ -1465,7 +1465,7 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma
|
||||
size = sizeof(gfx_allocator) + max_blocks * sizeof(gfx_block_info);
|
||||
a = (gfx_allocator *) IggyGDrawMalloc(size);
|
||||
if (!a)
|
||||
return nullptr;
|
||||
return NULL;
|
||||
|
||||
memset(a, 0, size);
|
||||
|
||||
@@ -1506,16 +1506,16 @@ static gfx_allocator *gfxalloc_create(void *mem, U32 mem_size, U32 align, U32 ma
|
||||
a->blocks[i].is_unused = 1;
|
||||
|
||||
gfxalloc_check(a);
|
||||
debug_complete_check(a, nullptr, 0,0);
|
||||
debug_complete_check(a, NULL, 0,0);
|
||||
return a;
|
||||
}
|
||||
|
||||
static void *gfxalloc_alloc(gfx_allocator *alloc, U32 size_in_bytes)
|
||||
{
|
||||
gfx_block_info *cur, *best = nullptr;
|
||||
gfx_block_info *cur, *best = NULL;
|
||||
U32 i, best_wasted = ~0u;
|
||||
U32 size = size_in_bytes;
|
||||
debug_complete_check(alloc, nullptr, 0,0);
|
||||
debug_complete_check(alloc, NULL, 0,0);
|
||||
gfxalloc_check(alloc);
|
||||
GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_blocks == alloc->num_alloc + alloc->num_free + alloc->num_unused);)
|
||||
GFXALLOC_IF_CHECK(GFXALLOC_ASSERT(alloc->num_free <= alloc->num_blocks+1);)
|
||||
@@ -1565,7 +1565,7 @@ gfxalloc_check(alloc);
|
||||
debug_check_overlap(alloc->cache, best->ptr, best->size);
|
||||
return best->ptr;
|
||||
} else
|
||||
return nullptr; // not enough space!
|
||||
return NULL; // not enough space!
|
||||
}
|
||||
|
||||
static void gfxalloc_free(gfx_allocator *alloc, void *ptr)
|
||||
@@ -1735,7 +1735,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta
|
||||
// (unused for allocated blocks, we'll use it to store a back-pointer to the corresponding handle)
|
||||
for (b = alloc->blocks[0].next_phys; b != alloc->blocks; b=b->next_phys)
|
||||
if (!b->is_free)
|
||||
b->prev = nullptr;
|
||||
b->prev = NULL;
|
||||
|
||||
// go through all handles and store a pointer to the handle in the corresponding memory block
|
||||
for (i=0; i < c->max_handles; i++)
|
||||
@@ -1748,7 +1748,7 @@ static void gdraw_DefragmentMain(GDrawHandleCache *c, U32 flags, GDrawStats *sta
|
||||
break;
|
||||
}
|
||||
|
||||
GFXALLOC_ASSERT(b != nullptr); // didn't find this block anywhere!
|
||||
GFXALLOC_ASSERT(b != NULL); // didn't find this block anywhere!
|
||||
}
|
||||
|
||||
// clear alloc hash table (we rebuild it during defrag)
|
||||
@@ -1910,7 +1910,7 @@ static rrbool gdraw_CanDefragment(GDrawHandleCache *c)
|
||||
static rrbool gdraw_MigrateResource(GDrawHandle *t, GDrawStats *stats)
|
||||
{
|
||||
GDrawHandleCache *c = t->cache;
|
||||
void *ptr = nullptr;
|
||||
void *ptr = NULL;
|
||||
|
||||
assert(t->state == GDRAW_HANDLE_STATE_live || t->state == GDRAW_HANDLE_STATE_locked || t->state == GDRAW_HANDLE_STATE_pinned);
|
||||
// anything we migrate should be in the "other" (old) pool
|
||||
@@ -2300,7 +2300,7 @@ static void gdraw_bufring_init(gdraw_bufring * RADRESTRICT ring, void *ptr, U32
|
||||
|
||||
static void gdraw_bufring_shutdown(gdraw_bufring * RADRESTRICT ring)
|
||||
{
|
||||
ring->cur = nullptr;
|
||||
ring->cur = NULL;
|
||||
ring->seg_size = 0;
|
||||
}
|
||||
|
||||
@@ -2310,7 +2310,7 @@ static void *gdraw_bufring_alloc(gdraw_bufring * RADRESTRICT ring, U32 size, U32
|
||||
gdraw_bufring_seg *seg;
|
||||
|
||||
if (size > ring->seg_size)
|
||||
return nullptr; // nope, won't fit
|
||||
return NULL; // nope, won't fit
|
||||
|
||||
assert(align <= ring->align);
|
||||
|
||||
@@ -2415,7 +2415,7 @@ static rrbool gdraw_res_free_lru(GDrawHandleCache *c, GDrawStats *stats)
|
||||
// was it referenced since end of previous frame (=in this frame)?
|
||||
// if some, we're thrashing; report it to the user, but only once per frame.
|
||||
if (c->prev_frame_end.value < r->fence.value && !c->is_thrashing) {
|
||||
IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory");
|
||||
IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Thrashing vertex memory" : "GDraw Thrashing texture memory");
|
||||
c->is_thrashing = true;
|
||||
}
|
||||
|
||||
@@ -2435,8 +2435,8 @@ static GDrawHandle *gdraw_res_alloc_outofmem(GDrawHandleCache *c, GDrawHandle *t
|
||||
{
|
||||
if (t)
|
||||
gdraw_HandleCacheAllocateFail(t);
|
||||
IggyGDrawSendWarning(nullptr, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type);
|
||||
return nullptr;
|
||||
IggyGDrawSendWarning(NULL, c->is_vertex ? "GDraw Out of static vertex buffer %s" : "GDraw Out of texture %s", failed_type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef GDRAW_MANAGE_MEM
|
||||
@@ -2445,7 +2445,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt
|
||||
{
|
||||
GDrawHandle *t;
|
||||
if (size > c->total_bytes)
|
||||
gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)");
|
||||
gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)");
|
||||
else {
|
||||
// given how much data we're going to allocate, throw out
|
||||
// data until there's "room" (this basically lets us use
|
||||
@@ -2453,7 +2453,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt
|
||||
// packing it and being exact)
|
||||
while (c->bytes_free < size) {
|
||||
if (!gdraw_res_free_lru(c, stats)) {
|
||||
gdraw_res_alloc_outofmem(c, nullptr, "memory");
|
||||
gdraw_res_alloc_outofmem(c, NULL, "memory");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2468,8 +2468,8 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt
|
||||
// we'd trade off cost of regenerating)
|
||||
if (gdraw_res_free_lru(c, stats)) {
|
||||
t = gdraw_HandleCacheAllocateBegin(c);
|
||||
if (t == nullptr) {
|
||||
gdraw_res_alloc_outofmem(c, nullptr, "handles");
|
||||
if (t == NULL) {
|
||||
gdraw_res_alloc_outofmem(c, NULL, "handles");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2513,7 +2513,7 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats)
|
||||
{
|
||||
GDRAW_FENCE_FLUSH(); // dead list is sorted by fence index - make sure all fence values are current.
|
||||
|
||||
r->owner = nullptr;
|
||||
r->owner = NULL;
|
||||
gdraw_HandleCacheInsertDead(r);
|
||||
gdraw_res_reap(r->cache, stats);
|
||||
}
|
||||
@@ -2521,11 +2521,11 @@ static void gdraw_res_kill(GDrawHandle *r, GDrawStats *stats)
|
||||
static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawStats *stats)
|
||||
{
|
||||
GDrawHandle *t;
|
||||
void *ptr = nullptr;
|
||||
void *ptr = NULL;
|
||||
|
||||
gdraw_res_reap(c, stats); // NB this also does GDRAW_FENCE_FLUSH();
|
||||
if (size > c->total_bytes)
|
||||
return gdraw_res_alloc_outofmem(c, nullptr, "memory (single resource larger than entire pool)");
|
||||
return gdraw_res_alloc_outofmem(c, NULL, "memory (single resource larger than entire pool)");
|
||||
|
||||
// now try to allocate a handle
|
||||
t = gdraw_HandleCacheAllocateBegin(c);
|
||||
@@ -2537,7 +2537,7 @@ static GDrawHandle *gdraw_res_alloc_begin(GDrawHandleCache *c, S32 size, GDrawSt
|
||||
gdraw_res_free_lru(c, stats);
|
||||
t = gdraw_HandleCacheAllocateBegin(c);
|
||||
if (!t)
|
||||
return gdraw_res_alloc_outofmem(c, nullptr, "handles");
|
||||
return gdraw_res_alloc_outofmem(c, NULL, "handles");
|
||||
}
|
||||
|
||||
// try to allocate first
|
||||
|
||||
@@ -356,13 +356,13 @@ IDOC typedef struct GDrawPrimitive
|
||||
IDOC typedef void RADLINK gdraw_draw_indexed_triangles(GDrawRenderState *r, GDrawPrimitive *prim, GDrawVertexBuffer *buf, GDrawStats *stats);
|
||||
/* Draws a collection of indexed triangles, ignoring special filters or blend modes.
|
||||
|
||||
If buf is nullptr, then the pointers in 'prim' are machine pointers, and
|
||||
If buf is NULL, then the pointers in 'prim' are machine pointers, and
|
||||
you need to make a copy of the data (note currently all triangles
|
||||
implementing strokes (wide lines) go this path).
|
||||
|
||||
If buf is non-nullptr, then use the appropriate vertex buffer, and the
|
||||
If buf is non-NULL, then use the appropriate vertex buffer, and the
|
||||
pointers in prim are actually offsets from the beginning of the
|
||||
vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) nullptr;
|
||||
vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) NULL;
|
||||
(note there are separate spaces for vertices and indices; e.g. the
|
||||
first mesh in a given vertex buffer will normally have a 0 offset
|
||||
for the vertices and a 0 offset for the indices)
|
||||
@@ -455,7 +455,7 @@ IDOC typedef GDrawTexture * RADLINK gdraw_make_texture_end(GDraw_MakeTexture_Pro
|
||||
/* Ends specification of a new texture.
|
||||
|
||||
$:info The same handle initially passed to $gdraw_make_texture_begin
|
||||
$:return Handle for the newly created texture, or nullptr if an error occured
|
||||
$:return Handle for the newly created texture, or NULL if an error occured
|
||||
*/
|
||||
|
||||
IDOC typedef rrbool RADLINK gdraw_update_texture_begin(GDrawTexture *tex, void *unique_id, GDrawStats *stats);
|
||||
|
||||
@@ -25,8 +25,8 @@ IDOC RADEXPFUNC HIGGYEXP RADEXPLINK IggyExpCreate(char *ip_address, S32 port, vo
|
||||
$:storage A small block of storage that needed to store the $HIGGYEXP, must be at least $IGGYEXP_MIN_STORAGE
|
||||
$:storage_size_in_bytes The size of the block pointer to by <tt>storage</tt>
|
||||
|
||||
Returns a nullptr HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer
|
||||
can be contacted at the specified address/port. Otherwise returns a non-nullptr $HIGGYEXP
|
||||
Returns a NULL HIGGYEXP if the IP address/hostname can't be resolved, or no Iggy Explorer
|
||||
can be contacted at the specified address/port. Otherwise returns a non-NULL $HIGGYEXP
|
||||
which you can pass to $IggyUseExplorer. */
|
||||
|
||||
IDOC RADEXPFUNC void RADEXPLINK IggyExpDestroy(HIGGYEXP p);
|
||||
|
||||
Reference in New Issue
Block a user