|
|
@ -20,9 +20,8 @@ RasterizerCacheOpenGL::~RasterizerCacheOpenGL() {
|
|
|
|
|
|
|
|
|
|
|
|
MICROPROFILE_DEFINE(OpenGL_TextureUpload, "OpenGL", "Texture Upload", MP_RGB(128, 64, 192));
|
|
|
|
MICROPROFILE_DEFINE(OpenGL_TextureUpload, "OpenGL", "Texture Upload", MP_RGB(128, 64, 192));
|
|
|
|
|
|
|
|
|
|
|
|
void RasterizerCacheOpenGL::LoadAndBindTexture(OpenGLState &state, unsigned texture_unit, const Pica::Regs::FullTextureConfig& config) {
|
|
|
|
void RasterizerCacheOpenGL::LoadAndBindTexture(OpenGLState &state, unsigned texture_unit, const Pica::DebugUtils::TextureInfo& info) {
|
|
|
|
PAddr texture_addr = config.config.GetPhysicalAddress();
|
|
|
|
const auto cached_texture = texture_cache.find(info.physical_address);
|
|
|
|
const auto cached_texture = texture_cache.find(texture_addr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cached_texture != texture_cache.end()) {
|
|
|
|
if (cached_texture != texture_cache.end()) {
|
|
|
|
state.texture_units[texture_unit].texture_2d = cached_texture->second->texture.handle;
|
|
|
|
state.texture_units[texture_unit].texture_2d = cached_texture->second->texture.handle;
|
|
|
@ -37,26 +36,12 @@ void RasterizerCacheOpenGL::LoadAndBindTexture(OpenGLState &state, unsigned text
|
|
|
|
state.Apply();
|
|
|
|
state.Apply();
|
|
|
|
glActiveTexture(GL_TEXTURE0 + texture_unit);
|
|
|
|
glActiveTexture(GL_TEXTURE0 + texture_unit);
|
|
|
|
|
|
|
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, PicaToGL::TextureFilterMode(config.config.mag_filter));
|
|
|
|
u8* texture_src_data = Memory::GetPhysicalPointer(info.physical_address);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, PicaToGL::TextureFilterMode(config.config.min_filter));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GLenum wrap_s = PicaToGL::WrapMode(config.config.wrap_s);
|
|
|
|
|
|
|
|
GLenum wrap_t = PicaToGL::WrapMode(config.config.wrap_t);
|
|
|
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s);
|
|
|
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (wrap_s == GL_CLAMP_TO_BORDER || wrap_t == GL_CLAMP_TO_BORDER) {
|
|
|
|
|
|
|
|
auto border_color = PicaToGL::ColorRGBA8(config.config.border_color.raw);
|
|
|
|
|
|
|
|
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, border_color.data());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const auto info = Pica::DebugUtils::TextureInfo::FromPicaRegister(config.config, config.format);
|
|
|
|
|
|
|
|
u8* texture_src_data = Memory::GetPhysicalPointer(texture_addr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new_texture->width = info.width;
|
|
|
|
new_texture->width = info.width;
|
|
|
|
new_texture->height = info.height;
|
|
|
|
new_texture->height = info.height;
|
|
|
|
new_texture->size = info.stride * info.height;
|
|
|
|
new_texture->size = info.stride * info.height;
|
|
|
|
new_texture->addr = texture_addr;
|
|
|
|
new_texture->addr = info.physical_address;
|
|
|
|
new_texture->hash = Common::ComputeHash64(texture_src_data, new_texture->size);
|
|
|
|
new_texture->hash = Common::ComputeHash64(texture_src_data, new_texture->size);
|
|
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<Math::Vec4<u8>[]> temp_texture_buffer_rgba(new Math::Vec4<u8>[info.width * info.height]);
|
|
|
|
std::unique_ptr<Math::Vec4<u8>[]> temp_texture_buffer_rgba(new Math::Vec4<u8>[info.width * info.height]);
|
|
|
@ -69,7 +54,7 @@ void RasterizerCacheOpenGL::LoadAndBindTexture(OpenGLState &state, unsigned text
|
|
|
|
|
|
|
|
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, info.width, info.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp_texture_buffer_rgba.get());
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, info.width, info.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp_texture_buffer_rgba.get());
|
|
|
|
|
|
|
|
|
|
|
|
texture_cache.emplace(texture_addr, std::move(new_texture));
|
|
|
|
texture_cache.emplace(info.physical_address, std::move(new_texture));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|