summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-10-26 15:34:15 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-11 12:04:56 +0100
commit971ce680f22f6bebbccb333c48b2d2983550e50d (patch)
tree209a79b2da6bc8c311ff84c2870a837b03880c3b
parentf4948721e48a469bdf174b463bd948cfed27462f (diff)
Fixes to how anisotropy is handled, makes it work on nvidia.
-rw-r--r--servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp21
-rw-r--r--servers/visual/rasterizer_rd/rasterizer_scene_rd.h1
2 files changed, 13 insertions, 9 deletions
diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp
index 80d1b33043..b2e90c7f59 100644
--- a/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp
+++ b/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp
@@ -1259,8 +1259,8 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
if (gi_probe->texture.is_valid()) {
RD::get_singleton()->free(gi_probe->texture);
if (gi_probe_use_anisotropy) {
- RD::get_singleton()->free(gi_probe->anisotropy[0]);
- RD::get_singleton()->free(gi_probe->anisotropy[1]);
+ RD::get_singleton()->free(gi_probe->anisotropy_r16[0]);
+ RD::get_singleton()->free(gi_probe->anisotropy_r16[1]);
}
RD::get_singleton()->free(gi_probe->write_buffer);
gi_probe->mipmaps.clear();
@@ -1279,9 +1279,6 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
//can create a 3D texture
PoolVector<int> levels = storage->gi_probe_get_level_counts(gi_probe->probe);
- for (int i = 0; i < levels.size(); i++) {
- print_line("level " + itos(i) + ": " + itos(levels[i]));
- }
RD::TextureFormat tf;
tf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
tf.width = octree_size.x;
@@ -1297,12 +1294,18 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc
RD::get_singleton()->texture_clear(gi_probe->texture, Color(0, 0, 0, 0), 0, levels.size(), 0, 1, false);
if (gi_probe_use_anisotropy) {
- tf.format = RD::DATA_FORMAT_R5G6B5_UNORM_PACK16;
- tf.shareable_formats.push_back(RD::DATA_FORMAT_R5G6B5_UNORM_PACK16);
+ tf.format = RD::DATA_FORMAT_R16_UINT;
tf.shareable_formats.push_back(RD::DATA_FORMAT_R16_UINT);
+ tf.shareable_formats.push_back(RD::DATA_FORMAT_R5G6B5_UNORM_PACK16);
+
+ //need to create R16 first, else driver does not like the storage bit for compute..
+ gi_probe->anisotropy_r16[0] = RD::get_singleton()->texture_create(tf, RD::TextureView());
+ gi_probe->anisotropy_r16[1] = RD::get_singleton()->texture_create(tf, RD::TextureView());
- gi_probe->anisotropy[0] = RD::get_singleton()->texture_create(tf, RD::TextureView());
- gi_probe->anisotropy[1] = RD::get_singleton()->texture_create(tf, RD::TextureView());
+ RD::TextureView tv;
+ tv.format_override = RD::DATA_FORMAT_R5G6B5_UNORM_PACK16;
+ gi_probe->anisotropy[0] = RD::get_singleton()->texture_create_shared(tv, gi_probe->anisotropy_r16[0]);
+ gi_probe->anisotropy[1] = RD::get_singleton()->texture_create_shared(tv, gi_probe->anisotropy_r16[1]);
RD::get_singleton()->texture_clear(gi_probe->anisotropy[0], Color(0, 0, 0, 0), 0, levels.size(), 0, 1, false);
RD::get_singleton()->texture_clear(gi_probe->anisotropy[1], Color(0, 0, 0, 0), 0, levels.size(), 0, 1, false);
diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_rd.h b/servers/visual/rasterizer_rd/rasterizer_scene_rd.h
index c3a647ddb1..d94ee60a2a 100644
--- a/servers/visual/rasterizer_rd/rasterizer_scene_rd.h
+++ b/servers/visual/rasterizer_rd/rasterizer_scene_rd.h
@@ -181,6 +181,7 @@ private:
RID probe;
RID texture;
RID anisotropy[2]; //only if anisotropy is used
+ RID anisotropy_r16[2]; //only if anisotropy is used
RID write_buffer;
struct Mipmap {