6 Replies Latest reply on Mar 6, 2009 6:04 PM by licoah

    about constant buffer

    licoah

      I had written my program as follows:

      for(CALuint i = 0; i < cNum; i++)
          {
              r = calResAllocRemote1D(&_Res[offset + i], device, 1, 1, CAL_FORMAT_BYTE_4, 0);
                  if(r != CAL_RESULT_OK)
                  {
                      fprintf(stderr, "AllocateRes: constants: There is an error in calResAllocLocal1D\n");
                      return 0;
                  }
                  r = calCtxGetMem(&_Mem[offset + i], *ctx, _Res[offset + i]);
                  if(r != CAL_RESULT_OK)
                  {
                      fprintf(stderr, "AllocateRes: constants:There is an error in calCtxGetMem\n");
                      return 0;
                  }
          }

      ...

       

      for(CALuint i = 0; i < cNum; i++)
          {
              sprintf(buffer, "cb%d", i);
              r = calModuleGetName(&progName, *ctx, *module, buffer);
              if(r != CAL_RESULT_OK)
              {
                  fprintf(stderr, "BindIOName: constants: Error string is %s\n",calGetErrorString());
                  fprintf(stderr, "Failing name binding was %s\n", buffer);
                  return 0;
              }
              r = calCtxSetMem(*ctx, progName, _Mem[offset + i]);
              if(r != CAL_RESULT_OK)
              {
                  fprintf(stderr, "BindIOName: calCtxSetMem: constants: Error string is %s %d\n",calGetErrorString(),i);
                  return 0;
              }
          }

      then I got this error message:

      BindIOName: calCtxSetMem:constants: Error string is Invalid format for constant buffer " 0

      I don't know the reason for this.

      Can somebody help me?

        • about constant buffer
          gaurav.garg

          8-bit, 16-bit datatypes are not supported for constant buffers, use 32-bit formats for constant buffer allocation.

            • about constant buffer
              licoah

              thank you

              but now there is new problem

              for(CALuint i = 0; i < cNum; i++)
                  {
                      r = calResAllocRemote1D(&_Res[offset + i], device, 1, 1, CAL_FORMAT_INT_4, 0);
                          if(r != CAL_RESULT_OK)
                          {
                              fprintf(stderr, "AllocateRes: constants: There is an error in calResAllocLocal1D\n");
                              return 0;
                          }
                          r = calCtxGetMem(&_Mem[offset + i], *ctx, _Res[offset + i]);
                          if(r != CAL_RESULT_OK)
                          {
                              fprintf(stderr, "AllocateRes: constants:There is an error in calCtxGetMem\n");
                              return 0;
                          }
                  }

              ....

              for(CALuint i = 0; i < cNum; i++)
                  {
                      sprintf(buffer, "cb%d", i);
                      r = calModuleGetName(&progName, *ctx, *module, buffer);
                      if(r != CAL_RESULT_OK)
                      {
                          fprintf(stderr, "BindIOName: constants: Error string is %s\n",calGetErrorString());
                          fprintf(stderr, "Failing name binding was %s\n", buffer);
                          return 0;
                      }
                      r = calCtxSetMem(*ctx, progName, _Mem[offset + i]);
                      if(r != CAL_RESULT_OK)
                      {
                          fprintf(stderr, "BindIOName: calCtxSetMem: constants: Error string is %s %d\n",calGetErrorString(),i);
                          return 0;
                      }
                  }

              error message:

              BindIOName: constants: Error string is Operational error
              Failing name binding was cb1