Skip to content

Commit

Permalink
template <typename T>
Browse files Browse the repository at this point in the history
  • Loading branch information
mizt committed Oct 10, 2021
1 parent e21f054 commit 8a8b304
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions ComputeShaderBase.h
@@ -1,3 +1,4 @@
template <typename T>
class ComputeShaderBase {

private:
Expand Down Expand Up @@ -57,18 +58,18 @@ class ComputeShaderBase {

bool init() { return this->_init; }

void replace(id<MTLTexture> texture, unsigned int *data) {
void replace(id<MTLTexture> texture, T *data) {
[texture replaceRegion:MTLRegionMake2D(0,0,this->_width,this->_height) mipmapLevel:0 withBytes:data bytesPerRow:(this->_width)<<2];
}

void copy(unsigned int *data, id<MTLTexture> texture) {
void copy(T *data, id<MTLTexture> texture) {
[texture getBytes:data bytesPerRow:this->_width<<2 fromRegion:MTLRegionMake2D(0,0,this->_width,this->_height) mipmapLevel:0];
}

void fill(unsigned int *data,unsigned int abgr) {
void fill(T *data,T value) {
for(int i=0; i<this->_height; i++) {
for(int j=0; j<this->_width; j++) {
this->_buffer[0][i*this->_width+j] = abgr;
data[i*this->_width+j] = value;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion HydraComputeShader.h
Expand Up @@ -21,7 +21,7 @@ namespace Hydra {
};
}

class HydraComputeShader : public ComputeShaderBase {
class HydraComputeShader : public ComputeShaderBase<unsigned int> {

protected:

Expand Down

0 comments on commit 8a8b304

Please sign in to comment.