intel: add command buffer relocs
diff --git a/icd/intel/cmd_priv.h b/icd/intel/cmd_priv.h
index 52b44fd..1c1c2e2 100644
--- a/icd/intel/cmd_priv.h
+++ b/icd/intel/cmd_priv.h
@@ -54,6 +54,24 @@
}
/**
+ * Add a reloc for the value at \p offset.
+ */
+static inline void cmd_add_reloc(struct intel_cmd *cmd, XGL_INT offset,
+ uint32_t val, struct intel_mem *mem,
+ uint16_t read_domains, uint16_t write_domain)
+{
+ struct intel_cmd_reloc *reloc = &cmd->relocs[cmd->reloc_used];
+
+ reloc->pos = cmd->used + offset;
+ reloc->val = val;
+ reloc->mem = mem;
+ reloc->read_domains = read_domains;
+ reloc->write_domain = write_domain;
+
+ cmd->reloc_used++;
+}
+
+/**
* Advance without writing.
*/
static inline void cmd_advance(struct intel_cmd *cmd, XGL_UINT len)
@@ -63,18 +81,6 @@
}
/**
- * Write \p len DWords and advance.
- */
-static inline void cmd_writen(struct intel_cmd *cmd,
- const uint32_t *vals, XGL_UINT len)
-{
- assert(cmd->used + len <= cmd->size);
- memcpy((uint32_t *) cmd->ptr_opaque + cmd->used,
- vals, sizeof(uint32_t) * len);
- cmd->used += len;
-}
-
-/**
* Write a DWord and advance.
*/
static inline void cmd_write(struct intel_cmd *cmd, uint32_t val)
@@ -83,4 +89,37 @@
((uint32_t *) cmd->ptr_opaque)[cmd->used++] = val;
}
+/**
+ * Write \p len DWords and advance.
+ */
+static inline void cmd_write_n(struct intel_cmd *cmd,
+ const uint32_t *vals, XGL_UINT len)
+{
+ assert(cmd->used + len <= cmd->size);
+ memcpy((uint32_t *) cmd->ptr_opaque + cmd->used,
+ vals, sizeof(uint32_t) * len);
+ cmd->used += len;
+}
+
+/**
+ * Write a reloc and advance.
+ */
+static inline void cmd_write_r(struct intel_cmd *cmd, uint32_t val,
+ struct intel_mem *mem,
+ uint16_t read_domains, uint16_t write_domain)
+{
+ cmd_add_reloc(cmd, 0, val, mem, read_domains, write_domain);
+ cmd->used++;
+}
+
+/**
+ * Patch the given \p pos.
+ */
+static inline void cmd_patch(struct intel_cmd *cmd,
+ XGL_UINT pos, uint32_t val)
+{
+ assert(pos < cmd->used);
+ ((uint32_t *) cmd->ptr_opaque)[pos] = val;
+}
+
#endif /* CMD_PRIV_H */