Multisampling works in 4.1

This commit is contained in:
Sam Gateau 2019-02-06 00:05:17 -08:00
parent 893bbe3a37
commit 35491bf5b0
7 changed files with 46 additions and 43 deletions

View file

@ -106,15 +106,20 @@ const std::vector<GLenum>& GLTexture::getFaceTargets(GLenum target) {
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
};
static const std::vector<GLenum> faceTargets {
static const std::vector<GLenum> face2DTargets {
GL_TEXTURE_2D
};
static const std::vector<GLenum> arrayFaceTargets{
static const std::vector<GLenum> face2DMSTargets{
GL_TEXTURE_2D_MULTISAMPLE
};
static const std::vector<GLenum> arrayFaceTargets{
GL_TEXTURE_2D_ARRAY
};
switch (target) {
case GL_TEXTURE_2D:
return faceTargets;
return face2DTargets;
case GL_TEXTURE_2D_MULTISAMPLE:
return face2DMSTargets;
case GL_TEXTURE_2D_ARRAY:
return arrayFaceTargets;
case GL_TEXTURE_CUBE_MAP:
@ -124,7 +129,7 @@ const std::vector<GLenum>& GLTexture::getFaceTargets(GLenum target) {
break;
}
Q_UNREACHABLE();
return faceTargets;
return face2DTargets;
}
GLTexture::GLTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, GLuint id) :

View file

@ -66,6 +66,8 @@ public:
if (gltexture) {
if (gltexture->_target == GL_TEXTURE_2D) {
glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D, gltexture->_texture, 0);
} else if (gltexture->_target == GL_TEXTURE_2D_MULTISAMPLE) {
glFramebufferTexture2D(GL_FRAMEBUFFER, colorAttachments[unit], GL_TEXTURE_2D_MULTISAMPLE, gltexture->_texture, 0);
} else {
glFramebufferTextureLayer(GL_FRAMEBUFFER, colorAttachments[unit], gltexture->_texture, 0,
b._subresource);
@ -98,6 +100,8 @@ public:
if (gltexture) {
if (gltexture->_target == GL_TEXTURE_2D) {
glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D, gltexture->_texture, 0);
} else if (gltexture->_target == GL_TEXTURE_2D_MULTISAMPLE) {
glFramebufferTexture2D(GL_FRAMEBUFFER, attachement, GL_TEXTURE_2D_MULTISAMPLE, gltexture->_texture, 0);
} else {
glFramebufferTextureLayer(GL_FRAMEBUFFER, attachement, gltexture->_texture, 0,
_gpuObject.getDepthStencilBufferSubresource());

View file

@ -216,19 +216,29 @@ void GL41FixedAllocationTexture::allocateStorage() const {
const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat());
const auto numMips = _gpuObject.getNumMips();
const auto numSlices = _gpuObject.getNumSlices();
const auto numSamples = _gpuObject.getNumSamples();
// glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
for (GLint level = 0; level < numMips; level++) {
Vec3u dimensions = _gpuObject.evalMipDimensions(level);
for (GLenum target : getFaceTargets(_target)) {
if (!_gpuObject.isArray()) {
glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format,
texelFormat.type, nullptr);
} else {
glTexImage3D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices, 0,
texelFormat.format, texelFormat.type, nullptr);
if (!_gpuObject.isMultisample()) {
for (GLint level = 0; level < numMips; level++) {
Vec3u dimensions = _gpuObject.evalMipDimensions(level);
for (GLenum target : getFaceTargets(_target)) {
if (!_gpuObject.isArray()) {
glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format,
texelFormat.type, nullptr);
} else {
glTexImage3D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices, 0,
texelFormat.format, texelFormat.type, nullptr);
}
}
}
} else {
const auto dimensions = _gpuObject.getDimensions();
if (!_gpuObject.isArray()) {
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, numSamples, texelFormat.internalFormat, dimensions.x, dimensions.y, GL_FALSE);
} else {
glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, numSamples, texelFormat.internalFormat, dimensions.x, dimensions.y, dimensions.z, GL_FALSE);
}
}
glTexParameteri(_target, GL_TEXTURE_BASE_LEVEL, 0);

