Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
bc60a0a8
Commit
bc60a0a8
authored
Dec 8, 2019
by
Lactozilla
Browse files
Options
Downloads
Patches
Plain Diff
Make some things clearer here.
parent
40b86296
No related branches found
No related tags found
2 merge requests
!734
Rebase Keycodes only branch.
,
!519
OpenGL fixes
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/hardware/hw_cache.c
+28
-15
28 additions, 15 deletions
src/hardware/hw_cache.c
with
28 additions
and
15 deletions
src/hardware/hw_cache.c
+
28
−
15
View file @
bc60a0a8
...
...
@@ -760,15 +760,15 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
// CACHING HANDLING
// =================================================
static
size_t
gr_numtextures
;
static
GLTexture_t
*
gr_textures
;
//
f
or
ALL Doom
textures
static
GLTexture_t
*
gr_
textures2
;
static
size_t
gr_numtextures
;
// Texture count
static
GLTexture_t
*
gr_textures
;
//
F
or
all
textures
static
GLTexture_t
*
gr_
flats
;
// For all (texture) flats, as normal flats don't need to be cached
void
HWR_InitTextureCache
(
void
)
{
gr_numtextures
=
0
;
gr_textures
=
NULL
;
gr_
textures2
=
NULL
;
gr_
flats
=
NULL
;
}
// Callback function for HWR_FreeTextureCache.
...
...
@@ -831,10 +831,10 @@ void HWR_FreeTextureCache(void)
// texturecache info, we can free it
if
(
gr_textures
)
free
(
gr_textures
);
if
(
gr_
textures2
)
free
(
gr_
textures2
);
if
(
gr_
flats
)
free
(
gr_
flats
);
gr_textures
=
NULL
;
gr_
textures2
=
NULL
;
gr_
flats
=
NULL
;
gr_numtextures
=
0
;
}
...
...
@@ -848,13 +848,15 @@ void HWR_PrepLevelCache(size_t pnumtextures)
// we must free it since numtextures changed
HWR_FreeTextureCache
();
// Why not Z_Malloc?
gr_numtextures
=
pnumtextures
;
gr_textures
=
calloc
(
pnumtextures
,
sizeof
(
*
gr_textures
));
if
(
gr_textures
==
NULL
)
I_Error
(
"3D can't alloc gr_textures"
);
gr_textures2
=
calloc
(
pnumtextures
,
sizeof
(
*
gr_textures2
));
if
(
gr_textures2
==
NULL
)
I_Error
(
"3D can't alloc gr_textures2"
);
gr_textures
=
calloc
(
gr_numtextures
,
sizeof
(
*
gr_textures
));
gr_flats
=
calloc
(
gr_numtextures
,
sizeof
(
*
gr_flats
));
// Doesn't tell you which it _is_, but hopefully
// should never ever happen (right?!)
if
((
gr_textures
==
NULL
)
||
(
gr_flats
==
NULL
))
I_Error
(
"HWR_PrepLevelCache: ran out of memory for OpenGL textures. Sad!"
);
}
void
HWR_SetPalette
(
RGBA_t
*
palette
)
...
...
@@ -887,11 +889,16 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
if
((
unsigned
)
tex
>=
gr_numtextures
)
I_Error
(
"HWR_GetTexture: tex >= numtextures
\n
"
);
#endif
// Every texture in memory, stored in the
// hardware renderer's bit depth format. Wow!
grtex
=
&
gr_textures
[
tex
];
// Generate texture if missing from the cache
if
(
!
grtex
->
mipmap
.
grInfo
.
data
&&
!
grtex
->
mipmap
.
downloaded
)
HWR_GenerateTexture
(
tex
,
grtex
);
// Tell the hardware driver to bind the current texture to the flat's mipmap
HWD
.
pfnSetTexture
(
&
grtex
->
mipmap
);
// The system-memory data can be purged now.
...
...
@@ -1003,13 +1010,19 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
if
((
unsigned
)
texturenum
>=
gr_numtextures
)
I_Error
(
"HWR_GetLevelFlat: texturenum >= numtextures
\n
"
);
#endif
// Who knows?
if
(
texturenum
==
0
||
texturenum
==
-
1
)
return
;
grtex
=
&
gr_textures2
[
texturenum
];
// Every texture in memory, stored as a 8-bit flat. Wow!
grtex
=
&
gr_flats
[
texturenum
];
// Generate flat if missing from the cache
if
(
!
grtex
->
mipmap
.
grInfo
.
data
&&
!
grtex
->
mipmap
.
downloaded
)
HWR_CacheTextureAsFlat
(
&
grtex
->
mipmap
,
texturenum
);
// Tell the hardware driver to bind the current texture to the flat's mipmap
HWD
.
pfnSetTexture
(
&
grtex
->
mipmap
);
// The system-memory data can be purged now.
...
...
@@ -1033,6 +1046,7 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
HWR_MakePatch
(
patch
,
gpatch
,
grmip
,
true
);
// You can't free rawpatch for some reason?
// (Obviously I can't, sprite rotation needs that...)
if
(
!
gpatch
->
rawpatch
)
Z_Free
(
patch
);
}
...
...
@@ -1060,7 +1074,6 @@ void HWR_GetPatch(GLPatch_t *gpatch)
// this is inefficient.. but the hardware patch in heap is purgeable so it should
// not fragment memory, and besides the REAL cache here is the hardware memory
// You can't free rawpatch for some reason?
if
(
!
gpatch
->
rawpatch
)
Z_Free
(
ptr
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment