clover: Don't try to build programs created from a binary again.
authorFrancisco Jerez <currojerez@riseup.net>
Tue, 14 Jan 2014 20:55:29 +0000 (21:55 +0100)
committerFrancisco Jerez <currojerez@riseup.net>
Wed, 15 Jan 2014 15:48:05 +0000 (16:48 +0100)
According to the spec it's allowed to call clBuildProgram() on a
program created from a user-specified binary.  We don't need to do
anything to build the program in that case.

Reported-and-tested-by: "Dorrington, Albert" <albert.dorrington@lmco.com>
src/gallium/state_trackers/clover/core/program.cpp
src/gallium/state_trackers/clover/core/program.hpp

index 6d4a9ba81ff5ef69537659e2720b6efad7423d7b..fb7e8d14a99a92c486a1a34ac27723f68538d76a 100644 (file)
 using namespace clover;
 
 program::program(context &ctx, const std::string &source) :
-   ctx(ctx), _source(source) {
+   has_source(true), ctx(ctx), _source(source) {
 }
 
 program::program(context &ctx,
                  const ref_vector<device> &devs,
                  const std::vector<module> &binaries) :
-   ctx(ctx) {
+   has_source(false), ctx(ctx) {
    for_each([&](device &dev, const module &bin) {
          _binaries.insert({ &dev, bin });
       },
@@ -41,23 +41,25 @@ program::program(context &ctx,
 
 void
 program::build(const ref_vector<device> &devs, const char *opts) {
-   for (auto &dev : devs) {
-      _binaries.erase(&dev);
-      _logs.erase(&dev);
-      _opts.erase(&dev);
-
-      _opts.insert({ &dev, opts });
-
-      try {
-         auto module = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
-                        compile_program_tgsi(_source) :
-                        compile_program_llvm(_source, dev.ir_format(),
-                                             dev.ir_target(), build_opts(dev)));
-         _binaries.insert({ &dev, module });
-
-      } catch (build_error &e) {
-         _logs.insert({ &dev, e.what() });
-         throw;
+   if (has_source) {
+      for (auto &dev : devs) {
+         _binaries.erase(&dev);
+         _logs.erase(&dev);
+         _opts.erase(&dev);
+
+         _opts.insert({ &dev, opts });
+
+         try {
+            auto module = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
+                           compile_program_tgsi(_source) :
+                           compile_program_llvm(_source, dev.ir_format(),
+                                                dev.ir_target(), build_opts(dev)));
+            _binaries.insert({ &dev, module });
+
+         } catch (build_error &e) {
+            _logs.insert({ &dev, e.what() });
+            throw;
+         }
       }
    }
 }
index 25ec239507de9afb4df5589016e8e3b65cd861c8..d36982cb3cabcb27eecc999a15a25ecb3e3113de 100644 (file)
@@ -49,6 +49,7 @@ namespace clover {
 
       void build(const ref_vector<device> &devs, const char *opts);
 
+      const bool has_source;
       const std::string &source() const;
 
       device_range devices() const;