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:
@@ -1364,7 +1364,7 @@ static DWORD pshader_exceptional_blend_12[276] = {
|
||||
};
|
||||
|
||||
static ProgramWithCachedVariableLocations pshader_exceptional_blend_arr[13] = {
|
||||
{ nullptr, 0, },
|
||||
{ NULL, 0, },
|
||||
{ pshader_exceptional_blend_1, 1340, },
|
||||
{ pshader_exceptional_blend_2, 1444, },
|
||||
{ pshader_exceptional_blend_3, 1424, },
|
||||
@@ -2672,10 +2672,10 @@ static ProgramWithCachedVariableLocations pshader_filter_arr[32] = {
|
||||
{ pshader_filter_9, 708, },
|
||||
{ pshader_filter_10, 1644, },
|
||||
{ pshader_filter_11, 1372, },
|
||||
{ nullptr, 0, },
|
||||
{ nullptr, 0, },
|
||||
{ nullptr, 0, },
|
||||
{ nullptr, 0, },
|
||||
{ NULL, 0, },
|
||||
{ NULL, 0, },
|
||||
{ NULL, 0, },
|
||||
{ NULL, 0, },
|
||||
{ pshader_filter_16, 1740, },
|
||||
{ pshader_filter_17, 1732, },
|
||||
{ pshader_filter_18, 1820, },
|
||||
@@ -2688,10 +2688,10 @@ static ProgramWithCachedVariableLocations pshader_filter_arr[32] = {
|
||||
{ pshader_filter_25, 1468, },
|
||||
{ pshader_filter_26, 1820, },
|
||||
{ pshader_filter_27, 1548, },
|
||||
{ nullptr, 0, },
|
||||
{ nullptr, 0, },
|
||||
{ nullptr, 0, },
|
||||
{ nullptr, 0, },
|
||||
{ NULL, 0, },
|
||||
{ NULL, 0, },
|
||||
{ NULL, 0, },
|
||||
{ NULL, 0, },
|
||||
};
|
||||
|
||||
static DWORD pshader_blur_2[320] = {
|
||||
@@ -3193,8 +3193,8 @@ static DWORD pshader_blur_9[621] = {
|
||||
};
|
||||
|
||||
static ProgramWithCachedVariableLocations pshader_blur_arr[10] = {
|
||||
{ nullptr, 0, },
|
||||
{ nullptr, 0, },
|
||||
{ NULL, 0, },
|
||||
{ NULL, 0, },
|
||||
{ pshader_blur_2, 1280, },
|
||||
{ pshader_blur_3, 1452, },
|
||||
{ pshader_blur_4, 1624, },
|
||||
|
||||
@@ -64,7 +64,7 @@ static void *map_buffer(ID3D1XContext *ctx, ID3D11Buffer *buf, bool discard)
|
||||
HRESULT hr = ctx->Map(buf, 0, discard ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE, 0, &msr);
|
||||
if (FAILED(hr)) {
|
||||
report_d3d_error(hr, "Map", "of buffer");
|
||||
return nullptr;
|
||||
return NULL;
|
||||
} else
|
||||
return msr.pData;
|
||||
}
|
||||
@@ -76,12 +76,12 @@ static void unmap_buffer(ID3D1XContext *ctx, ID3D11Buffer *buf)
|
||||
|
||||
static RADINLINE void set_pixel_shader(ID3D11DeviceContext *ctx, ID3D11PixelShader *shader)
|
||||
{
|
||||
ctx->PSSetShader(shader, nullptr, 0);
|
||||
ctx->PSSetShader(shader, NULL, 0);
|
||||
}
|
||||
|
||||
static RADINLINE void set_vertex_shader(ID3D11DeviceContext *ctx, ID3D11VertexShader *shader)
|
||||
{
|
||||
ctx->VSSetShader(shader, nullptr, 0);
|
||||
ctx->VSSetShader(shader, NULL, 0);
|
||||
}
|
||||
|
||||
static ID3D11BlendState *create_blend_state(ID3D11Device *dev, BOOL blend, D3D11_BLEND src, D3D11_BLEND dst)
|
||||
@@ -100,7 +100,7 @@ static ID3D11BlendState *create_blend_state(ID3D11Device *dev, BOOL blend, D3D11
|
||||
HRESULT hr = dev->CreateBlendState(&desc, &res);
|
||||
if (FAILED(hr)) {
|
||||
report_d3d_error(hr, "CreateBlendState", "");
|
||||
res = nullptr;
|
||||
res = NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -113,10 +113,10 @@ static void create_pixel_shader(ProgramWithCachedVariableLocations *p, ProgramWi
|
||||
{
|
||||
*p = *src;
|
||||
if(p->bytecode) {
|
||||
HRESULT hr = gdraw->d3d_device->CreatePixelShader(p->bytecode, p->size, nullptr, &p->pshader);
|
||||
HRESULT hr = gdraw->d3d_device->CreatePixelShader(p->bytecode, p->size, NULL, &p->pshader);
|
||||
if (FAILED(hr)) {
|
||||
report_d3d_error(hr, "CreatePixelShader", "");
|
||||
p->pshader = nullptr;
|
||||
p->pshader = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -126,10 +126,10 @@ static void create_vertex_shader(ProgramWithCachedVariableLocations *p, ProgramW
|
||||
{
|
||||
*p = *src;
|
||||
if(p->bytecode) {
|
||||
HRESULT hr = gdraw->d3d_device->CreateVertexShader(p->bytecode, p->size, nullptr, &p->vshader);
|
||||
HRESULT hr = gdraw->d3d_device->CreateVertexShader(p->bytecode, p->size, NULL, &p->vshader);
|
||||
if (FAILED(hr)) {
|
||||
report_d3d_error(hr, "CreateVertexShader", "");
|
||||
p->vshader = nullptr;
|
||||
p->vshader = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ IDOC extern GDrawFunctions * gdraw_D3D11_CreateContext(ID3D11Device *dev, ID3D11
|
||||
There can only be one D3D 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_D3D11_DestroyContext(void);
|
||||
/* Destroys the current GDraw context, if any. */
|
||||
@@ -69,7 +69,7 @@ IDOC extern void gdraw_D3D11_SetTileOrigin(ID3D11RenderTargetView *main_rt, ID3D
|
||||
If your rendertarget uses multisampling, you also need to specify a shader
|
||||
resource view for a non-MSAA rendertarget texture (identically sized to main_rt)
|
||||
in non_msaa_rt. This is only used if the Flash content includes non-standard
|
||||
blend modes which have to use a special blend shader, so you can leave it nullptr
|
||||
blend modes which have to use a special blend shader, so you can leave it NULL
|
||||
if you forbid such content.
|
||||
|
||||
You need to call this before Iggy calls any rendering functions. */
|
||||
|
||||
@@ -196,16 +196,16 @@ static void safe_release(T *&p)
|
||||
{
|
||||
if (p) {
|
||||
p->Release();
|
||||
p = nullptr;
|
||||
p = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void report_d3d_error(HRESULT hr, char *call, char *context)
|
||||
{
|
||||
if (hr == E_OUTOFMEMORY)
|
||||
IggyGDrawSendWarning(nullptr, "GDraw D3D out of memory in %s%s", call, context);
|
||||
IggyGDrawSendWarning(NULL, "GDraw D3D out of memory in %s%s", call, context);
|
||||
else
|
||||
IggyGDrawSendWarning(nullptr, "GDraw D3D error in %s%s: 0x%08x", call, context, hr);
|
||||
IggyGDrawSendWarning(NULL, "GDraw D3D error in %s%s: 0x%08x", call, context, hr);
|
||||
}
|
||||
|
||||
static void unbind_resources(void)
|
||||
@@ -215,12 +215,12 @@ static void unbind_resources(void)
|
||||
// unset active textures and vertex/index buffers,
|
||||
// to make sure there are no dangling refs
|
||||
static ID3D1X(ShaderResourceView) *no_views[3] = { 0 };
|
||||
ID3D1X(Buffer) *no_vb = nullptr;
|
||||
ID3D1X(Buffer) *no_vb = NULL;
|
||||
UINT no_offs = 0;
|
||||
|
||||
d3d->PSSetShaderResources(0, 3, no_views);
|
||||
d3d->IASetVertexBuffers(0, 1, &no_vb, &no_offs, &no_offs);
|
||||
d3d->IASetIndexBuffer(nullptr, DXGI_FORMAT_UNKNOWN, 0);
|
||||
d3d->IASetIndexBuffer(NULL, DXGI_FORMAT_UNKNOWN, 0);
|
||||
}
|
||||
|
||||
static void api_free_resource(GDrawHandle *r)
|
||||
@@ -251,11 +251,11 @@ static void RADLINK gdraw_UnlockHandles(GDrawStats * /*stats*/)
|
||||
|
||||
static void *start_write_dyn(DynBuffer *buf, U32 size)
|
||||
{
|
||||
U8 *ptr = nullptr;
|
||||
U8 *ptr = NULL;
|
||||
|
||||
if (size > buf->size) {
|
||||
IggyGDrawSendWarning(nullptr, "GDraw dynamic vertex buffer usage of %d bytes in one call larger than buffer size %d", size, buf->size);
|
||||
return nullptr;
|
||||
IggyGDrawSendWarning(NULL, "GDraw dynamic vertex buffer usage of %d bytes in one call larger than buffer size %d", size, buf->size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// update statistics
|
||||
@@ -373,19 +373,19 @@ extern GDrawTexture *gdraw_D3D1X_(WrappedTextureCreate)(ID3D1X(ShaderResourceVie
|
||||
{
|
||||
GDrawStats stats={0};
|
||||
GDrawHandle *p = gdraw_res_alloc_begin(gdraw->texturecache, 0, &stats); // it may need to free one item to give us a handle
|
||||
p->handle.tex.d3d = nullptr;
|
||||
p->handle.tex.d3d = NULL;
|
||||
p->handle.tex.d3d_view = tex_view;
|
||||
p->handle.tex.d3d_rtview = nullptr;
|
||||
p->handle.tex.d3d_rtview = NULL;
|
||||
p->handle.tex.w = 1;
|
||||
p->handle.tex.h = 1;
|
||||
gdraw_HandleCacheAllocateEnd(p, 0, nullptr, GDRAW_HANDLE_STATE_user_owned);
|
||||
gdraw_HandleCacheAllocateEnd(p, 0, NULL, GDRAW_HANDLE_STATE_user_owned);
|
||||
return (GDrawTexture *) p;
|
||||
}
|
||||
|
||||
extern void gdraw_D3D1X_(WrappedTextureChange)(GDrawTexture *tex, ID3D1X(ShaderResourceView) *tex_view)
|
||||
{
|
||||
GDrawHandle *p = (GDrawHandle *) tex;
|
||||
p->handle.tex.d3d = nullptr;
|
||||
p->handle.tex.d3d = NULL;
|
||||
p->handle.tex.d3d_view = tex_view;
|
||||
}
|
||||
|
||||
@@ -407,12 +407,12 @@ 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 format, U32 flags, GDraw_MakeTexture_ProcessingInfo *p, GDrawStats *stats)
|
||||
{
|
||||
GDrawHandle *t = nullptr;
|
||||
GDrawHandle *t = NULL;
|
||||
DXGI_FORMAT dxgi_fmt;
|
||||
S32 bpp, size = 0, nmips = 0;
|
||||
|
||||
if (width >= 16384 || height >= 16384) {
|
||||
IggyGDrawSendWarning(nullptr, "GDraw texture size too large (%d x %d), dimension limit is 16384", width, height);
|
||||
IggyGDrawSendWarning(NULL, "GDraw texture size too large (%d x %d), dimension limit is 16384", width, height);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height,
|
||||
// try to allocate memory for the client to write to
|
||||
p->texture_data = (U8 *) IggyGDrawMalloc(size);
|
||||
if (!p->texture_data) {
|
||||
IggyGDrawSendWarning(nullptr, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height);
|
||||
IggyGDrawSendWarning(NULL, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -446,9 +446,9 @@ static rrbool RADLINK gdraw_MakeTextureBegin(void *owner, S32 width, S32 height,
|
||||
|
||||
t->handle.tex.w = width;
|
||||
t->handle.tex.h = height;
|
||||
t->handle.tex.d3d = nullptr;
|
||||
t->handle.tex.d3d_view = nullptr;
|
||||
t->handle.tex.d3d_rtview = nullptr;
|
||||
t->handle.tex.d3d = NULL;
|
||||
t->handle.tex.d3d_view = NULL;
|
||||
t->handle.tex.d3d_rtview = NULL;
|
||||
|
||||
p->texture_type = GDRAW_TEXTURE_TYPE_rgba;
|
||||
p->p0 = t;
|
||||
@@ -512,7 +512,7 @@ static GDrawTexture * RADLINK gdraw_MakeTextureEnd(GDraw_MakeTexture_ProcessingI
|
||||
|
||||
// and create a corresponding shader resource view
|
||||
failed_call = "CreateShaderResourceView";
|
||||
hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_view);
|
||||
hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_view);
|
||||
|
||||
done:
|
||||
if (!FAILED(hr)) {
|
||||
@@ -525,7 +525,7 @@ done:
|
||||
safe_release(t->handle.tex.d3d_view);
|
||||
|
||||
gdraw_HandleCacheAllocateFail(t);
|
||||
t = nullptr;
|
||||
t = NULL;
|
||||
report_d3d_error(hr, failed_call, " while creating texture");
|
||||
}
|
||||
|
||||
@@ -554,8 +554,8 @@ static void RADLINK gdraw_UpdateTextureEnd(GDrawTexture *t, void * /*unique_id*/
|
||||
static void RADLINK gdraw_FreeTexture(GDrawTexture *tt, void *unique_id, GDrawStats *stats)
|
||||
{
|
||||
GDrawHandle *t = (GDrawHandle *) tt;
|
||||
assert(t != nullptr); // @GDRAW_ASSERT
|
||||
if (t->owner == unique_id || unique_id == nullptr) {
|
||||
assert(t != NULL); // @GDRAW_ASSERT
|
||||
if (t->owner == unique_id || unique_id == NULL) {
|
||||
if (t->cache == &gdraw->rendertargets) {
|
||||
gdraw_HandleCacheUnlock(t);
|
||||
// cache it by simply not freeing it
|
||||
@@ -595,7 +595,7 @@ static void RADLINK gdraw_SetAntialiasTexture(S32 width, U8 *rgba)
|
||||
return;
|
||||
}
|
||||
|
||||
hr = gdraw->d3d_device->CreateShaderResourceView(gdraw->aa_tex, nullptr, &gdraw->aa_tex_view);
|
||||
hr = gdraw->d3d_device->CreateShaderResourceView(gdraw->aa_tex, NULL, &gdraw->aa_tex_view);
|
||||
if (FAILED(hr)) {
|
||||
report_d3d_error(hr, "CreateShaderResourceView", " while creating texture");
|
||||
safe_release(gdraw->aa_tex);
|
||||
@@ -616,8 +616,8 @@ static rrbool RADLINK gdraw_MakeVertexBufferBegin(void *unique_id, gdraw_vformat
|
||||
if (p->vertex_data && p->index_data) {
|
||||
GDrawHandle *vb = gdraw_res_alloc_begin(gdraw->vbufcache, vbuf_size + ibuf_size, stats);
|
||||
if (vb) {
|
||||
vb->handle.vbuf.verts = nullptr;
|
||||
vb->handle.vbuf.inds = nullptr;
|
||||
vb->handle.vbuf.verts = NULL;
|
||||
vb->handle.vbuf.inds = NULL;
|
||||
|
||||
p->vertex_data_length = vbuf_size;
|
||||
p->index_data_length = ibuf_size;
|
||||
@@ -661,7 +661,7 @@ static GDrawVertexBuffer * RADLINK gdraw_MakeVertexBufferEnd(GDraw_MakeVertexBuf
|
||||
safe_release(vb->handle.vbuf.inds);
|
||||
|
||||
gdraw_HandleCacheAllocateFail(vb);
|
||||
vb = nullptr;
|
||||
vb = NULL;
|
||||
|
||||
report_d3d_error(hr, "CreateBuffer", " creating vertex buffer");
|
||||
} else {
|
||||
@@ -682,7 +682,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_free(h, stats);
|
||||
}
|
||||
@@ -712,31 +712,31 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats)
|
||||
// ran out of RTs, allocate a new one
|
||||
S32 size = gdraw->frametex_width * gdraw->frametex_height * 4;
|
||||
if (gdraw->rendertargets.bytes_free < size) {
|
||||
IggyGDrawSendWarning(nullptr, "GDraw rendertarget allocation failed: hit size limit of %d bytes", gdraw->rendertargets.total_bytes);
|
||||
return nullptr;
|
||||
IggyGDrawSendWarning(NULL, "GDraw rendertarget allocation failed: hit size limit of %d bytes", gdraw->rendertargets.total_bytes);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
D3D1X_(TEXTURE2D_DESC) desc = { gdraw->frametex_width, gdraw->frametex_height, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 },
|
||||
D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_SHADER_RESOURCE) | D3D1X_(BIND_RENDER_TARGET), 0, 0 };
|
||||
|
||||
t->handle.tex.d3d = nullptr;
|
||||
t->handle.tex.d3d_view = nullptr;
|
||||
t->handle.tex.d3d_rtview = nullptr;
|
||||
t->handle.tex.d3d = NULL;
|
||||
t->handle.tex.d3d_view = NULL;
|
||||
t->handle.tex.d3d_rtview = NULL;
|
||||
|
||||
HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, nullptr, &t->handle.tex.d3d);
|
||||
HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, NULL, &t->handle.tex.d3d);
|
||||
failed_call = "CreateTexture2D";
|
||||
if (!FAILED(hr)) {
|
||||
hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_view);
|
||||
hr = gdraw->d3d_device->CreateShaderResourceView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_view);
|
||||
failed_call = "CreateTexture2D";
|
||||
}
|
||||
if (!FAILED(hr)) {
|
||||
hr = gdraw->d3d_device->CreateRenderTargetView(t->handle.tex.d3d, nullptr, &t->handle.tex.d3d_rtview);
|
||||
hr = gdraw->d3d_device->CreateRenderTargetView(t->handle.tex.d3d, NULL, &t->handle.tex.d3d_rtview);
|
||||
failed_call = "CreateRenderTargetView";
|
||||
}
|
||||
|
||||
@@ -748,7 +748,7 @@ static GDrawHandle *get_color_rendertarget(GDrawStats *stats)
|
||||
|
||||
report_d3d_error(hr, failed_call, " creating rendertarget");
|
||||
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gdraw_HandleCacheAllocateEnd(t, size, (void *) 1, GDRAW_HANDLE_STATE_locked);
|
||||
@@ -768,10 +768,10 @@ static ID3D1X(DepthStencilView) *get_rendertarget_depthbuffer(GDrawStats *stats)
|
||||
D3D1X_(TEXTURE2D_DESC) desc = { gdraw->frametex_width, gdraw->frametex_height, 1, 1, DXGI_FORMAT_D24_UNORM_S8_UINT, { 1, 0 },
|
||||
D3D1X_(USAGE_DEFAULT), D3D1X_(BIND_DEPTH_STENCIL), 0, 0 };
|
||||
|
||||
HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, nullptr, &gdraw->rt_depth_buffer);
|
||||
HRESULT hr = gdraw->d3d_device->CreateTexture2D(&desc, NULL, &gdraw->rt_depth_buffer);
|
||||
failed_call = "CreateTexture2D";
|
||||
if (!FAILED(hr)) {
|
||||
hr = gdraw->d3d_device->CreateDepthStencilView(gdraw->rt_depth_buffer, nullptr, &gdraw->depth_buffer[1]);
|
||||
hr = gdraw->d3d_device->CreateDepthStencilView(gdraw->rt_depth_buffer, NULL, &gdraw->depth_buffer[1]);
|
||||
failed_call = "CreateDepthStencilView while creating rendertarget";
|
||||
}
|
||||
|
||||
@@ -1110,7 +1110,7 @@ static void set_render_target(GDrawStats *stats)
|
||||
gdraw->d3d_context->OMSetRenderTargets(1, &target, gdraw->depth_buffer[0]);
|
||||
gdraw->d3d_context->RSSetState(gdraw->raster_state[gdraw->main_msaa]);
|
||||
} else {
|
||||
ID3D1X(DepthStencilView) *depth = nullptr;
|
||||
ID3D1X(DepthStencilView) *depth = NULL;
|
||||
if (gdraw->cur->flags & (GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_id | GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_stencil))
|
||||
depth = get_rendertarget_depthbuffer(stats);
|
||||
|
||||
@@ -1125,15 +1125,15 @@ static void set_render_target(GDrawStats *stats)
|
||||
static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_texture_format /*format*/, U32 flags, void *owner, GDrawStats *stats)
|
||||
{
|
||||
GDrawFramebufferState *n = gdraw->cur+1;
|
||||
GDrawHandle *t = nullptr;
|
||||
GDrawHandle *t = NULL;
|
||||
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]) {
|
||||
assert(0);
|
||||
IggyGDrawSendWarning(nullptr, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH");
|
||||
IggyGDrawSendWarning(NULL, "GDraw rendertarget nesting exceeds MAX_RENDER_STACK_DEPTH");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1147,10 +1147,10 @@ static rrbool RADLINK gdraw_TextureDrawBufferBegin(gswf_recti *region, gdraw_tex
|
||||
|
||||
n->flags = flags;
|
||||
n->color_buffer = t;
|
||||
assert(n->color_buffer != nullptr); // @GDRAW_ASSERT
|
||||
assert(n->color_buffer != NULL); // @GDRAW_ASSERT
|
||||
|
||||
++gdraw->cur;
|
||||
gdraw->cur->cached = owner != nullptr;
|
||||
gdraw->cur->cached = owner != NULL;
|
||||
if (owner) {
|
||||
gdraw->cur->base_x = region->x0;
|
||||
gdraw->cur->base_y = region->y0;
|
||||
@@ -1229,9 +1229,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
|
||||
|
||||
// switch back to old render target
|
||||
set_render_target(stats);
|
||||
@@ -1288,8 +1288,8 @@ static void set_texture(S32 texunit, GDrawTexture *tex, rrbool nearest, S32 wrap
|
||||
{
|
||||
ID3D1XContext *d3d = gdraw->d3d_context;
|
||||
|
||||
if (tex == nullptr) {
|
||||
ID3D1X(ShaderResourceView) *notex = nullptr;
|
||||
if (tex == NULL) {
|
||||
ID3D1X(ShaderResourceView) *notex = NULL;
|
||||
d3d->PSSetShaderResources(texunit, 1, ¬ex);
|
||||
} else {
|
||||
GDrawHandle *h = (GDrawHandle *) tex;
|
||||
@@ -1300,7 +1300,7 @@ static void set_texture(S32 texunit, GDrawTexture *tex, rrbool nearest, S32 wrap
|
||||
|
||||
static void RADLINK gdraw_Set3DTransform(F32 *mat)
|
||||
{
|
||||
if (mat == nullptr)
|
||||
if (mat == NULL)
|
||||
gdraw->use_3d = 0;
|
||||
else {
|
||||
gdraw->use_3d = 1;
|
||||
@@ -1363,9 +1363,9 @@ static int set_renderstate_full(S32 vertex_format, GDrawRenderState *r, GDrawSta
|
||||
// in stencil set mode, prefer not doing any shading at all
|
||||
// but if alpha test is on, we need to make an exception
|
||||
|
||||
#ifndef GDRAW_D3D11_LEVEL9 // level9 can't do nullptr PS it seems
|
||||
#ifndef GDRAW_D3D11_LEVEL9 // level9 can't do NULL PS it seems
|
||||
if (which != GDRAW_TEXTURE_alpha_test)
|
||||
program = nullptr;
|
||||
program = NULL;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
@@ -1475,7 +1475,7 @@ static int vertsize[GDRAW_vformat__basic_count] = {
|
||||
// Draw triangles with a given renderstate
|
||||
//
|
||||
|
||||
static void tag_resources(void *r1, void *r2=nullptr, void *r3=nullptr, void *r4=nullptr)
|
||||
static void tag_resources(void *r1, void *r2=NULL, void *r3=NULL, void *r4=NULL)
|
||||
{
|
||||
U64 now = gdraw->frame_counter;
|
||||
if (r1) ((GDrawHandle *) r1)->fence.value = now;
|
||||
@@ -1687,7 +1687,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], false, GDRAW_WRAP_clamp);
|
||||
@@ -1775,7 +1775,7 @@ static void RADLINK gdraw_FilterQuad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1
|
||||
assert(0);
|
||||
}
|
||||
} else {
|
||||
GDrawHandle *blend_tex = nullptr;
|
||||
GDrawHandle *blend_tex = NULL;
|
||||
|
||||
// for crazy blend modes, we need to read back from the framebuffer
|
||||
// and do the blending in the pixel shader. we do this with copies
|
||||
@@ -1859,18 +1859,18 @@ static void destroy_shader(ProgramWithCachedVariableLocations *p)
|
||||
{
|
||||
if (p->pshader) {
|
||||
p->pshader->Release();
|
||||
p->pshader = nullptr;
|
||||
p->pshader = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static ID3D1X(Buffer) *create_dynamic_buffer(U32 size, U32 bind)
|
||||
{
|
||||
D3D1X_(BUFFER_DESC) desc = { size, D3D1X_(USAGE_DYNAMIC), bind, D3D1X_(CPU_ACCESS_WRITE), 0 };
|
||||
ID3D1X(Buffer) *buf = nullptr;
|
||||
HRESULT hr = gdraw->d3d_device->CreateBuffer(&desc, nullptr, &buf);
|
||||
ID3D1X(Buffer) *buf = NULL;
|
||||
HRESULT hr = gdraw->d3d_device->CreateBuffer(&desc, NULL, &buf);
|
||||
if (FAILED(hr)) {
|
||||
report_d3d_error(hr, "CreateBuffer", " creating dynamic vertex buffer");
|
||||
buf = nullptr;
|
||||
buf = NULL;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
@@ -1907,7 +1907,7 @@ static void create_all_shaders_and_state(void)
|
||||
HRESULT hr = d3d->CreateInputLayout(vformats[i].desc, vformats[i].nelem, vsh->bytecode, vsh->size, &gdraw->inlayout[i]);
|
||||
if (FAILED(hr)) {
|
||||
report_d3d_error(hr, "CreateInputLayout", "");
|
||||
gdraw->inlayout[i] = nullptr;
|
||||
gdraw->inlayout[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2026,11 +2026,11 @@ static void create_all_shaders_and_state(void)
|
||||
hr = gdraw->d3d_device->CreateBuffer(&bufdesc, &data, &gdraw->quad_ib);
|
||||
if (FAILED(hr)) {
|
||||
report_d3d_error(hr, "CreateBuffer", " for constants");
|
||||
gdraw->quad_ib = nullptr;
|
||||
gdraw->quad_ib = NULL;
|
||||
}
|
||||
IggyGDrawFree(inds);
|
||||
} else
|
||||
gdraw->quad_ib = nullptr;
|
||||
gdraw->quad_ib = NULL;
|
||||
}
|
||||
|
||||
static void destroy_all_shaders_and_state()
|
||||
@@ -2103,7 +2103,7 @@ static void free_gdraw()
|
||||
if (gdraw->texturecache) IggyGDrawFree(gdraw->texturecache);
|
||||
if (gdraw->vbufcache) IggyGDrawFree(gdraw->vbufcache);
|
||||
IggyGDrawFree(gdraw);
|
||||
gdraw = nullptr;
|
||||
gdraw = NULL;
|
||||
}
|
||||
|
||||
static bool alloc_dynbuffer(U32 size)
|
||||
@@ -2139,7 +2139,7 @@ static bool alloc_dynbuffer(U32 size)
|
||||
gdraw->max_quad_vert_count = RR_MIN(size / sizeof(gswf_vertex_xyst), QUAD_IB_COUNT * 4);
|
||||
gdraw->max_quad_vert_count &= ~3; // must be multiple of four
|
||||
|
||||
return gdraw->dyn_vb.buffer != nullptr && gdraw->dyn_ib.buffer != nullptr;
|
||||
return gdraw->dyn_vb.buffer != NULL && gdraw->dyn_ib.buffer != NULL;
|
||||
}
|
||||
|
||||
int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S32 num_bytes)
|
||||
@@ -2178,7 +2178,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3
|
||||
IggyGDrawFree(gdraw->texturecache);
|
||||
}
|
||||
gdraw->texturecache = make_handle_cache(GDRAW_D3D1X_(RESOURCE_texture));
|
||||
return gdraw->texturecache != nullptr;
|
||||
return gdraw->texturecache != NULL;
|
||||
|
||||
case GDRAW_D3D1X_(RESOURCE_vertexbuffer):
|
||||
if (gdraw->vbufcache) {
|
||||
@@ -2186,7 +2186,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3
|
||||
IggyGDrawFree(gdraw->vbufcache);
|
||||
}
|
||||
gdraw->vbufcache = make_handle_cache(GDRAW_D3D1X_(RESOURCE_vertexbuffer));
|
||||
return gdraw->vbufcache != nullptr;
|
||||
return gdraw->vbufcache != NULL;
|
||||
|
||||
case GDRAW_D3D1X_(RESOURCE_dynbuffer):
|
||||
unbind_resources();
|
||||
@@ -2202,7 +2202,7 @@ int gdraw_D3D1X_(SetResourceLimits)(gdraw_resourcetype type, S32 num_handles, S3
|
||||
static GDrawFunctions *create_context(ID3D1XDevice *dev, ID3D1XContext *ctx, S32 w, S32 h)
|
||||
{
|
||||
gdraw = (GDraw *) IggyGDrawMalloc(sizeof(*gdraw));
|
||||
if (!gdraw) return nullptr;
|
||||
if (!gdraw) return NULL;
|
||||
|
||||
memset(gdraw, 0, sizeof(*gdraw));
|
||||
|
||||
@@ -2217,7 +2217,7 @@ static GDrawFunctions *create_context(ID3D1XDevice *dev, ID3D1XContext *ctx, S32
|
||||
|
||||
if (!gdraw->texturecache || !gdraw->vbufcache || !alloc_dynbuffer(gdraw_limits[GDRAW_D3D1X_(RESOURCE_dynbuffer)].num_bytes)) {
|
||||
free_gdraw();
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
create_all_shaders_and_state();
|
||||
@@ -2288,7 +2288,7 @@ void gdraw_D3D1X_(DestroyContext)(void)
|
||||
if (gdraw->texturecache) gdraw_res_flush(gdraw->texturecache, &stats);
|
||||
if (gdraw->vbufcache) gdraw_res_flush(gdraw->vbufcache, &stats);
|
||||
|
||||
gdraw->d3d_device = nullptr;
|
||||
gdraw->d3d_device = NULL;
|
||||
}
|
||||
|
||||
free_gdraw();
|
||||
@@ -2351,7 +2351,7 @@ void RADLINK gdraw_D3D1X_(GetResourceUsageStats)(gdraw_resourcetype type, S32 *h
|
||||
case GDRAW_D3D1X_(RESOURCE_texture): cache = gdraw->texturecache; break;
|
||||
case GDRAW_D3D1X_(RESOURCE_vertexbuffer): cache = gdraw->vbufcache; break;
|
||||
case GDRAW_D3D1X_(RESOURCE_dynbuffer): *handles_used = 0; *bytes_used = gdraw->last_dyn_maxalloc; return;
|
||||
default: cache = nullptr; break;
|
||||
default: cache = NULL; break;
|
||||
}
|
||||
|
||||
*handles_used = *bytes_used = 0;
|
||||
@@ -2408,7 +2408,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file,
|
||||
case IFT_FORMAT_DXT3 : size=16; d3dfmt = DXGI_FORMAT_BC2_UNORM; blk = 4; break;
|
||||
case IFT_FORMAT_DXT5 : size=16; d3dfmt = DXGI_FORMAT_BC3_UNORM; blk = 4; break;
|
||||
default: {
|
||||
IggyGDrawSendWarning(nullptr, "GDraw .iggytex raw texture format %d not supported by hardware", texture->format);
|
||||
IggyGDrawSendWarning(NULL, "GDraw .iggytex raw texture format %d not supported by hardware", texture->format);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@@ -2424,7 +2424,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file,
|
||||
|
||||
free_data = (U8 *) IggyGDrawMalloc(total_size);
|
||||
if (!free_data) {
|
||||
IggyGDrawSendWarning(nullptr, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height);
|
||||
IggyGDrawSendWarning(NULL, "GDraw out of memory to store texture data to pass to D3D for %d x %d texture", width, height);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -2457,7 +2457,7 @@ GDrawTexture * RADLINK gdraw_D3D1X_(MakeTextureFromResource)(U8 *resource_file,
|
||||
if (FAILED(hr)) goto done;
|
||||
|
||||
failed_call = "CreateShaderResourceView for texture creation";
|
||||
hr = gdraw->d3d_device->CreateShaderResourceView(tex, nullptr, &view);
|
||||
hr = gdraw->d3d_device->CreateShaderResourceView(tex, NULL, &view);
|
||||
if (FAILED(hr)) goto done;
|
||||
|
||||
t = gdraw_D3D1X_(WrappedTextureCreate)(view);
|
||||
|
||||
@@ -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;
|
||||
@@ -558,7 +558,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)
|
||||
@@ -773,7 +773,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);
|
||||
}
|
||||
|
||||
@@ -825,7 +825,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);
|
||||
}
|
||||
|
||||
@@ -837,7 +837,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;
|
||||
|
||||
@@ -944,7 +944,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;
|
||||
@@ -1090,7 +1090,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 {
|
||||
@@ -1127,7 +1127,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;
|
||||
@@ -1152,7 +1152,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
|
||||
@@ -1161,7 +1161,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.
|
||||
@@ -1379,7 +1379,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);)
|
||||
|
||||
@@ -1452,7 +1452,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]
|
||||
@@ -1460,7 +1460,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);
|
||||
|
||||
@@ -1501,16 +1501,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);)
|
||||
@@ -1560,7 +1560,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)
|
||||
@@ -1730,7 +1730,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++)
|
||||
@@ -1743,7 +1743,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)
|
||||
@@ -1905,7 +1905,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
|
||||
@@ -2295,7 +2295,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;
|
||||
}
|
||||
|
||||
@@ -2305,7 +2305,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);
|
||||
|
||||
@@ -2410,7 +2410,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;
|
||||
}
|
||||
|
||||
@@ -2430,8 +2430,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
|
||||
@@ -2440,7 +2440,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
|
||||
@@ -2448,7 +2448,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;
|
||||
}
|
||||
}
|
||||
@@ -2463,8 +2463,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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2508,7 +2508,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);
|
||||
}
|
||||
@@ -2516,11 +2516,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);
|
||||
@@ -2532,7 +2532,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