Merge branch 'master' into d3d12

This commit is contained in:
Triang3l 2018-11-08 19:45:56 +03:00
commit 6274f664f9
3 changed files with 19 additions and 22 deletions

View File

@ -158,7 +158,7 @@ SHIM_CALL XamContentResolve_shim(PPCContext* ppc_context,
dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id, dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id,
dword_t content_type, dword_t content_type,
dword_t content_flags, dword_t content_flags,
dword_t max_count, dword_t items_per_enumerate,
lpdword_t buffer_size_ptr, lpdword_t buffer_size_ptr,
lpdword_t handle_out) { lpdword_t handle_out) {
assert_not_null(handle_out); assert_not_null(handle_out);
@ -173,11 +173,11 @@ dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id,
} }
if (buffer_size_ptr) { if (buffer_size_ptr) {
*buffer_size_ptr = (uint32_t)XCONTENT_DATA::kSize * max_count; *buffer_size_ptr = (uint32_t)XCONTENT_DATA::kSize * items_per_enumerate;
} }
auto e = auto e = new XStaticEnumerator(kernel_state(), items_per_enumerate,
new XStaticEnumerator(kernel_state(), max_count, XCONTENT_DATA::kSize); XCONTENT_DATA::kSize);
e->Initialize(); e->Initialize();
// Get all content data. // Get all content data.
@ -187,14 +187,13 @@ dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id,
content_type); content_type);
for (auto& content_data : content_datas) { for (auto& content_data : content_datas) {
auto ptr = e->AppendItem(); auto ptr = e->AppendItem();
if (!ptr) { assert_not_null(ptr);
// Too many items.
break;
}
content_data.Write(ptr); content_data.Write(ptr);
} }
XELOGD("XamContentCreateEnumerator: added %d items to enumerator",
e->item_count());
*handle_out = e->handle(); *handle_out = e->handle();
return X_ERROR_SUCCESS; return X_ERROR_SUCCESS;
} }

View File

@ -12,10 +12,10 @@
namespace xe { namespace xe {
namespace kernel { namespace kernel {
XEnumerator::XEnumerator(KernelState* kernel_state, size_t item_capacity, XEnumerator::XEnumerator(KernelState* kernel_state, size_t items_per_enumerate,
size_t item_size) size_t item_size)
: XObject(kernel_state, kTypeEnumerator), : XObject(kernel_state, kTypeEnumerator),
item_capacity_(item_capacity), items_per_enumerate_(items_per_enumerate),
item_size_(item_size) {} item_size_(item_size) {}
XEnumerator::~XEnumerator() = default; XEnumerator::~XEnumerator() = default;

View File

@ -23,7 +23,7 @@ class XEnumerator : public XObject {
public: public:
static const Type kType = kTypeEnumerator; static const Type kType = kTypeEnumerator;
XEnumerator(KernelState* kernel_state, size_t item_capacity, XEnumerator(KernelState* kernel_state, size_t items_per_enumerate,
size_t item_size); size_t item_size);
virtual ~XEnumerator(); virtual ~XEnumerator();
@ -34,30 +34,28 @@ class XEnumerator : public XObject {
virtual bool WriteItem(uint8_t* buffer) = 0; virtual bool WriteItem(uint8_t* buffer) = 0;
size_t item_size() const { return item_size_; } size_t item_size() const { return item_size_; }
size_t items_per_enumerate() const { return items_per_enumerate_; }
size_t current_item() const { return current_item_; } size_t current_item() const { return current_item_; }
protected: protected:
size_t item_capacity_ = 0; size_t items_per_enumerate_ = 0;
size_t item_size_ = 0; size_t item_size_ = 0;
size_t current_item_ = 0; size_t current_item_ = 0;
}; };
class XStaticEnumerator : public XEnumerator { class XStaticEnumerator : public XEnumerator {
public: public:
XStaticEnumerator(KernelState* kernel_state, size_t item_capacity, XStaticEnumerator(KernelState* kernel_state, size_t items_per_enumerate,
size_t item_size) size_t item_size)
: XEnumerator(kernel_state, item_capacity, item_size), item_count_(0) { : XEnumerator(kernel_state, items_per_enumerate, item_size),
buffer_.resize(item_capacity_ * item_size_); item_count_(0) {}
}
uint32_t item_count() const override { return item_count_; } uint32_t item_count() const override { return item_count_; }
uint8_t* AppendItem() { uint8_t* AppendItem() {
if (item_count_ + 1 > item_capacity_) { buffer_.resize(++item_count_ * item_size_);
return nullptr; auto ptr =
} const_cast<uint8_t*>(buffer_.data() + (item_count_ - 1) * item_size_);
auto ptr = const_cast<uint8_t*>(buffer_.data() + item_count_ * item_size_);
++item_count_;
return ptr; return ptr;
} }