Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose tex clear funcs and fix more Metal issues with blended textures (cherry-pick) #409

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/graphic/Fast3D/gfx_metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,10 @@ void gfx_metal_end_frame(void) {
fb.has_ended_encoding = false;
fb.has_bounded_vertex_buffer = false;
fb.has_bounded_fragment_buffer = false;
fb.last_bound_textures[0] = nullptr;
fb.last_bound_textures[1] = nullptr;
fb.last_bound_samplers[0] = nullptr;
fb.last_bound_samplers[1] = nullptr;
for (int i = 0; i < SHADER_MAX_TEXTURES; i++) {
fb.last_bound_textures[i] = nullptr;
fb.last_bound_samplers[i] = nullptr;
}
fb.last_depth_test = -1;
fb.last_depth_mask = -1;
fb.last_zmode_decal = -1;
Expand Down
10 changes: 9 additions & 1 deletion src/graphic/Fast3D/gfx_pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ static std::string gfx_get_base_texture_path(const std::string& path) {
return path;
}

static void gfx_texture_cache_delete(const uint8_t* orig_addr) {
void gfx_texture_cache_delete(const uint8_t* orig_addr) {
while (gfx_texture_cache.map.bucket_count() > 0) {
TextureCacheKey key = { orig_addr, { 0 }, 0, 0 }; // bucket index only depends on the address
size_t bucket = gfx_texture_cache.map.bucket(key);
Expand Down Expand Up @@ -3341,3 +3341,11 @@ void gfx_register_blended_texture(const char* name, uint8_t* mask, uint8_t* repl

masked_textures[name] = MaskedTextureEntry{ mask, replacement };
}

void gfx_unregister_blended_texture(const char* name) {
if (gfx_check_image_signature(name)) {
name += 7;
}

masked_textures.erase(name);
}
2 changes: 2 additions & 0 deletions src/graphic/Fast3D/gfx_pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ void gfx_run(Gfx* commands, const std::unordered_map<Mtx*, MtxF>& mtx_replacemen
void gfx_end_frame(void);
void gfx_set_target_fps(int);
void gfx_set_maximum_frame_latency(int latency);
void gfx_texture_cache_delete(const uint8_t* orig_addr);
extern "C" void gfx_texture_cache_clear();
extern "C" int gfx_create_framebuffer(uint32_t width, uint32_t height);
void gfx_get_pixel_depth_prepare(float x, float y);
uint16_t gfx_get_pixel_depth(float x, float y);
void gfx_push_current_dir(char* path);
int32_t gfx_check_image_signature(const char* imgData);
void gfx_register_blended_texture(const char* name, uint8_t* mask, uint8_t* replacement = nullptr);
void gfx_unregister_blended_texture(const char* name);

#endif
Loading