From 04a68c1dec82814fd06630361261adaeec00b277 Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Thu, 2 Mar 2017 20:50:30 -0800 Subject: [PATCH] Fixed a small bug regarding to AMD vs Intel OpenCL implementations --- include/Map.h | 4 ---- include/raycaster/Hardware_Caster.h | 2 +- src/main.cpp | 4 ++-- src/raycaster/Hardware_Caster.cpp | 8 ++++---- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/Map.h b/include/Map.h index cc75b52..8af3ecf 100644 --- a/include/Map.h +++ b/include/Map.h @@ -29,10 +29,6 @@ struct XYZHasher { } }; - - - - class Octree { public: Octree() { diff --git a/include/raycaster/Hardware_Caster.h b/include/raycaster/Hardware_Caster.h index 0c7b202..139eb7e 100644 --- a/include/raycaster/Hardware_Caster.h +++ b/include/raycaster/Hardware_Caster.h @@ -80,7 +80,7 @@ private: int check_cl_khr_gl_sharing(); - int create_image_buffer(std::string buffer_name, cl_uint size, sf::Texture* texture); + int create_image_buffer(std::string buffer_name, cl_uint size, sf::Texture* texture, cl_int access_type); int create_buffer(std::string buffer_name, cl_uint size, void* data); int create_buffer(std::string buffer_name, cl_uint size, void* data, cl_mem_flags flags); int store_buffer(cl_mem, std::string buffer_name); diff --git a/src/main.cpp b/src/main.cpp index 13c54f4..01b2602 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -92,7 +92,7 @@ int main() { _map.a.get_voxel(sf::Vector3i(5, 5, 0)); // ============================= - return 0; + sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML"); window.setMouseCursorVisible(false); @@ -147,7 +147,7 @@ int main() { // Load in the spritesheet texture sf::Texture spritesheet; spritesheet.loadFromFile("../assets/textures/minecraft_tiles.png"); - spritesheet.getNativeHandle(); + //spritesheet.getNativeHandle(); raycaster->create_texture_atlas(&spritesheet, sf::Vector2i(16, 16)); diff --git a/src/raycaster/Hardware_Caster.cpp b/src/raycaster/Hardware_Caster.cpp index 57bd428..82ec9c2 100644 --- a/src/raycaster/Hardware_Caster.cpp +++ b/src/raycaster/Hardware_Caster.cpp @@ -99,7 +99,7 @@ void Hardware_Caster::validate() void Hardware_Caster::create_texture_atlas(sf::Texture *t, sf::Vector2i tile_dim) { - create_image_buffer("texture_atlas", t->getSize().x * t->getSize().x * 4 * sizeof(float), t); + create_image_buffer("texture_atlas", t->getSize().x * t->getSize().x * 4 * sizeof(float), t, CL_MEM_READ_ONLY); // create_buffer observes arg 3's @@ -191,7 +191,7 @@ void Hardware_Caster::create_viewport(int width, int height, float v_fov, float viewport_sprite.setTexture(viewport_texture); // Pass the buffer to opencl - create_image_buffer("image", sizeof(sf::Uint8) * width * height * 4, &viewport_texture); + create_image_buffer("image", sizeof(sf::Uint8) * width * height * 4, &viewport_texture, CL_MEM_WRITE_ONLY); } @@ -529,7 +529,7 @@ int Hardware_Caster::set_kernel_arg( } -int Hardware_Caster::create_image_buffer(std::string buffer_name, cl_uint size, sf::Texture* texture) { +int Hardware_Caster::create_image_buffer(std::string buffer_name, cl_uint size, sf::Texture* texture, cl_int access_type) { // I can imagine overwriting buffers will be common, so I think // this is safe to overwrite / release old buffers quietly @@ -539,7 +539,7 @@ int Hardware_Caster::create_image_buffer(std::string buffer_name, cl_uint size, int error; cl_mem buff = clCreateFromGLTexture( - getContext(), CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, + getContext(), access_type, GL_TEXTURE_2D, 0, texture->getNativeHandle(), &error); if (assert(error, "clCreateFromGLTexture"))