View file

@ -84,7 +84,7 @@ void ToneMappingEffect::render(RenderArgs* args, const gpu::TexturePointer& ligh
void ToneMappingDeferred::configure(const Config& config) {
_toneMappingEffect.setExposure(config.exposure);
_toneMappingEffect.setColorFilter(config.colorFilter);
_toneMappingEffect.setColorFilter(toGlm(config.colorFilter));
_toneMappingEffect.setToneCurve((ToneMappingEffect::ToneCurve)config.curve);
}

View file

@ -70,18 +70,18 @@ private:
class ToneMappingConfig : public render::Job::Config {
Q_OBJECT
Q_PROPERTY(float exposure MEMBER exposure WRITE setExposure);
Q_PROPERTY(glm::vec3 colorFilter MEMBER colorFilter WRITE setColorFilter);
Q_PROPERTY(QColor colorFilter MEMBER colorFilter WRITE setColorFilter);
Q_PROPERTY(int curve MEMBER curve WRITE setCurve);
public:
ToneMappingConfig() : render::Job::Config(true) {}
void setExposure(float newExposure) { exposure = newExposure; emit dirty(); }
void setColorFilter(const glm::vec3& newColorFilter) { colorFilter = newColorFilter; emit dirty(); }
void setColorFilter(const QColor& newColorFilter) { colorFilter = newColorFilter; emit dirty(); }
void setCurve(int newCurve) { curve = std::max((int)ToneMappingEffect::None, std::min((int)ToneMappingEffect::Filmic, newCurve)); emit dirty(); }
float exposure{ 0.0f };
glm::vec3 colorFilter { 1.0f };
QColor colorFilter { 255, 255, 255 };
int curve{ ToneMappingEffect::None };
signals:
void dirty();

View file

@ -23,6 +23,7 @@ Item {
height: 24
property var _color: Qt.rgba(1.0, 1.0, 1.0, 1.0 );
property var _lcolor: Qt.vec4(1.0, 1.0, 1.0, 1.0 );
property var zoneWidth: width / 3;
property var hoveredOn: 0.0;
property var sliderHeight: height / 2;

View file

@ -124,22 +124,6 @@ Rectangle {
anchors.right: parent.right
}
}
Item {
HifiControls.Label {
text: "Color filter"
anchors.left: parent.left
}
Color {
height: 20
anchors.right: parent.right
width: parent.width / 2
_color: render.mainViewTask.getConfig("ToneMapping")["colorFilter"]
onNewColor: {
render.mainViewTask.getConfig("ToneMapping")["colorFilter"] = getXColor()
}
}
}
Item {
height: childrenRect.height
anchors.left: parent.left
@ -150,18 +134,17 @@ Rectangle {
anchors.left: parent.left
}
HifiControls.ComboBox {
ComboBox {
anchors.right: parent.right
currentIndex: 1
model: ListModel {
id: cbItems
ListElement { text: "RGB"; color: "Yellow" }
ListElement { text: "SRGB"; color: "Green" }
ListElement { text: "Reinhard"; color: "Yellow" }
ListElement { text: "Filmic"; color: "White" }
}
model: [
"RGB",
"SRGB",
"Reinhard",
"Filmic",
]
width: 200
onCurrentIndexChanged: { render.mainViewTask.getConfig("ToneMapping")["curve"] = currentIndex }
onCurrentIndexChanged: { render.mainViewTask.getConfig("ToneMapping")["curve"] = currentIndex; }
}
}
}
@ -186,7 +169,7 @@ Rectangle {
framebuffer.config.mode = mode;
}
HifiControls.ComboBox {
ComboBox {
anchors.right: parent.right
currentIndex: 0
model: ListModel {