|
|
@ -53,9 +53,9 @@ public final class Shader extends NativeObject { |
|
|
|
private final ListMap<String, Uniform> uniforms; |
|
|
|
private final ListMap<String, Uniform> uniforms; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Maps storage block name to the storage block variable. |
|
|
|
* Maps storage block name to the buffer block variables. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private final ListMap<String, StorageBlock> storageBlocks; |
|
|
|
private final ListMap<String, ShaderBufferBlock> bufferBlocks; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Uniforms bound to {@link UniformBinding}s. |
|
|
|
* Uniforms bound to {@link UniformBinding}s. |
|
|
@ -227,7 +227,7 @@ public final class Shader extends NativeObject { |
|
|
|
super(); |
|
|
|
super(); |
|
|
|
shaderSourceList = new ArrayList<>(); |
|
|
|
shaderSourceList = new ArrayList<>(); |
|
|
|
uniforms = new ListMap<>(); |
|
|
|
uniforms = new ListMap<>(); |
|
|
|
storageBlocks = new ListMap<>(); |
|
|
|
bufferBlocks = new ListMap<>(); |
|
|
|
attribs = new IntMap<>(); |
|
|
|
attribs = new IntMap<>(); |
|
|
|
boundUniforms = new ArrayList<>(); |
|
|
|
boundUniforms = new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
@ -246,7 +246,7 @@ public final class Shader extends NativeObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uniforms = null; |
|
|
|
uniforms = null; |
|
|
|
storageBlocks = null; |
|
|
|
bufferBlocks = null; |
|
|
|
boundUniforms = null; |
|
|
|
boundUniforms = null; |
|
|
|
attribs = null; |
|
|
|
attribs = null; |
|
|
|
} |
|
|
|
} |
|
|
@ -296,24 +296,24 @@ public final class Shader extends NativeObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get or create a storage block by the name. |
|
|
|
* Gets or creates a buffer block by the name. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param name the storage block's name. |
|
|
|
* @param name the buffer block's name. |
|
|
|
* @return the storage block. |
|
|
|
* @return the buffer block. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public StorageBlock getStorageBlock(final String name) { |
|
|
|
public ShaderBufferBlock getBufferBlock(final String name) { |
|
|
|
|
|
|
|
|
|
|
|
assert name.startsWith("m_"); |
|
|
|
assert name.startsWith("m_"); |
|
|
|
|
|
|
|
|
|
|
|
StorageBlock storageBlock = storageBlocks.get(name); |
|
|
|
ShaderBufferBlock block = bufferBlocks.get(name); |
|
|
|
|
|
|
|
|
|
|
|
if (storageBlock == null) { |
|
|
|
if (block == null) { |
|
|
|
storageBlock = new StorageBlock(); |
|
|
|
block = new ShaderBufferBlock(); |
|
|
|
storageBlock.name = name; |
|
|
|
block.name = name; |
|
|
|
storageBlocks.put(name, storageBlock); |
|
|
|
bufferBlocks.put(name, block); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return storageBlock; |
|
|
|
return block; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void removeUniform(String name){ |
|
|
|
public void removeUniform(String name){ |
|
|
@ -321,12 +321,12 @@ public final class Shader extends NativeObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Remove a storage block by the name. |
|
|
|
* Removes a buffer block by the name. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param name the storage block's name. |
|
|
|
* @param name the buffer block's name. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void removeStorageBlock(final String name){ |
|
|
|
public void removeBufferBlock(final String name){ |
|
|
|
storageBlocks.remove(name); |
|
|
|
bufferBlocks.remove(name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Attribute getAttribute(VertexBuffer.Type attribType){ |
|
|
|
public Attribute getAttribute(VertexBuffer.Type attribType){ |
|
|
@ -345,12 +345,12 @@ public final class Shader extends NativeObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get the storage blocks map. |
|
|
|
* Get the buffer blocks map. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return the storage blocks map. |
|
|
|
* @return the buffer blocks map. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ListMap<String, StorageBlock> getStorageBlockMap() { |
|
|
|
public ListMap<String, ShaderBufferBlock> getBufferBlockMap() { |
|
|
|
return storageBlocks; |
|
|
|
return bufferBlocks; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<Uniform> getBoundUniforms() { |
|
|
|
public ArrayList<Uniform> getBoundUniforms() { |
|
|
@ -366,7 +366,7 @@ public final class Shader extends NativeObject { |
|
|
|
return getClass().getSimpleName() + |
|
|
|
return getClass().getSimpleName() + |
|
|
|
"[numSources=" + shaderSourceList.size() + |
|
|
|
"[numSources=" + shaderSourceList.size() + |
|
|
|
", numUniforms=" + uniforms.size() + |
|
|
|
", numUniforms=" + uniforms.size() + |
|
|
|
", numStorageBlocks=" + storageBlocks.size() + |
|
|
|
", numBufferBlocks=" + bufferBlocks.size() + |
|
|
|
", shaderSources=" + getSources() + "]"; |
|
|
|
", shaderSources=" + getSources() + "]"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -413,9 +413,9 @@ public final class Shader extends NativeObject { |
|
|
|
uniform.reset(); // fixes issue with re-initialization
|
|
|
|
uniform.reset(); // fixes issue with re-initialization
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (storageBlocks != null) { |
|
|
|
if (bufferBlocks != null) { |
|
|
|
for (StorageBlock storageBlock : storageBlocks.values()) { |
|
|
|
for (ShaderBufferBlock shaderBufferBlock : bufferBlocks.values()) { |
|
|
|
storageBlock.reset(); |
|
|
|
shaderBufferBlock.reset(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (attribs != null) { |
|
|
|
if (attribs != null) { |
|
|
|