mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:53:52 +00:00
Fixed mirror texture blitting when back buffer is multisampled (maybe i should just force it to not be)
This commit is contained in:
parent
61e8368e53
commit
1f76f93221
4 changed files with 51 additions and 27 deletions
|
@ -216,8 +216,12 @@ namespace MWGui
|
|||
getWidget(mControllerSwitch, "ControllerButton");
|
||||
getWidget(mWaterTextureSize, "WaterTextureSize");
|
||||
getWidget(mWaterReflectionDetail, "WaterReflectionDetail");
|
||||
getWidget(mVRMirrorTextureEye, "VRMirrorTextureEye");
|
||||
getWidget(mVRLeftHudPosition, "VRLeftHudPosition");
|
||||
|
||||
if (MWBase::Environment::get().getVrMode())
|
||||
{
|
||||
getWidget(mVRMirrorTextureEye, "VRMirrorTextureEye");
|
||||
getWidget(mVRLeftHudPosition, "VRLeftHudPosition");
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
// hide gamma controls since it currently does not work under Linux
|
||||
|
@ -246,8 +250,11 @@ namespace MWGui
|
|||
mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
|
||||
mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked);
|
||||
|
||||
mVRMirrorTextureEye->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onVRMirrorTextureEyeChanged);
|
||||
mVRLeftHudPosition->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onVRLeftHudPositionChanged);
|
||||
if (MWBase::Environment::get().getVrMode())
|
||||
{
|
||||
mVRMirrorTextureEye->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onVRMirrorTextureEyeChanged);
|
||||
mVRLeftHudPosition->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onVRLeftHudPositionChanged);
|
||||
}
|
||||
|
||||
center();
|
||||
|
||||
|
@ -277,15 +284,18 @@ namespace MWGui
|
|||
std::string tmip = Settings::Manager::getString("texture mipmap", "General");
|
||||
mTextureFilteringButton->setCaption(textureMipmappingToStr(tmip));
|
||||
|
||||
std::string mirrorTextureEye = Settings::Manager::getString("mirror texture eye", "VR");
|
||||
for (unsigned i = 0; i < mVRMirrorTextureEye->getItemCount(); i++)
|
||||
if (Misc::StringUtils::ciEqual(mirrorTextureEye, mVRMirrorTextureEye->getItem(i)))
|
||||
mVRMirrorTextureEye->setIndexSelected(i);
|
||||
if (MWBase::Environment::get().getVrMode())
|
||||
{
|
||||
std::string mirrorTextureEye = Settings::Manager::getString("mirror texture eye", "VR");
|
||||
for (unsigned i = 0; i < mVRMirrorTextureEye->getItemCount(); i++)
|
||||
if (Misc::StringUtils::ciEqual(mirrorTextureEye, mVRMirrorTextureEye->getItem(i)))
|
||||
mVRMirrorTextureEye->setIndexSelected(i);
|
||||
|
||||
std::string leftHandHudPosition = Settings::Manager::getString("left hand hud position", "VR");
|
||||
for (unsigned i = 0; i < mVRLeftHudPosition->getItemCount(); i++)
|
||||
if (Misc::StringUtils::ciEqual(leftHandHudPosition, mVRLeftHudPosition->getItem(i)))
|
||||
mVRLeftHudPosition->setIndexSelected(i);
|
||||
std::string leftHandHudPosition = Settings::Manager::getString("left hand hud position", "VR");
|
||||
for (unsigned i = 0; i < mVRLeftHudPosition->getItemCount(); i++)
|
||||
if (Misc::StringUtils::ciEqual(leftHandHudPosition, mVRLeftHudPosition->getItem(i)))
|
||||
mVRLeftHudPosition->setIndexSelected(i);
|
||||
}
|
||||
|
||||
int waterTextureSize = Settings::Manager::getInt("rtt size", "Water");
|
||||
if (waterTextureSize >= 512)
|
||||
|
@ -524,9 +534,12 @@ namespace MWGui
|
|||
MWBase::Environment::get().getInputManager()->processChangedSettings(changed);
|
||||
MWBase::Environment::get().getMechanicsManager()->processChangedSettings(changed);
|
||||
#ifdef USE_OPENXR
|
||||
MWVR::Environment::get().getSession()->processChangedSettings(changed);
|
||||
MWVR::Environment::get().getViewer()->processChangedSettings(changed);
|
||||
MWVR::Environment::get().getGUIManager()->processChangedSettings(changed);
|
||||
if (MWBase::Environment::get().getVrMode())
|
||||
{
|
||||
MWVR::Environment::get().getSession()->processChangedSettings(changed);
|
||||
MWVR::Environment::get().getViewer()->processChangedSettings(changed);
|
||||
MWVR::Environment::get().getGUIManager()->processChangedSettings(changed);
|
||||
}
|
||||
#endif
|
||||
Settings::Manager::resetPendingChanges();
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@ namespace MWVR {
|
|||
{
|
||||
mFramebuffer->bindFramebuffer(gc, GL_FRAMEBUFFER_EXT);
|
||||
readBuffer.blit(gc, offset_x, offset_y, offset_x + mFramebuffer->width(), offset_y + mFramebuffer->height(), 0, 0, mFramebuffer->width(), mFramebuffer->height(), mBufferBits, GL_NEAREST);
|
||||
readBuffer.bindFramebuffer(gc, GL_FRAMEBUFFER_EXT);
|
||||
}
|
||||
|
||||
XrSwapchainImageOpenGLKHR mXrImage;
|
||||
|
@ -148,7 +147,6 @@ namespace MWVR {
|
|||
mFramebuffer->bindFramebuffer(gc, GL_FRAMEBUFFER_EXT);
|
||||
readBuffer.blit(gc, offset_x, offset_y, offset_x + mFramebuffer->width(), offset_y + mFramebuffer->height(), 0, mFramebuffer->height(), mFramebuffer->width(), 0, mBufferBits, GL_NEAREST);
|
||||
xr->impl().platform().DXUnlockObject(mDxResourceShareHandle);
|
||||
readBuffer.bindFramebuffer(gc, GL_FRAMEBUFFER_EXT);
|
||||
|
||||
|
||||
// If the d3d11 texture couldn't be shared directly, blit it again.
|
||||
|
|
|
@ -96,7 +96,6 @@ namespace MWVR
|
|||
|
||||
void VRFramebuffer::blit(osg::GraphicsContext* gc, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, uint32_t bits, uint32_t filter)
|
||||
{
|
||||
#define GLERR if(auto err = glGetError() != GL_NO_ERROR) Log(Debug::Verbose) << __FILE__ << "." << __LINE__ << ": " << glGetError()
|
||||
auto* state = gc->getState();
|
||||
auto* gl = osg::GLExtensions::Get(state->getContextID(), false);
|
||||
gl->glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, mFBO);
|
||||
|
@ -111,13 +110,16 @@ namespace MWVR
|
|||
glGenTextures(1, &image);
|
||||
glBindTexture(mTextureTarget, image);
|
||||
if (mSamples <= 1)
|
||||
{
|
||||
glTexImage2D(mTextureTarget, 0, formatInternal, mWidth, mHeight, 0, format, GL_UNSIGNED_INT, nullptr);
|
||||
glTexParameteri(mTextureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER_ARB);
|
||||
glTexParameteri(mTextureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER_ARB);
|
||||
glTexParameteri(mTextureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(mTextureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
else
|
||||
gl->glTexImage2DMultisample(mTextureTarget, mSamples, format, mWidth, mHeight, false);
|
||||
glTexParameteri(mTextureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER_ARB);
|
||||
glTexParameteri(mTextureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER_ARB);
|
||||
glTexParameteri(mTextureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(mTextureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glTexParameteri(mTextureTarget, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
|
||||
return image;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include <osgViewer/Renderer>
|
||||
|
||||
#include <components/debug/gldebug.hpp>
|
||||
|
||||
#include <components/sceneutil/mwshadowtechnique.hpp>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
@ -18,6 +20,8 @@
|
|||
|
||||
#include <components/sdlutil/sdlgraphicswindow.hpp>
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
namespace MWVR
|
||||
{
|
||||
|
||||
|
@ -270,14 +274,18 @@ namespace MWVR
|
|||
//mSwapchain->framebuffer()->blit(gc, 0, 0, mMsaaResolveMirrorTexture->width(), mMsaaResolveMirrorTexture->height(), GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
mFramebuffer->blit(gc, 0, 0, mFramebuffer->width(), mFramebuffer->height(), 0, 0, mMsaaResolveTexture->width(), mMsaaResolveTexture->height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
mFramebuffer->blit(gc, 0, 0, mFramebuffer->width(), mFramebuffer->height(), 0, 0, mMsaaResolveTexture->width(), mMsaaResolveTexture->height(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
//mMirrorTexture->bindFramebuffer(gc, GL_FRAMEBUFFER_EXT);
|
||||
gl->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
mMsaaResolveTexture->blit(gc, 0, 0, mMsaaResolveTexture->width(), mMsaaResolveTexture->height(), 0, 0, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
//mMirrorTexture->blit(gc, 0, 0, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT);
|
||||
if (mMirrorTexture)
|
||||
{
|
||||
mMirrorTexture->bindFramebuffer(gc, GL_FRAMEBUFFER_EXT);
|
||||
mMsaaResolveTexture->blit(gc, 0, 0, mMsaaResolveTexture->width(), mMsaaResolveTexture->height(), 0, 0, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
gl->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
mMirrorTexture->blit(gc, 0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
mSwapchain[0]->endFrame(gc, *mMsaaResolveTexture);
|
||||
mSwapchain[1]->endFrame(gc, *mMsaaResolveTexture);
|
||||
gl->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -291,7 +299,10 @@ namespace MWVR
|
|||
RealizeOperation::operator()(
|
||||
osg::GraphicsContext* gc)
|
||||
{
|
||||
return Environment::get().getViewer()->configureXR(gc);
|
||||
if (Debug::shouldDebugOpenGL())
|
||||
Debug::EnableGLDebugOperation()(gc);
|
||||
|
||||
Environment::get().getViewer()->configureXR(gc);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Loading…
Reference in a new issue