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

View file

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

View file

@ -216,19 +216,29 @@ void GL41FixedAllocationTexture::allocateStorage() const {
const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat()); const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat());
const auto numMips = _gpuObject.getNumMips(); const auto numMips = _gpuObject.getNumMips();
const auto numSlices = _gpuObject.getNumSlices(); const auto numSlices = _gpuObject.getNumSlices();
const auto numSamples = _gpuObject.getNumSamples();
// glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); // glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
for (GLint level = 0; level < numMips; level++) { if (!_gpuObject.isMultisample()) {
Vec3u dimensions = _gpuObject.evalMipDimensions(level); for (GLint level = 0; level < numMips; level++) {
for (GLenum target : getFaceTargets(_target)) { Vec3u dimensions = _gpuObject.evalMipDimensions(level);
if (!_gpuObject.isArray()) { for (GLenum target : getFaceTargets(_target)) {
glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format, if (!_gpuObject.isArray()) {
texelFormat.type, nullptr); glTexImage2D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, 0, texelFormat.format,
} else { texelFormat.type, nullptr);
glTexImage3D(target, level, texelFormat.internalFormat, dimensions.x, dimensions.y, numSlices, 0, } else {
texelFormat.format, texelFormat.type, nullptr); 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); 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) { void ToneMappingDeferred::configure(const Config& config) {
_toneMappingEffect.setExposure(config.exposure); _toneMappingEffect.setExposure(config.exposure);
_toneMappingEffect.setColorFilter(config.colorFilter); _toneMappingEffect.setColorFilter(toGlm(config.colorFilter));
_toneMappingEffect.setToneCurve((ToneMappingEffect::ToneCurve)config.curve); _toneMappingEffect.setToneCurve((ToneMappingEffect::ToneCurve)config.curve);
} }

View file

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

View file

@ -23,6 +23,7 @@ Item {
height: 24 height: 24
property var _color: Qt.rgba(1.0, 1.0, 1.0, 1.0 ); 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 zoneWidth: width / 3;
property var hoveredOn: 0.0; property var hoveredOn: 0.0;
property var sliderHeight: height / 2; property var sliderHeight: height / 2;

View file

@ -124,22 +124,6 @@ Rectangle {
anchors.right: parent.right 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 { Item {
height: childrenRect.height height: childrenRect.height
anchors.left: parent.left anchors.left: parent.left
@ -150,18 +134,17 @@ Rectangle {
anchors.left: parent.left anchors.left: parent.left
} }
HifiControls.ComboBox { ComboBox {
anchors.right: parent.right anchors.right: parent.right
currentIndex: 1 currentIndex: 1
model: ListModel { model: [
id: cbItems "RGB",
ListElement { text: "RGB"; color: "Yellow" } "SRGB",
ListElement { text: "SRGB"; color: "Green" } "Reinhard",
ListElement { text: "Reinhard"; color: "Yellow" } "Filmic",
ListElement { text: "Filmic"; color: "White" } ]
}
width: 200 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; framebuffer.config.mode = mode;
} }
HifiControls.ComboBox { ComboBox {
anchors.right: parent.right anchors.right: parent.right
currentIndex: 0 currentIndex: 0
model: ListModel { model: ListModel {