- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我注意到当 GLSL 版本低于 130 时,我的 GLSL 着色器无法编译。
拥有向后兼容的着色器源最关键的要素是什么?我不想完全向后兼容,但我想了解在 GLSL 低于 130 的 GPU 上运行简单(向前兼容)着色器的主要准则。
当然这个问题可以通过预处理器来解决
#if __VERSION__ < 130
#define VERTEX_IN attribute
#else
#define VERTER_IN in
#endif
但是可能有很多问题我忽略了。
最佳答案
最近的事件提出了这个老问题,我意识到我解决了这个问题。这并不容易,但它是一个成功的解决方案,许多基于它的着色器以及编译着色器源代码的驱动程序的数量都证明了这一点。
本质上,我使用了 GL_ARB_shading_language_include扩展(并且我还为那些未实现它的系统实现了源预处理器),并且我最终定义了以下着色器包含源:
// Copyright (C) 2011-2013 Luca Piccioni
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// @BeginInterface
// Shader renderer
// Symbol defined if running on NVIDIA renderer.
#define DS_VENDOR_NVIDIA 1
// Symbol defined if running on ATI/AMD renderer.
#define DS_VENDOR_AMD 2
// Symbol defined if running on INTEL renderer
#define DS_VENDOR_INTEL 3
// Shader inputs and outputs keywords
//
// - ATTRIBUTE: used to mark a vertex shader inputs
// - SHADER_IN: used to mark a non-vertex shader inputs
// - SHADER_OUT: used to mark a non-fragment shader output
// - OUT: used to mark a fragment shader output
#if __VERSION__ >= 130
#define ATTRIBUTE in
#define SHADER_IN in
#define SHADER_OUT out
#define OUT out
#else
#define ATTRIBUTE attribute
#define SHADER_IN varying
#define SHADER_OUT varying
#define OUT
#endif
// Support array attributes
#if __VERSION__ >= 130
#define ARRAY_ATTRIBUTE(name, size) name[size]
#else
#define ARRAY_ATTRIBUTE(name, size) name[size]
#endif
// Uniform blocks
#if __VERSION__ >= 130
#define BEGIN_UNIFORM_BLOCK(name) uniform name {
#define END_UNIFORM_BLOCK() };
#else
#define BEGIN_UNIFORM_BLOCK(name)
#define END_UNIFORM_BLOCK()
#endif
// Input and output blocks
#if __VERSION__ >= 150
#define BEGIN_INPUT_BLOCK(name) in name {
#define END_INPUT_BLOCK() };
#define BEGIN_OUTPUT_BLOCK(name) out name {
#define END_OUTPUT_BLOCK() };
#else
#define BEGIN_INPUT_BLOCK(name)
#define END_INPUT_BLOCK()
#define BEGIN_OUTPUT_BLOCK(name)
#define END_OUTPUT_BLOCK()
#endif
// Texturing functions
#if __VERSION__ >= 130
#define TEXTURE_2D texture
#define TEXTURE_3D texture
#define TEXTURE_RECT texture
#define TEXTURE_CUBE texture
#if __VERSION__ >= 150
#define TEXTURE_SIZE(sampler) textureSize(sampler)
#else
#define TEXTURE_SIZE(sampler) sampler ## _Size
#endif
#else
#define TEXTURE_2D texture2D
#define TEXTURE_3D texture3D
#define TEXTURE_RECT texture2DRect
#define TEXTURE_CUBE textureCube
#endif
// Invariance
#if __VERSION__ >= 120
#define INVARIANT invariant
#else
#define INVARIANT
#endif
// Attribute location
#if defined(GL_ARB_explicit_attrib_location)
#define LOCATION(loc) layout(location = loc)
#else
#define LOCATION(loc)
#endif
// Geometry shader layout
#if __VERSION__ >= 150
#define GEOMETRY_LAYOUT_IN(from) layout (from) in
#define GEOMETRY_LAYOUT(to, max) layout (to, max_vertices = max) out
#else
#define GEOMETRY_LAYOUT_IN(from)
#define GEOMETRY_LAYOUT(to, max)
#endif
// @EndInterface
事实上,在着色器源代码之前包含着色器,框架可以在各种编译器上进行编译。当然,框架必须检测实际的系统功能并定义编译器参数,以便正确完成工作(考虑一下线着色器,因为线宽 > 1.0 已弃用)。
当然,着色器基础设施可以定义最低要求。一旦着色器需要 GLSL 1.50 或更高版本的核心配置文件,就不再需要上面包含的着色器。
关于OpenGL 着色语言向后兼容性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2631324/
这不是我的专业领域,所以我希望问的是正确的问题。 我们有一台滚动租用的服务器。旧服务器是32位windows服务器,新服务器是64位windows 2008 R2 SP1。 其中一个 Web 应用程序
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我已将 Oracle 数据库从 10g 迁移到 12c。从 12c 开始,oracle 不支持 PLSQL_V2_COMPATIBILITY 参数。 该参数用于: https://www.safari
开发环境db server为SqlServer 2005(开发版) 有什么方法可以确保我的 SQL 查询将在 SqlServer 2000 中运行? 此数据库设置为兼容级别“SQL Server 20
我有一个这种形式的类: public class Foo implements Serializable { private static final long serialVersionUI
我有以下代码来隐藏状态栏,取自 http://developer.android.com/training/system-ui/status.html和 Hide status bar android
我正在尝试测试 .prop() 是否方法存在于当前包含的 jQuery 中(出于兼容性原因): if(typeof $.prop === 'function') 我期望上面的条件是 true对于 jQ
当收到新消息时,我在项目中使用BroadcastChannel更改所有选项卡的标题。 问题在于它仅适用于chrome和firefox。因此,我决定使用localStorage创建一个Broadcast
我正在使用一个函数通过 FTP 将一个文件上传到我的服务器。这是我的代码并且工作正常但是创建的文件 example.json 不兼容 UTF8,因为它有 Atlético 而不是 Atlético 例
我正在使用兼容性类来构建用户代理字符串: public abstract class Compatibility { private static int sdkInt = 0; pr
我需要实现一个 C 例程来(解)压缩 gzip 格式的文件。 谁能举个例子? 我试过 zlib,但它似乎不兼容。 谢谢。 最佳答案 zlib 与 gzip 文件完全兼容,但您需要确保您使用的是面向 g
我正在使用以下 CSS 代码,它与 Chrome 完美兼容,但与 IE 浏览器不兼容 .collapse{ display:block; } .collapse + input[type="c
我的应用程序以 android Sdk 的 v10 为目标,但具有 minSdkVersion 的 v6。默认情况下,“match_parent”属性将用于宽度或高度。我应该为 fill_parent
我正在阅读有关 dynamic_cast 的内容,然后我遇到了以下语句 ( from cplusplus.com ): Compatibility note: This type of dynamic
我正在尝试在 Linux 下使用 QtCreator 构建一个用 VS 2008 编写的项目,但我遇到了很多错误: /home/ga/dev/CppGroup/MonteCarlo/main.cpp:
因此,我正在构建一个网站,用户可以在该网站上上传观看视频。我正在使用标准的 HTML5 视频播放器 ( ... )目前,我使用多个来源:MP4、OGG 和 WEBM,以实现跨浏览器兼容性 由于维护三
mozilla 和其他浏览器是否有类似-webkit-box-reflect 的属性?我无法在谷歌上找到哪些其他浏览器支持这个。因此,如果有人可以告诉我或给我链接,那就太好了。 最佳答案 这不仅可以使
我定义了一个自定义的 ValidateSet 参数属性,如下所示: Class MyValidValuesAttribute : System.Management.Automation.IValid
我使用 .net 4.0、linq 等编写 winforms 应用程序。它可以在带有 .net 2.0 的机器上运行吗? 最佳答案 不,不会。为 Framework 4.0 版编译的应用程序将要求该框
我如何专门检查 @keyframes translate3d 动画 与浏览器的兼容性? 请不要关闭这个问题,因为在问这个问题之前我已经尝试了很多 stackoverflow 解决方案。 我想检查我的网
我是一名优秀的程序员,十分优秀!