renderer_opengl: Fix shader compilation

* Also use glCopyImageSubData to do texture copies'
This commit is contained in:
GPUCode
2023-01-02 16:22:51 +02:00
parent a6ca7dca61
commit 8779cb7785
3 changed files with 13 additions and 17 deletions

View File

@ -118,18 +118,18 @@ void OGLSampler::Release() {
}
void OGLShader::Create(std::string_view source, GLenum type) {
if (handle != 0)
return;
if (source == nullptr)
if (handle != 0 || source.empty()) {
return;
}
MICROPROFILE_SCOPE(OpenGL_ResourceCreation);
handle = LoadShader(source, type);
}
void OGLShader::Release() {
if (handle == 0)
if (handle == 0) {
return;
}
MICROPROFILE_SCOPE(OpenGL_ResourceDeletion);
glDeleteShader(handle);
@ -137,8 +137,9 @@ void OGLShader::Release() {
}
void OGLProgram::Create(bool separable_program, const std::vector<GLuint>& shaders) {
if (handle != 0)
if (handle != 0) {
return;
}
MICROPROFILE_SCOPE(OpenGL_ResourceCreation);
handle = LoadProgram(separable_program, shaders);

View File

@ -222,18 +222,12 @@ bool TextureRuntime::ClearTexture(Surface& surface, const VideoCore::TextureClea
bool TextureRuntime::CopyTextures(Surface& source, Surface& dest,
const VideoCore::TextureCopy& copy) {
// Emulate texture copy with blit for now
const VideoCore::TextureBlit blit = {
.src_level = copy.src_level,
.dst_level = copy.dst_level,
.src_layer = copy.src_layer,
.dst_layer = copy.dst_layer,
.src_rect = {copy.src_offset.x, copy.src_offset.y + copy.extent.height,
copy.src_offset.x + copy.extent.width, copy.src_offset.y},
.dst_rect = {copy.dst_offset.x, copy.dst_offset.y + copy.extent.height,
copy.dst_offset.x + copy.extent.width, copy.dst_offset.y}};
return BlitTextures(source, dest, blit);
glCopyImageSubData(source.texture.handle, GL_TEXTURE_2D,
copy.src_level, copy.src_offset.x, copy.src_offset.y, 0,
dest.texture.handle, GL_TEXTURE_2D,
copy.dst_level, copy.dst_offset.x, copy.dst_offset.y, 0,
copy.extent.width, copy.extent.height, 1);
return true;
}
bool TextureRuntime::BlitTextures(Surface& source, Surface& dest,

View File

@ -338,6 +338,7 @@ ImageAlloc TextureRuntime::Allocate(u32 width, u32 height, VideoCore::PixelForma
alloc.storage_view = device.createImageView(storage_view_info);
}
renderpass_cache.ExitRenderpass();
scheduler.Record([image = alloc.image, aspect = alloc.aspect](vk::CommandBuffer cmdbuf) {
const vk::ImageMemoryBarrier init_barrier = {
.srcAccessMask = vk::AccessFlagBits::eNone,